forked from friendica/friendica-addons
First part of Refactoring to stay compatible with v2.0 of the VObject library
This commit is contained in:
parent
8751d2221b
commit
87d314170b
|
@ -99,51 +99,6 @@ class vcard_source_data
|
||||||
public $photo;
|
public $photo;
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param vcard_source_data $vcardsource
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function vcard_source_compile($vcardsource)
|
|
||||||
{
|
|
||||||
$str = "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\n";
|
|
||||||
$str .= "N:" . str_replace(";", ",", $vcardsource->name_last) . ";" . str_replace(";", ",", $vcardsource->name_first) . ";" . str_replace(";", ",", $vcardsource->name_middle) . ";;\r\n";
|
|
||||||
$str .= "FN:" . str_replace(";", ",", $vcardsource->name_first) . " " . str_replace(";", ",", $vcardsource->name_middle) . " " . str_replace(";", ",", $vcardsource->name_last) . "\r\n";
|
|
||||||
$str .= "REV:" . str_replace(" ", "T", $vcardsource->last_update) . "Z\r\n";
|
|
||||||
|
|
||||||
$item_count = 0;
|
|
||||||
for ($i = 0; $i < count($vcardsource->homepages); $i++) {
|
|
||||||
if ($i == 0) $str .= "URL;type=" . $vcardsource->homepages[0]->type . ":" . $vcardsource->homepages[0]->homepage . "\r\n";
|
|
||||||
else {
|
|
||||||
$c = ++$item_count;
|
|
||||||
$str .= "item$c.URL;type=" . $vcardsource->homepages[0]->type . ":" . $vcardsource->homepages[0]->homepage . "\r\n";
|
|
||||||
$str .= "item$c.X-ABLabel:_\$!<HomePage>!\$_\r\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_object($vcardsource->photo)) {
|
|
||||||
$data = base64_encode($vcardsource->photo->binarydata);
|
|
||||||
$str .= "PHOTO;ENCODING=BASE64;TYPE=" . $vcardsource->photo->type . ":" . $data . "\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($vcardsource->socialnetworks) && is_array($vcardsource->socialnetworks)) foreach ($vcardsource->socialnetworks as $netw) switch ($netw->type) {
|
|
||||||
case "dfrn":
|
|
||||||
$str .= "X-SOCIALPROFILE;type=dfrn;x-user=" . $netw->nick . ":" . $netw->url . "\r\n";
|
|
||||||
break;
|
|
||||||
case "facebook":
|
|
||||||
$str .= "X-SOCIALPROFILE;type=facebook;x-user=" . $netw->nick . ":" . $netw->url . "\r\n";
|
|
||||||
break;
|
|
||||||
case "twitter":
|
|
||||||
$str .= "X-SOCIALPROFILE;type=twitter;x-user=" . $netw->nick . ":" . $netw->url . "\r\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$str .= "END:VCARD\r\n";
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $phpDate (UTC)
|
* @param int $phpDate (UTC)
|
||||||
|
@ -237,7 +192,7 @@ function dav_create_server($force_authentication = false, $needs_caldav = true,
|
||||||
|
|
||||||
if (CALDAV_URL_PREFIX != "") $server->setBaseUri(CALDAV_URL_PREFIX);
|
if (CALDAV_URL_PREFIX != "") $server->setBaseUri(CALDAV_URL_PREFIX);
|
||||||
|
|
||||||
$authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), 'SabreDAV');
|
$authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), DAV_APPNAME);
|
||||||
$server->addPlugin($authPlugin);
|
$server->addPlugin($authPlugin);
|
||||||
|
|
||||||
if ($needs_caldav) {
|
if ($needs_caldav) {
|
||||||
|
@ -253,6 +208,10 @@ function dav_create_server($force_authentication = false, $needs_caldav = true,
|
||||||
$aclPlugin = new $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"]();
|
$aclPlugin = new $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"]();
|
||||||
$aclPlugin->defaultUsernamePath = "principals/users";
|
$aclPlugin->defaultUsernamePath = "principals/users";
|
||||||
$server->addPlugin($aclPlugin);
|
$server->addPlugin($aclPlugin);
|
||||||
|
} else {
|
||||||
|
$aclPlugin = new Sabre_DAVACL_Plugin();
|
||||||
|
$aclPlugin->defaultUsernamePath = "principals/users";
|
||||||
|
$server->addPlugin($aclPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($force_authentication) $server->broadcastEvent('beforeMethod', array("GET", "/")); // Make it authenticate
|
if ($force_authentication) $server->broadcastEvent('beforeMethod', array("GET", "/")); // Make it authenticate
|
||||||
|
@ -298,7 +257,7 @@ function dav_get_current_user_calendars(&$server, $with_privilege = "")
|
||||||
* @param Sabre_CalDAV_Calendar $calendar
|
* @param Sabre_CalDAV_Calendar $calendar
|
||||||
* @param string $calendarobject_uri
|
* @param string $calendarobject_uri
|
||||||
* @param string $with_privilege
|
* @param string $with_privilege
|
||||||
* @return null|Sabre_VObject_Component_VCalendar
|
* @return null|Sabre\VObject\Component\VCalendar
|
||||||
*/
|
*/
|
||||||
function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobject_uri, $with_privilege = "")
|
function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobject_uri, $with_privilege = "")
|
||||||
{
|
{
|
||||||
|
@ -314,7 +273,7 @@ function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobje
|
||||||
if (!$aclplugin->checkPrivileges($uri, $with_privilege, Sabre_DAVACL_Plugin::R_PARENT, false)) return null;
|
if (!$aclplugin->checkPrivileges($uri, $with_privilege, Sabre_DAVACL_Plugin::R_PARENT, false)) return null;
|
||||||
|
|
||||||
$data = $obj->get();
|
$data = $obj->get();
|
||||||
$vObject = Sabre_VObject_Reader::read($data);
|
$vObject = Sabre\VObject\Reader::read($data);
|
||||||
|
|
||||||
return $vObject;
|
return $vObject;
|
||||||
}
|
}
|
||||||
|
@ -342,20 +301,19 @@ function dav_get_current_user_calendar_by_id(&$server, $id, $with_privilege = ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $uid
|
* @param string $uid
|
||||||
* @return Sabre_VObject_Component_VCalendar $vObject
|
* @return Sabre\VObject\Component\VCalendar $vObject
|
||||||
*/
|
*/
|
||||||
function dav_create_empty_vevent($uid = "")
|
function dav_create_empty_vevent($uid = "")
|
||||||
{
|
{
|
||||||
$a = get_app();
|
|
||||||
if ($uid == "") $uid = uniqid();
|
if ($uid == "") $uid = uniqid();
|
||||||
return Sabre_VObject_Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . dav_compat_get_hostname() .
|
return Sabre\VObject\Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . dav_compat_get_hostname() .
|
||||||
"\r\nDTSTAMP:" . date("Ymd") . "T" . date("His") . "Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
|
"\r\nDTSTAMP:" . date("Ymd") . "T" . date("His") . "Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Sabre_VObject_Component_VCalendar $vObject
|
* @param Sabre\VObject\Component\VCalendar $vObject
|
||||||
* @return Sabre_VObject_Component_VEvent|null
|
* @return Sabre\VObject\Component\VEvent|null
|
||||||
*/
|
*/
|
||||||
function dav_get_eventComponent(&$vObject)
|
function dav_get_eventComponent(&$vObject)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Sabre_VObject_Component_VAlarm $alarm
|
* @param Sabre\VObject\Component\VAlarm $alarm
|
||||||
* @param Sabre_VObject_Component_VEvent|Sabre_VObject_Component_VTodo $parent
|
* @param Sabre\VObject\Component\VEvent|Sabre\VObject\Component\VTodo $parent
|
||||||
* @return DateTime|null
|
* @return DateTime|null
|
||||||
* @throws Sabre_DAV_Exception
|
* @throws Sabre_DAV_Exception
|
||||||
*/
|
*/
|
||||||
|
@ -12,12 +12,12 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent)
|
||||||
{
|
{
|
||||||
$trigger = $alarm->__get("TRIGGER");
|
$trigger = $alarm->__get("TRIGGER");
|
||||||
if (!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') {
|
if (!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') {
|
||||||
$triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($trigger->value);
|
$triggerDuration = Sabre\VObject\DateTimeParser::parseDuration($trigger->value);
|
||||||
|
|
||||||
$related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START';
|
$related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START';
|
||||||
|
|
||||||
if ($related === 'START') {
|
if ($related === 'START') {
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtstart */
|
/** @var Sabre\VObject\Property\DateTime $dtstart */
|
||||||
$dtstart = $parent->__get("DTSTART");
|
$dtstart = $parent->__get("DTSTART");
|
||||||
$effectiveTrigger = $dtstart->getDateTime();
|
$effectiveTrigger = $dtstart->getDateTime();
|
||||||
$effectiveTrigger->add($triggerDuration);
|
$effectiveTrigger->add($triggerDuration);
|
||||||
|
@ -28,14 +28,14 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent)
|
||||||
$endProp = 'DTEND';
|
$endProp = 'DTEND';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtstart */
|
/** @var Sabre\VObject\Property\DateTime $dtstart */
|
||||||
$dtstart = $parent->__get("DTSTART");
|
$dtstart = $parent->__get("DTSTART");
|
||||||
if (isset($parent->$endProp)) {
|
if (isset($parent->$endProp)) {
|
||||||
$effectiveTrigger = clone $parent->$endProp->getDateTime();
|
$effectiveTrigger = clone $parent->$endProp->getDateTime();
|
||||||
$effectiveTrigger->add($triggerDuration);
|
$effectiveTrigger->add($triggerDuration);
|
||||||
} elseif ($parent->__get("DURATION") != "") {
|
} elseif ($parent->__get("DURATION") != "") {
|
||||||
$effectiveTrigger = clone $dtstart->getDateTime();
|
$effectiveTrigger = clone $dtstart->getDateTime();
|
||||||
$duration = Sabre_VObject_DateTimeParser::parseDuration($parent->__get("DURATION"));
|
$duration = Sabre\VObject\DateTimeParser::parseDuration($parent->__get("DURATION"));
|
||||||
$effectiveTrigger->add($duration);
|
$effectiveTrigger->add($duration);
|
||||||
$effectiveTrigger->add($triggerDuration);
|
$effectiveTrigger->add($triggerDuration);
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,10 +58,10 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent)
|
||||||
*/
|
*/
|
||||||
function renderCalDavEntry_data(&$calendar, &$calendarobject)
|
function renderCalDavEntry_data(&$calendar, &$calendarobject)
|
||||||
{
|
{
|
||||||
/** @var Sabre_VObject_Component_VCalendar $vObject */
|
/** @var Sabre\VObject\Component\VCalendar $vObject */
|
||||||
$vObject = Sabre_VObject_Reader::read($calendarobject["calendardata"]);
|
$vObject = Sabre\VObject\Reader::read($calendarobject["calendardata"]);
|
||||||
$componentType = null;
|
$componentType = null;
|
||||||
/** @var Sabre_VObject_Component_VEvent $component */
|
/** @var Sabre\VObject\Component\VEvent $component */
|
||||||
$component = null;
|
$component = null;
|
||||||
foreach ($vObject->getComponents() as $component) {
|
foreach ($vObject->getComponents() as $component) {
|
||||||
if ($component->name !== 'VTIMEZONE') {
|
if ($component->name !== 'VTIMEZONE') {
|
||||||
|
@ -86,18 +86,18 @@ function renderCalDavEntry_data(&$calendar, &$calendarobject)
|
||||||
);
|
);
|
||||||
|
|
||||||
$recurring = ($component->__get("RRULE") ? 1 : 0);
|
$recurring = ($component->__get("RRULE") ? 1 : 0);
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtstart */
|
/** @var Sabre\VObject\Property\DateTime $dtstart */
|
||||||
$dtstart = $component->__get("DTSTART");
|
$dtstart = $component->__get("DTSTART");
|
||||||
$allday = ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE ? 1 : 0);
|
$allday = ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE ? 1 : 0);
|
||||||
|
|
||||||
/** @var array|Sabre_VObject_Component_VAlarm[] $alarms */
|
/** @var array|Sabre\VObject\Component\VAlarm[] $alarms */
|
||||||
$alarms = array();
|
$alarms = array();
|
||||||
foreach ($component->getComponents() as $a_component) if ($a_component->name == "VALARM") {
|
foreach ($component->getComponents() as $a_component) if ($a_component->name == "VALARM") {
|
||||||
/** var Sabre_VObject_Component_VAlarm $component */
|
/** var Sabre\VObject\Component_VAlarm $component */
|
||||||
$alarms[] = $a_component;
|
$alarms[] = $a_component;
|
||||||
}
|
}
|
||||||
|
|
||||||
$it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
|
$it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID"));
|
||||||
$last_end = 0;
|
$last_end = 0;
|
||||||
$max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR * 1);
|
$max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR * 1);
|
||||||
$first = true;
|
$first = true;
|
||||||
|
|
|
@ -81,22 +81,22 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* @param Sabre_VObject_Component_VEvent $component
|
* @param Sabre\VObject\Component\VEvent $component
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getDtEndTimeStamp(&$component)
|
public static function getDtEndTimeStamp(&$component)
|
||||||
{
|
{
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtstart */
|
/** @var Sabre\VObject\Property\DateTime $dtstart */
|
||||||
$dtstart = $component->__get("DTSTART");
|
$dtstart = $component->__get("DTSTART");
|
||||||
if ($component->__get("DTEND")) {
|
if ($component->__get("DTEND")) {
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtend */
|
/** @var Sabre\VObject\Property\DateTime $dtend */
|
||||||
$dtend = $component->__get("DTEND");
|
$dtend = $component->__get("DTEND");
|
||||||
return $dtend->getDateTime()->getTimeStamp();
|
return $dtend->getDateTime()->getTimeStamp();
|
||||||
} elseif ($component->__get("DURATION")) {
|
} elseif ($component->__get("DURATION")) {
|
||||||
$endDate = clone $dtstart->getDateTime();
|
$endDate = clone $dtstart->getDateTime();
|
||||||
$endDate->add(Sabre_VObject_DateTimeParser::parse($component->__get("DURATION")->value));
|
$endDate->add(Sabre\VObject\DateTimeParser::parse($component->__get("DURATION")->value));
|
||||||
return $endDate->getTimeStamp();
|
return $endDate->getTimeStamp();
|
||||||
} elseif ($dtstart->getDateType() === Sabre_VObject_Property_DateTime::DATE) {
|
} elseif ($dtstart->getDateType() === Sabre\VObject\Property\DateTime::DATE) {
|
||||||
$endDate = clone $dtstart->getDateTime();
|
$endDate = clone $dtstart->getDateTime();
|
||||||
$endDate->modify('+1 day');
|
$endDate->modify('+1 day');
|
||||||
return $endDate->getTimeStamp();
|
return $endDate->getTimeStamp();
|
||||||
|
@ -124,8 +124,8 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract
|
||||||
*/
|
*/
|
||||||
protected function getDenormalizedData($calendarData)
|
protected function getDenormalizedData($calendarData)
|
||||||
{
|
{
|
||||||
/** @var Sabre_VObject_Component_VEvent $vObject */
|
/** @var Sabre\VObject\Component\VEvent $vObject */
|
||||||
$vObject = Sabre_VObject_Reader::read($calendarData);
|
$vObject = Sabre\VObject\Reader::read($calendarData);
|
||||||
$componentType = null;
|
$componentType = null;
|
||||||
$component = null;
|
$component = null;
|
||||||
$firstOccurence = null;
|
$firstOccurence = null;
|
||||||
|
@ -141,15 +141,15 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract
|
||||||
throw new Sabre_DAV_Exception_BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
|
throw new Sabre_DAV_Exception_BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
|
||||||
}
|
}
|
||||||
if ($componentType === 'VEVENT') {
|
if ($componentType === 'VEVENT') {
|
||||||
/** @var Sabre_VObject_Component_VEvent $component */
|
/** @var Sabre\VObject\Component\VEvent $component */
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtstart */
|
/** @var Sabre\VObject\Property\DateTime $dtstart */
|
||||||
$dtstart = $component->__get("DTSTART");
|
$dtstart = $component->__get("DTSTART");
|
||||||
$firstOccurence = $dtstart->getDateTime()->getTimeStamp();
|
$firstOccurence = $dtstart->getDateTime()->getTimeStamp();
|
||||||
// Finding the last occurence is a bit harder
|
// Finding the last occurence is a bit harder
|
||||||
if (!$component->__get("RRULE")) {
|
if (!$component->__get("RRULE")) {
|
||||||
$lastOccurence = self::getDtEndTimeStamp($component);
|
$lastOccurence = self::getDtEndTimeStamp($component);
|
||||||
} else {
|
} else {
|
||||||
$it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
|
$it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID"));
|
||||||
$maxDate = new DateTime(CALDAV_MAX_YEAR . "-01-01");
|
$maxDate = new DateTime(CALDAV_MAX_YEAR . "-01-01");
|
||||||
if ($it->isInfinite()) {
|
if ($it->isInfinite()) {
|
||||||
$lastOccurence = $maxDate->getTimeStamp();
|
$lastOccurence = $maxDate->getTimeStamp();
|
||||||
|
|
|
@ -16,65 +16,147 @@ abstract class Sabre_CardDAV_Backend_Virtual extends Sabre_CardDAV_Backend_Commo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* @param int $uid
|
* @param int $addressbookId
|
||||||
* @param int $namespace
|
|
||||||
*/
|
*/
|
||||||
static public function invalidateCache($uid = 0, $namespace = 0) {
|
static public function invalidateCache($addressbookId) {
|
||||||
q("DELETE FROM %s%sadd_virtual_object_sync WHERE `uid` = %d AND `namespace` = %d",
|
q("UPDATE %s%saddressbooks SET `needs_rebuild` = 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId));
|
||||||
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($uid), IntVal($namespace));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param int $addressbookId
|
* @param int $addressbookId
|
||||||
|
* @param bool $force
|
||||||
*/
|
*/
|
||||||
static abstract protected function createCache_internal($addressbookId);
|
static abstract protected function createCache_internal($addressbookId, $force = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $addressbookId
|
||||||
|
* @param null|array $addressbook
|
||||||
|
* @param bool $force
|
||||||
|
*/
|
||||||
|
public function createCache($addressbookId, $addressbook = null, $force = false) {
|
||||||
|
$addressbookId = IntVal($addressbookId);
|
||||||
|
|
||||||
|
if (!$addressbook) {
|
||||||
|
$add = q("SELECT `needs_rebuild`, `uri` FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
$addressbook = $add[0];
|
||||||
|
}
|
||||||
|
if ($addressbook["needs_rebuild"] == 1 || $force) {
|
||||||
|
static::createCache_internal($addressbookId, $force);
|
||||||
|
q("UPDATE %s%saddressbooks SET `needs_rebuild` = 0, `ctag` = `ctag` + 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @static
|
* @static
|
||||||
|
* @abstract
|
||||||
* @param int $addressbookId
|
* @param int $addressbookId
|
||||||
|
* @param int $contactId
|
||||||
|
* @param bool $force
|
||||||
*/
|
*/
|
||||||
static protected function createCache($addressbookId) {
|
static abstract protected function createCardCache($addressbookId, $contactId, $force = false);
|
||||||
$addressbookId = IntVal($addressbookId);
|
|
||||||
q("DELETE FROM %s%saddressbookobjects WHERE `addressbook_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
|
||||||
static::createCache_internal($addressbookId);
|
|
||||||
q("REPLACE INTO %s%sadd_virtual_object_sync (`addressbook_id`, `date`) VALUES (%d, NOW())", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $addressbookId
|
* @param int $addressbookId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCards($addressbookId)
|
public function getCards($addressbookId)
|
||||||
{
|
{
|
||||||
$addressbookId = IntVal($addressbookId);
|
$addressbookId = IntVal($addressbookId);
|
||||||
$r = q("SELECT COUNT(*) n FROM %s%sadd_virtual_object_sync WHERE `addressbook_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
$add = q("SELECT * FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
if ($add[0]["needs_rebuild"]) {
|
||||||
|
static::createCache_internal($addressbookId);
|
||||||
|
q("UPDATE %s%saddressbooks SET `needs_rebuild` = 0, `ctag` = `ctag` + 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
$add[0]["needs_rebuild"] = 0;
|
||||||
|
$add[0]["ctag"]++;
|
||||||
|
}
|
||||||
|
|
||||||
if ($r[0]["n"] == 0) static::createCache($addressbookId);
|
$ret = array();
|
||||||
|
$x = q("SELECT * FROM %s%saddressbookobjects WHERE `addressbook_id` = %d AND `manually_deleted` = 0", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
foreach ($x as $y) $ret[] = self::getCard($addressbookId, $add[0]["uri"], $add[0], $y);
|
||||||
|
|
||||||
return q("SELECT * FROM %s%saddressbookobjects WHERE `addressbook_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the x-prop_name value. Replaces the prop_name value IF the old value is the same as the old value of x-prop_name (meaning: the user has not manually changed it)
|
||||||
|
*
|
||||||
|
* @param Sabre\VObject\Component $component
|
||||||
|
* @param string $prop_name
|
||||||
|
* @param string $prop_value
|
||||||
|
* @param array $parameters
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
static public function card_set_automatic_value(&$component, $prop_name, $prop_value, $parameters = array()) {
|
||||||
|
$automatic = $component->select("X-" . $prop_name);
|
||||||
|
$curr = $component->select($prop_name);
|
||||||
|
|
||||||
|
if (count($automatic) == 0) {
|
||||||
|
$prop = new Sabre\VObject\Property('X-' . $prop_name, $prop_value);
|
||||||
|
foreach ($parameters as $key=>$val) $prop->add($key, $val);
|
||||||
|
$component->children[] = $prop;
|
||||||
|
|
||||||
|
if (count($curr) == 0) {
|
||||||
|
$prop = new Sabre\VObject\Property($prop_name, $prop_value);
|
||||||
|
foreach ($parameters as $key=>$val) $prop->add($key, $val);
|
||||||
|
$component->children[] = $prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else foreach ($automatic as $auto_prop) {
|
||||||
|
/** @var Sabre\VObject\Property $auto_prop */
|
||||||
|
/** @var Sabre\VObject\Property $actual_prop */
|
||||||
|
foreach ($curr as $actual_prop) {
|
||||||
|
if ($auto_prop->value == $actual_prop->value) $actual_prop->setValue($prop_value);
|
||||||
|
}
|
||||||
|
$auto_prop->setValue($prop_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the x-prop_name value. Deletes the prop_name value IF the old value is the same as the old value of x-prop_name (meaning: the user has not manually changed it)
|
||||||
|
*
|
||||||
|
* @param Sabre\VObject\Component $component
|
||||||
|
* @param string $prop_name
|
||||||
|
* @param array $parameters
|
||||||
|
*/
|
||||||
|
static public function card_del_automatic_value(&$component, $prop_name, $parameters = array()) {
|
||||||
|
// @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $addressbookId
|
* @param int $addressbookId
|
||||||
* @param string $objectUri
|
* @param string $objectUri
|
||||||
|
* @param array $book
|
||||||
|
* @param array $obj
|
||||||
* @throws Sabre_DAV_Exception_NotFound
|
* @throws Sabre_DAV_Exception_NotFound
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCard($addressbookId, $objectUri)
|
public function getCard($addressbookId, $objectUri, $book = null, $obj = null)
|
||||||
{
|
{
|
||||||
$addressbookId = IntVal($addressbookId);
|
$addressbookId = IntVal($addressbookId);
|
||||||
$r = q("SELECT COUNT(*) n FROM %s%sadd_virtual_object_sync WHERE `addressbook_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressbookId));
|
|
||||||
|
|
||||||
if ($r[0]["n"] == 0) static::createCache($addressbookId);
|
if ($book == null) {
|
||||||
|
$add = q("SELECT `needs_rebuild`, `uri` FROM %s%saddressbooks WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
$book = $add[0];
|
||||||
|
}
|
||||||
|
if ($book["needs_rebuild"] == 1) {
|
||||||
|
static::createCache_internal($addressbookId);
|
||||||
|
q("UPDATE %s%saddressbooks SET `needs_rebuild` = 0, `ctag` = `ctag` + 1 WHERE `id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $addressbookId);
|
||||||
|
$add[0]["needs_rebuild"] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM %s%saddressbookobjects WHERE `uri` = '%s' AND `addressbook_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($objectUri), IntVal($addressbookId));
|
if ($obj == null) {
|
||||||
|
$r = q("SELECT * FROM %s%saddressbookobjects WHERE `uri` = '%s' AND `addressbook_id` = %d AND `manually_deleted` = 0",
|
||||||
|
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($objectUri), IntVal($addressbookId));
|
||||||
if (count($r) == 0) throw new Sabre_DAV_Exception_NotFound();
|
if (count($r) == 0) throw new Sabre_DAV_Exception_NotFound();
|
||||||
|
|
||||||
$obj = $r[0];
|
$obj = $r[0];
|
||||||
|
if ($obj["needs_rebuild"] == 1) $obj = static::createCardCache($addressbookId, $obj["contact"]);
|
||||||
|
}
|
||||||
|
|
||||||
$ret = array(
|
$ret = array(
|
||||||
"id" => IntVal($obj["uri"]),
|
"id" => IntVal($obj["uri"]),
|
||||||
"carddata" => $obj["carddata"],
|
"carddata" => $obj["carddata"],
|
||||||
|
@ -125,26 +207,62 @@ abstract class Sabre_CardDAV_Backend_Virtual extends Sabre_CardDAV_Backend_Commo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $addressbookId
|
* Updates a card.
|
||||||
* @param string $objectUri
|
*
|
||||||
|
* The addressbook id will be passed as the first argument. This is the
|
||||||
|
* same id as it is returned from the getAddressbooksForUser method.
|
||||||
|
*
|
||||||
|
* The cardUri is a base uri, and doesn't include the full path. The
|
||||||
|
* cardData argument is the vcard body, and is passed as a string.
|
||||||
|
*
|
||||||
|
* It is possible to return an ETag from this method. This ETag should
|
||||||
|
* match that of the updated resource, and must be enclosed with double
|
||||||
|
* quotes (that is: the string itself must contain the actual quotes).
|
||||||
|
*
|
||||||
|
* You should only return the ETag if you store the carddata as-is. If a
|
||||||
|
* subsequent GET request on the same card does not have the same body,
|
||||||
|
* byte-by-byte and you did return an ETag here, clients tend to get
|
||||||
|
* confused.
|
||||||
|
*
|
||||||
|
* If you don't return an ETag, you can just return null.
|
||||||
|
*
|
||||||
|
* @param string $addressBookId
|
||||||
|
* @param string $cardUri
|
||||||
* @param string $cardData
|
* @param string $cardData
|
||||||
* @throws Sabre_DAV_Exception_Forbidden
|
* @throws Sabre_DAV_Exception_Forbidden
|
||||||
* @return null|string|void
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
function updateCard($addressbookId, $objectUri, $cardData)
|
public function updateCard($addressBookId, $cardUri, $cardData)
|
||||||
{
|
{
|
||||||
throw new Sabre_DAV_Exception_Forbidden();
|
echo "Die!"; die(); // @TODO
|
||||||
|
$x = explode("-", $addressBookId);
|
||||||
|
|
||||||
|
$etag = md5($cardData);
|
||||||
|
q("UPDATE %s%scards SET carddata = '%s', lastmodified = %d, etag = '%s', size = %d, manually_edited = 1 WHERE uri = '%s' AND namespace = %d AND namespace_id =%d",
|
||||||
|
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), time(), $etag, strlen($cardData), dbesc($cardUri), IntVal($x[10]), IntVal($x[1])
|
||||||
|
);
|
||||||
|
q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1]));
|
||||||
|
|
||||||
|
return '"' . $etag . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $addressbookId
|
* Deletes a card
|
||||||
* @param string $objectUri
|
*
|
||||||
|
* @param string $addressBookId
|
||||||
|
* @param string $cardUri
|
||||||
* @throws Sabre_DAV_Exception_Forbidden
|
* @throws Sabre_DAV_Exception_Forbidden
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function deleteCard($addressbookId, $objectUri)
|
public function deleteCard($addressBookId, $cardUri)
|
||||||
{
|
{
|
||||||
throw new Sabre_DAV_Exception_Forbidden();
|
q("UPDATE %s%scards SET `manually_deleted` = 1 WHERE `addressbook_id` = %d AND `uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId), dbesc($cardUri));
|
||||||
|
q('UPDATE %s%saddressbooks SET ctag = ctag + 1 WHERE `id` = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($addressBookId));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,12 +97,12 @@ function wdcal_print_feed($base_path = "")
|
||||||
$component = dav_get_eventComponent($item);
|
$component = dav_get_eventComponent($item);
|
||||||
$component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("CalendarTitle")));
|
$component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("CalendarTitle")));
|
||||||
|
|
||||||
if (isset($_REQUEST["allday"])) $type = Sabre_VObject_Property_DateTime::DATE;
|
if (isset($_REQUEST["allday"])) $type = Sabre\VObject\Property\DateTime::DATE;
|
||||||
else $type = Sabre_VObject_Property_DateTime::LOCALTZ;
|
else $type = Sabre\VObject\Property\DateTime::LOCALTZ;
|
||||||
|
|
||||||
$datetime_start = new Sabre_VObject_Property_DateTime("DTSTART");
|
$datetime_start = new Sabre\VObject\Property\DateTime("DTSTART");
|
||||||
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type);
|
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type);
|
||||||
$datetime_end = new Sabre_VObject_Property_DateTime("DTEND");
|
$datetime_end = new Sabre\VObject\Property\DateTime("DTEND");
|
||||||
$datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type);
|
$datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type);
|
||||||
|
|
||||||
$component->add($datetime_start);
|
$component->add($datetime_start);
|
||||||
|
@ -179,12 +179,12 @@ function wdcal_print_feed($base_path = "")
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST["allday"])) $type = Sabre_VObject_Property_DateTime::DATE;
|
if (isset($_REQUEST["allday"])) $type = Sabre\VObject\Property\DateTime::DATE;
|
||||||
else $type = Sabre_VObject_Property_DateTime::LOCALTZ;
|
else $type = Sabre\VObject\Property\DateTime::LOCALTZ;
|
||||||
|
|
||||||
$datetime_start = new Sabre_VObject_Property_DateTime("DTSTART");
|
$datetime_start = new Sabre\VObject\Property\DateTime("DTSTART");
|
||||||
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type);
|
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type);
|
||||||
$datetime_end = new Sabre_VObject_Property_DateTime("DTEND");
|
$datetime_end = new Sabre\VObject\Property\DateTime("DTEND");
|
||||||
$datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type);
|
$datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type);
|
||||||
|
|
||||||
$component->__unset("DTSTART");
|
$component->__unset("DTSTART");
|
||||||
|
|
|
@ -29,7 +29,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $calendar_id, $uri)
|
||||||
|
|
||||||
if ($component == null) return t('Could not open component for editing');
|
if ($component == null) return t('Could not open component for editing');
|
||||||
|
|
||||||
/** @var Sabre_VObject_Property_DateTime $dtstart */
|
/** @var Sabre\VObject\Property\DateTime $dtstart */
|
||||||
$dtstart = $component->__get("DTSTART");
|
$dtstart = $component->__get("DTSTART");
|
||||||
$event = array(
|
$event = array(
|
||||||
"id" => IntVal($uri),
|
"id" => IntVal($uri),
|
||||||
|
@ -44,7 +44,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $calendar_id, $uri)
|
||||||
|
|
||||||
$exdates = $component->select("EXDATE");
|
$exdates = $component->select("EXDATE");
|
||||||
$recurrentce_exdates = array();
|
$recurrentce_exdates = array();
|
||||||
/** @var Sabre_VObject_Property_MultiDateTime $x */
|
/** @var Sabre\VObject\Property\MultiDateTime $x */
|
||||||
foreach ($exdates as $x) {
|
foreach ($exdates as $x) {
|
||||||
/** @var DateTime $y */
|
/** @var DateTime $y */
|
||||||
$z = $x->getDateTimes();
|
$z = $x->getDateTimes();
|
||||||
|
@ -511,15 +511,15 @@ 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");
|
||||||
$type = Sabre_VObject_Property_DateTime::DATE;
|
$type = Sabre\VObject\Property\DateTime::DATE;
|
||||||
} else {
|
} else {
|
||||||
$ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
|
$ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
|
||||||
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
|
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
|
||||||
$type = Sabre_VObject_Property_DateTime::LOCALTZ;
|
$type = Sabre\VObject\Property\DateTime::LOCALTZ;
|
||||||
}
|
}
|
||||||
$datetime_start = new Sabre_VObject_Property_DateTime("DTSTART");
|
$datetime_start = new Sabre\VObject\Property\DateTime("DTSTART");
|
||||||
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type);
|
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type);
|
||||||
$datetime_end = new Sabre_VObject_Property_DateTime("DTEND");
|
$datetime_end = new Sabre\VObject\Property\DateTime("DTEND");
|
||||||
$datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type);
|
$datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type);
|
||||||
|
|
||||||
$component->__unset("DTSTART");
|
$component->__unset("DTSTART");
|
||||||
|
@ -539,7 +539,7 @@ function wdcal_set_component_date(&$component, &$localization)
|
||||||
function wdcal_set_component_recurrence_special(&$component, $str) {
|
function wdcal_set_component_recurrence_special(&$component, $str) {
|
||||||
$ret = "";
|
$ret = "";
|
||||||
|
|
||||||
/** @var Sabre_VObject_Property_DateTime $start */
|
/** @var Sabre\VObject\Property\DateTime $start */
|
||||||
$start = $component->__get("DTSTART");
|
$start = $component->__get("DTSTART");
|
||||||
$dayMap = array(
|
$dayMap = array(
|
||||||
0 => 'SU',
|
0 => 'SU',
|
||||||
|
@ -595,8 +595,8 @@ function wdcal_set_component_recurrence(&$component, &$localization)
|
||||||
case "date":
|
case "date":
|
||||||
$date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]);
|
$date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]);
|
||||||
$part_until = ";UNTIL=" . date("Ymd", $date);
|
$part_until = ";UNTIL=" . date("Ymd", $date);
|
||||||
$datetime_until = new Sabre_VObject_Property_DateTime("UNTIL");
|
$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);
|
$datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre\VObject\Property\DateTime::DATE);
|
||||||
break;
|
break;
|
||||||
case "count":
|
case "count":
|
||||||
$part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]);
|
$part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]);
|
||||||
|
@ -626,7 +626,7 @@ function wdcal_set_component_recurrence(&$component, &$localization)
|
||||||
$part_freq .= wdcal_set_component_recurrence_special($component, $_REQUEST["rec_monthly_day"]);
|
$part_freq .= wdcal_set_component_recurrence_special($component, $_REQUEST["rec_monthly_day"]);
|
||||||
break;
|
break;
|
||||||
case "yearly":
|
case "yearly":
|
||||||
/** @var Sabre_VObject_Property_DateTime $start */
|
/** @var Sabre\VObject\Property\DateTime $start */
|
||||||
$start = $component->__get("DTSTART");
|
$start = $component->__get("DTSTART");
|
||||||
$part_freq = "FREQ=YEARLY";
|
$part_freq = "FREQ=YEARLY";
|
||||||
$part_freq .= ";BYMONTH=" . $start->getDateTime()->format("n");
|
$part_freq .= ";BYMONTH=" . $start->getDateTime()->format("n");
|
||||||
|
@ -645,20 +645,20 @@ function wdcal_set_component_recurrence(&$component, &$localization)
|
||||||
foreach ($_REQUEST["rec_exceptions"] as $except) {
|
foreach ($_REQUEST["rec_exceptions"] as $except) {
|
||||||
$arr[] = new DateTime(date("Y-m-d H:i:s", $except));
|
$arr[] = new DateTime(date("Y-m-d H:i:s", $except));
|
||||||
}
|
}
|
||||||
/** @var Sabre_VObject_Property_MultiDateTime $prop */
|
/** @var Sabre\VObject\Property\MultiDateTime $prop */
|
||||||
$prop = Sabre_VObject_Property::create("EXDATE");
|
$prop = Sabre\VObject\Property::create("EXDATE");
|
||||||
$prop->setDateTimes($arr);
|
$prop->setDateTimes($arr);
|
||||||
$component->add($prop);
|
$component->add($prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rrule = $part_freq . $part_until;
|
$rrule = $part_freq . $part_until;
|
||||||
$component->add(new Sabre_VObject_Property("RRULE", $rrule));
|
$component->add(new Sabre\VObject\Property("RRULE", $rrule));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Sabre_VObject_Component_VEvent $component
|
* @param Sabre\VObject\Component\VEvent $component
|
||||||
* @param wdcal_local $localization
|
* @param wdcal_local $localization
|
||||||
* @param string $summary
|
* @param string $summary
|
||||||
* @param int $dtstart
|
* @param int $dtstart
|
||||||
|
@ -671,12 +671,12 @@ function wdcal_set_component_alerts(&$component, &$localization, $summary, $dtst
|
||||||
$component->__unset("VALARM");
|
$component->__unset("VALARM");
|
||||||
|
|
||||||
foreach ($prev_alarms as $al) {
|
foreach ($prev_alarms as $al) {
|
||||||
/** @var Sabre_VObject_Component_VAlarm $al */
|
/** @var Sabre\VObject\Component\VAlarm $al */
|
||||||
// @TODO Parse notifications that have been there before; e.g. from Lightning
|
// @TODO Parse notifications that have been there before; e.g. from Lightning
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_keys($_REQUEST["noti_type"]) as $key) if (is_numeric($key) || ($key == "new" && $_REQUEST["new_alarm"] == 1)) {
|
foreach (array_keys($_REQUEST["noti_type"]) as $key) if (is_numeric($key) || ($key == "new" && $_REQUEST["new_alarm"] == 1)) {
|
||||||
$alarm = new Sabre_VObject_Component_VAlarm("VALARM");
|
$alarm = new Sabre\VObject\Component\VAlarm("VALARM");
|
||||||
|
|
||||||
switch ($_REQUEST["noti_type"][$key]) {
|
switch ($_REQUEST["noti_type"][$key]) {
|
||||||
case "email":
|
case "email":
|
||||||
|
@ -686,15 +686,15 @@ function wdcal_set_component_alerts(&$component, &$localization, $summary, $dtst
|
||||||
$localization->date_timestamp2local($dtstart), $summary,
|
$localization->date_timestamp2local($dtstart), $summary,
|
||||||
), t("The event #name# will start at #date"));
|
), t("The event #name# will start at #date"));
|
||||||
|
|
||||||
$alarm->add(new Sabre_VObject_Property("ACTION", "EMAIL"));
|
$alarm->add(new Sabre\VObject\Property("ACTION", "EMAIL"));
|
||||||
$alarm->add(new Sabre_VObject_Property("SUMMARY", $summary));
|
$alarm->add(new Sabre\VObject\Property("SUMMARY", $summary));
|
||||||
$alarm->add(new Sabre_VObject_Property("DESCRIPTION", $mailtext));
|
$alarm->add(new Sabre\VObject\Property("DESCRIPTION", $mailtext));
|
||||||
$alarm->add(new Sabre_VObject_Property("ATTENDEE", "MAILTO:" . $a->user["email"]));
|
$alarm->add(new Sabre\VObject\Property("ATTENDEE", "MAILTO:" . $a->user["email"]));
|
||||||
break;
|
break;
|
||||||
case "display":
|
case "display":
|
||||||
$alarm->add(new Sabre_VObject_Property("ACTION", "DISPLAY"));
|
$alarm->add(new Sabre\VObject\Property("ACTION", "DISPLAY"));
|
||||||
$text = str_replace("#name#", $summary, t("#name# is about to begin."));
|
$text = str_replace("#name#", $summary, t("#name# is about to begin."));
|
||||||
$alarm->add(new Sabre_VObject_Property("DESCRIPTION", $text));
|
$alarm->add(new Sabre\VObject\Property("DESCRIPTION", $text));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
|
@ -706,7 +706,7 @@ function wdcal_set_component_alerts(&$component, &$localization, $summary, $dtst
|
||||||
$trigger_val .= "-P";
|
$trigger_val .= "-P";
|
||||||
if (in_array($_REQUEST["noti_unit"][$key], array("H", "M", "S"))) $trigger_val .= "T";
|
if (in_array($_REQUEST["noti_unit"][$key], array("H", "M", "S"))) $trigger_val .= "T";
|
||||||
$trigger_val .= IntVal($_REQUEST["noti_value"][$key]) . $_REQUEST["noti_unit"][$key];
|
$trigger_val .= IntVal($_REQUEST["noti_value"][$key]) . $_REQUEST["noti_unit"][$key];
|
||||||
$alarm->add(new Sabre_VObject_Property($trigger_name, $trigger_val));
|
$alarm->add(new Sabre\VObject\Property($trigger_name, $trigger_val));
|
||||||
|
|
||||||
$component->add($alarm);
|
$component->add($alarm);
|
||||||
}
|
}
|
||||||
|
@ -785,12 +785,12 @@ function wdcal_getEditPage_exception_selector()
|
||||||
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);
|
||||||
wdcal_set_component_recurrence($component, $localization);
|
wdcal_set_component_recurrence($component, $localization);
|
||||||
|
|
||||||
|
|
||||||
$it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
|
$it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID"));
|
||||||
$max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR + 1);
|
$max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR + 1);
|
||||||
$last_start = 0;
|
$last_start = 0;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ function dav_get_update_statements($from_version)
|
||||||
`namespace_id` int(11) unsigned NOT NULL,
|
`namespace_id` int(11) unsigned NOT NULL,
|
||||||
`displayname` varchar(200) NOT NULL,
|
`displayname` varchar(200) NOT NULL,
|
||||||
`description` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
`description` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
|
`needs_rebuild` TINYINT NOT NULL DEFAULT '1',
|
||||||
`uri` varchar(50) NOT NULL,
|
`uri` varchar(50) NOT NULL,
|
||||||
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
|
@ -194,6 +195,7 @@ function dav_get_create_statements($except = array())
|
||||||
`namespace_id` int(11) unsigned NOT NULL,
|
`namespace_id` int(11) unsigned NOT NULL,
|
||||||
`displayname` varchar(200) NOT NULL,
|
`displayname` varchar(200) NOT NULL,
|
||||||
`description` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
`description` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
|
`needs_rebuild` TINYINT NOT NULL DEFAULT '1',
|
||||||
`uri` varchar(50) NOT NULL,
|
`uri` varchar(50) NOT NULL,
|
||||||
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
`ctag` int(11) unsigned NOT NULL DEFAULT '1',
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
|
|
Loading…
Reference in a new issue