define("CALDAV_SQL_DB", "");
define("CALDAV_SQL_PREFIX", "dav_");
define("CALDAV_URL_PREFIX", $path . "dav/");
+define("DAV_APPNAME", "Friendica");
define("CALDAV_NAMESPACE_PRIVATE", 1);
define("CALDAV_FRIENDICA_CONTACTS", "friendica-contacts");
$GLOBALS["CALDAV_PRIVATE_SYSTEM_CALENDARS"] = array(CALDAV_FRIENDICA_MINE, CALDAV_FRIENDICA_CONTACTS);
+$GLOBALS["CALDAV_PRIVATE_SYSTEM_BACKENDS"] = array("Sabre_CalDAV_Backend_Friendica");
define("CARDDAV_NAMESPACE_COMMUNITYCONTACTS", 1);
define("CARDDAV_NAMESPACE_PHONECONTACTS", 2);
+$GLOBALS["CARDDAV_PRIVATE_SYSTEM_BACKENDS"] = array("Sabre_CardDAV_Backend_FriendicaCommunity");
define("CALDAV_MAX_YEAR", date("Y") + 5);
return null;
}
+/**
+ * @return string
+ */
+function dav_compat_get_hostname() {
+ $a = get_app();
+ return $a->get_hostname();
+}
+
/**
* @param int $namespace
* @param int $namespace_id
*/
function vcard_source_compile($vcardsource)
{
- $str = "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Friendica//DAV-Plugin//EN\r\n";
+ $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";
*/
function dav_createRootCalendarNode()
{
- $caldavBackend_std = Sabre_CalDAV_Backend_Private::getInstance();
- $caldavBackend_community = Sabre_CalDAV_Backend_Friendica::getInstance();
-
- return new Sabre_CalDAV_AnimexxCalendarRootNode(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), array(
- $caldavBackend_std,
- $caldavBackend_community,
- ));
+ $backends = array(Sabre_CalDAV_Backend_Private::getInstance());
+ foreach ($GLOBALS["CALDAV_PRIVATE_SYSTEM_BACKENDS"] as $backendclass) $backends[] = $backendclass::getInstance();
+ return new Sabre_CalDAV_AnimexxCalendarRootNode(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), $backends);
}
/**
*/
function dav_createRootContactsNode()
{
- $carddavBackend_std = Sabre_CardDAV_Backend_Std::getInstance();
- $carddavBackend_community = Sabre_CardDAV_Backend_FriendicaCommunity::getInstance();
+ $backends = array(Sabre_CardDAV_Backend_Std::getInstance());
+ foreach ($GLOBALS["CARDDAV_PRIVATE_SYSTEM_BACKENDS"] as $backendclass) $backends[] = $backendclass::getInstance();
- return new Sabre_CardDAV_AddressBookRootFriendica(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), array(
- $carddavBackend_std,
- $carddavBackend_community,
- ));
+ return new Sabre_CardDAV_AddressBookRootFriendica(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), $backends);
}
$authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), 'SabreDAV');
$server->addPlugin($authPlugin);
- $aclPlugin = new Sabre_DAVACL_Plugin_Friendica();
- $aclPlugin->defaultUsernamePath = "principals/users";
- $server->addPlugin($aclPlugin);
-
if ($needs_caldav) {
$caldavPlugin = new Sabre_CalDAV_Plugin();
$server->addPlugin($caldavPlugin);
{
$a = get_app();
if ($uid == "") $uid = uniqid();
- return Sabre_VObject_Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Friendica//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . $a->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");
}