1<?php 2 3/** 4 * DokuWiki DAVCal PlugIn - DAV Calendar Server PlugIn. 5 * 6 * This is heavily based on SabreDAV and features a DokuWiki connector. 7 */ 8 9 // Initialize DokuWiki 10if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../../'); 11if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); 12require_once(DOKU_INC.'inc/init.php'); 13session_write_close(); //close session 14 15global $conf; 16 17if($conf['allowdebug']) 18 dbglog('---- DAVCAL calendarserver.php init'); 19 20$hlp = null; 21$hlp =& plugin_load('helper', 'davcal'); 22 23if(is_null($hlp)) 24{ 25 if($conf['allowdebug']) 26 dbglog('Error loading helper plugin'); 27 die('Error loading helper plugin'); 28} 29 30$baseUri = DOKU_BASE.'lib/plugins/davcal/'.basename(__FILE__).'/'; 31 32if($hlp->getConfig('disable_sync') === 1) 33{ 34 if($conf['allowdebug']) 35 dbglog('Synchronisation is disabled'); 36 die('Synchronisation is disabled'); 37} 38 39//Mapping PHP errors to exceptions 40function exception_error_handler($errno, $errstr, $errfile, $errline) { 41 if($conf['allowdebug']) 42 dbglog('Exception occured: '.$errstr); 43 throw new ErrorException($errstr, 0, $errno, $errfile, $errline); 44} 45//set_error_handler("exception_error_handler"); 46 47// Files we need 48require_once(DOKU_PLUGIN.'davcal/vendor/autoload.php'); 49require_once(DOKU_PLUGIN.'davcal/authBackendDokuwiki.php'); 50require_once(DOKU_PLUGIN.'davcal/principalBackendDokuwiki.php'); 51require_once(DOKU_PLUGIN.'davcal/calendarBackendDokuwiki.php'); 52 53// Backends - our DokuWiki backends 54$authBackend = new DokuWikiSabreAuthBackend(); 55$calendarBackend = new DokuWikiSabreCalendarBackend($hlp); 56$principalBackend = new DokuWikiSabrePrincipalBackend(); 57 58// Directory structure 59$tree = array( 60 new Sabre\CalDAV\Principal\Collection($principalBackend), 61 new Sabre\CalDAV\CalendarRoot($principalBackend, $calendarBackend), 62); 63 64$server = new Sabre\DAV\Server($tree); 65 66if (isset($baseUri)) 67 $server->setBaseUri($baseUri); 68 69/* Server Plugins */ 70$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend); 71$server->addPlugin($authPlugin); 72 73$aclPlugin = new Sabre\DAVACL\Plugin(); 74$server->addPlugin($aclPlugin); 75 76/* CalDAV support */ 77$caldavPlugin = new Sabre\CalDAV\Plugin(); 78$server->addPlugin($caldavPlugin); 79 80/* Calendar subscription support */ 81//$server->addPlugin( 82// new Sabre\CalDAV\Subscriptions\Plugin() 83//); 84 85/* Calendar scheduling support */ 86//$server->addPlugin( 87// new Sabre\CalDAV\Schedule\Plugin() 88//); 89 90/* WebDAV-Sync plugin */ 91$server->addPlugin(new Sabre\DAV\Sync\Plugin()); 92 93// Support for html frontend 94$browser = new Sabre\DAV\Browser\Plugin(); 95$server->addPlugin($browser); 96 97if($conf['allowdebug']) 98 dbglog('$server->exec()'); 99// And off we go! 100$server->exec(); 101