aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/examples/addressbookserver.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
committerfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
commitb35122f7a6ad42756c35bb60ba1f06c3dcd45c77 (patch)
treeccdf373ce6475d264778523259cc32899b732fe7 /vendor/sabre/dav/examples/addressbookserver.php
parente3504df514d306cfe6b83e44a11f550664564af4 (diff)
downloadvolse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.gz
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.bz2
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.zip
add sabre (1.8.x) via composer in the !@#$ place it wants to be
Diffstat (limited to 'vendor/sabre/dav/examples/addressbookserver.php')
-rw-r--r--vendor/sabre/dav/examples/addressbookserver.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/vendor/sabre/dav/examples/addressbookserver.php b/vendor/sabre/dav/examples/addressbookserver.php
new file mode 100644
index 000000000..b8986bc41
--- /dev/null
+++ b/vendor/sabre/dav/examples/addressbookserver.php
@@ -0,0 +1,56 @@
+<?php
+
+/*
+
+Addressbook/CardDAV server example
+
+This server features CardDAV support
+
+*/
+
+// settings
+date_default_timezone_set('Canada/Eastern');
+
+// Make sure this setting is turned on and reflect the root url for your WebDAV server.
+// This can be for example the root / or a complete path to your server script
+$baseUri = '/';
+
+/* Database */
+$pdo = new PDO('sqlite:data/db.sqlite');
+$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
+
+//Mapping PHP errors to exceptions
+function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+}
+set_error_handler("exception_error_handler");
+
+// Autoloader
+require_once 'vendor/autoload.php';
+
+// Backends
+$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
+$principalBackend = new Sabre\DAVACL\PrincipalBackend\PDO($pdo);
+$carddavBackend = new Sabre\CardDAV\Backend\PDO($pdo);
+//$caldavBackend = new Sabre\CalDAV\Backend\PDO($pdo);
+
+// Setting up the directory tree //
+$nodes = array(
+ new Sabre\DAVACL\PrincipalCollection($principalBackend),
+// new Sabre\CalDAV\CalendarRootNode($authBackend, $caldavBackend),
+ new Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend),
+);
+
+// The object tree needs in turn to be passed to the server class
+$server = new Sabre\DAV\Server($nodes);
+$server->setBaseUri($baseUri);
+
+// Plugins
+$server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV'));
+$server->addPlugin(new Sabre\DAV\Browser\Plugin());
+//$server->addPlugin(new Sabre\CalDAV\Plugin());
+$server->addPlugin(new Sabre\CardDAV\Plugin());
+$server->addPlugin(new Sabre\DAVACL\Plugin());
+
+// And off we go!
+$server->exec();