/** * The CalDAV server is a simple script that just composes a * Sabre_DAV_Server. All we really have to do is check if the setup * is done correctly. */ function testSetup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $pdo = Sabre_CalDAV_TestUtil::getSQLiteDB(); $server = new Sabre_CalDAV_Server($pdo); $authPlugin = $server->getPlugin('auth'); $this->assertTrue($authPlugin instanceof Sabre_DAV_Auth_Plugin); $caldavPlugin = $server->getPlugin('caldav'); $this->assertTrue($caldavPlugin instanceof Sabre_CalDAV_Plugin); $node = $server->tree->getNodeForPath(''); $this->assertTrue($node instanceof Sabre_DAV_SimpleCollection); $this->assertEquals('root', $node->getName()); }
This server features CalDAV and ACL 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 'lib/Sabre/autoload.php'; // The 'caldav server' only needs the pdo object. Note that if you plan to // extend the server in any way, you'll probably don't want to use // Sabre_CalDAV_Server, but plain Sabre_DAV_Server instead. // You'll need to add your own nodes and plugins manually then. $server = new Sabre_CalDAV_Server($pdo); if (isset($baseUri)) { $server->setBaseUri($baseUri); } // Support for html frontend $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); // And off we go! $server->exec();