ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
addressbookserver.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4 
5 Addressbook/CardDAV server example
6 
7 This server features CardDAV support
8 
9 */
10 
11 // settings
12 date_default_timezone_set('Canada/Eastern');
13 
14 // Make sure this setting is turned on and reflect the root url for your WebDAV server.
15 // This can be for example the root / or a complete path to your server script
16 $baseUri = '/';
17 
18 /* Database */
19 $pdo = new PDO('sqlite:data/db.sqlite');
20 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
21 
22 //Mapping PHP errors to exceptions
23 function exception_error_handler($errno, $errstr, $errfile, $errline) {
24  throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
25 }
26 set_error_handler("exception_error_handler");
27 
28 // Autoloader
29 require_once 'vendor/autoload.php';
30 
31 // Backends
35 //$caldavBackend = new Sabre\CalDAV\Backend\PDO($pdo);
36 
37 // Setting up the directory tree //
38 $nodes = [
40 // new Sabre\CalDAV\CalendarRoot($authBackend, $caldavBackend),
42 ];
43 
44 // The object tree needs in turn to be passed to the server class
46 $server->setBaseUri($baseUri);
47 
48 // Plugins
49 $server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend));
50 $server->addPlugin(new Sabre\DAV\Browser\Plugin());
51 //$server->addPlugin(new Sabre\CalDAV\Plugin());
52 $server->addPlugin(new Sabre\CardDAV\Plugin());
53 $server->addPlugin(new Sabre\DAVACL\Plugin());
54 $server->addPlugin(new Sabre\DAV\Sync\Plugin());
55 
56 // And off we go!
57 $server->exec();
$carddavBackend
PDO CardDAV backend.
Definition: PDO.php:17
PDO principal backend.
Definition: PDO.php:20
$authBackend
This is an authentication backend that uses a database to manage passwords.
Definition: PDO.php:12
exception_error_handler($errno, $errstr, $errfile, $errline)
AddressBook rootnode.
$principalBackend