Server.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * CalDAV server
  4. *
  5. * This script is a convenience script. It quickly sets up a WebDAV server
  6. * with caldav and ACL support, and it creates the root 'principals' and
  7. * 'calendars' collections.
  8. *
  9. * Note that if you plan to do anything moderately complex, you are advised to
  10. * not subclass this server, but use Sabre_DAV_Server directly instead. This
  11. * class is nothing more than an 'easy setup'.
  12. *
  13. * @package Sabre
  14. * @subpackage CalDAV
  15. * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
  16. * @author Evert Pot (http://www.rooftopsolutions.nl/)
  17. * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  18. */
  19. class Sabre_CalDAV_Server extends Sabre_DAV_Server {
  20. /**
  21. * The authentication realm
  22. *
  23. * Note that if this changes, the hashes in the auth backend must also
  24. * be recalculated.
  25. *
  26. * @var string
  27. */
  28. public $authRealm = 'SabreDAV';
  29. /**
  30. * Sets up the object. A PDO object must be passed to setup all the backends.
  31. *
  32. * @param PDO $pdo
  33. */
  34. public function __construct(PDO $pdo) {
  35. /* Backends */
  36. $authBackend = new Sabre_DAV_Auth_Backend_PDO($pdo);
  37. $calendarBackend = new Sabre_CalDAV_Backend_PDO($pdo);
  38. $principalBackend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
  39. /* Directory structure */
  40. $tree = array(
  41. new Sabre_CalDAV_Principal_Collection($principalBackend),
  42. new Sabre_CalDAV_CalendarRootNode($principalBackend, $calendarBackend),
  43. );
  44. /* Initializing server */
  45. parent::__construct($tree);
  46. /* Server Plugins */
  47. $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend,$this->authRealm);
  48. $this->addPlugin($authPlugin);
  49. $aclPlugin = new Sabre_DAVACL_Plugin();
  50. $this->addPlugin($aclPlugin);
  51. $caldavPlugin = new Sabre_CalDAV_Plugin();
  52. $this->addPlugin($caldavPlugin);
  53. }
  54. }