summaryrefslogtreecommitdiffstats
path: root/js/dav/test/integration/server/calendarserver.php
diff options
context:
space:
mode:
Diffstat (limited to 'js/dav/test/integration/server/calendarserver.php')
-rw-r--r--js/dav/test/integration/server/calendarserver.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/js/dav/test/integration/server/calendarserver.php b/js/dav/test/integration/server/calendarserver.php
new file mode 100644
index 00000000..8a688af4
--- /dev/null
+++ b/js/dav/test/integration/server/calendarserver.php
@@ -0,0 +1,82 @@
+<?php
+
+/*
+
+CalendarServer example
+
+This server features CalDAV support
+
+*/
+
+// settings
+date_default_timezone_set('Canada/Eastern');
+
+// If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance)
+// You can override the baseUri here.
+// $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");
+
+// Files we need
+require_once 'vendor/autoload.php';
+
+// Backends
+$authBackend = new Sabre\DAV\Auth\Backend\BasicCallBack(function($username, $password) {
+ return true;
+});
+
+$calendarBackend = new Sabre\CalDAV\Backend\PDO($pdo);
+$contactsBackend = new Sabre\CardDAV\Backend\PDO($pdo);
+$principalBackend = new Sabre\DAVACL\PrincipalBackend\PDO($pdo);
+
+// Directory structure
+$tree = [
+ new Sabre\CalDAV\Principal\Collection($principalBackend),
+ new Sabre\CalDAV\CalendarRootNode($principalBackend, $calendarBackend),
+ new Sabre\CardDAV\AddressBookRoot($principalBackend, $contactsBackend),
+];
+
+$server = new Sabre\DAV\Server($tree);
+
+if (isset($baseUri))
+ $server->setBaseUri($baseUri);
+
+/* Server Plugins */
+$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV');
+$server->addPlugin($authPlugin);
+
+$aclPlugin = new Sabre\DAVACL\Plugin();
+$server->addPlugin($aclPlugin);
+
+/* CalDAV support */
+$caldavPlugin = new Sabre\CalDAV\Plugin();
+$server->addPlugin($caldavPlugin);
+
+/* CardDAV support */
+$carddavPlugin = new Sabre\CardDAV\Plugin();
+$server->addPlugin($carddavPlugin);
+
+/* Calendar subscription support */
+$server->addPlugin(
+ new Sabre\CalDAV\Subscriptions\Plugin()
+);
+
+/* WebDAV Sync */
+$server->addPlugin(
+ new Sabre\DAV\Sync\Plugin()
+);
+
+// Support for html frontend
+$browser = new Sabre\DAV\Browser\Plugin();
+$server->addPlugin($browser);
+
+// And off we go!
+$server->exec();