/**
  * @static
  * @return Sabre_DAV_Auth_Backend_Std
  */
 public static function &getInstance()
 {
     if (is_null(self::$intstance)) {
         self::$intstance = new Sabre_DAV_Auth_Backend_Std();
     }
     return self::$intstance;
 }
 /**
  * @static
  * @return Sabre_DAVACL_IPrincipalBackend
  */
 public static function &getInstance()
 {
     if (is_null(self::$intstance)) {
         $authBackend = Sabre_DAV_Auth_Backend_Std::getInstance();
         self::$intstance = new Sabre_DAVACL_PrincipalBackend_Std($authBackend);
     }
     return self::$intstance;
 }
Exemplo n.º 3
0
/**
 * @param bool $force_authentication
 * @param bool $needs_caldav
 * @param bool $needs_carddav
 * @return Sabre_DAV_Server
 */
function dav_create_server($force_authentication = false, $needs_caldav = true, $needs_carddav = true)
{
    $arr = array(new Sabre_DAV_SimpleCollection('principals', array(new Sabre_CalDAV_Principal_Collection(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), "principals/users"))));
    if ($needs_caldav) {
        $arr[] = dav_createRootCalendarNode();
    }
    if ($needs_carddav) {
        $arr[] = dav_createRootContactsNode();
    }
    $tree = new Sabre_DAV_SimpleCollection('root', $arr);
    // The object tree needs in turn to be passed to the server class
    $server = new Sabre_DAV_Server($tree);
    if (CALDAV_URL_PREFIX != "") {
        $server->setBaseUri(CALDAV_URL_PREFIX);
    }
    $authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), DAV_APPNAME);
    $server->addPlugin($authPlugin);
    if ($needs_caldav) {
        $caldavPlugin = new Sabre_CalDAV_Plugin();
        $server->addPlugin($caldavPlugin);
    }
    if ($needs_carddav) {
        $carddavPlugin = new Sabre_CardDAV_Plugin();
        $server->addPlugin($carddavPlugin);
    }
    if ($GLOBALS["CALDAV_ACL_PLUGIN_CLASS"] != "") {
        $aclPlugin = new $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"]();
        $aclPlugin->defaultUsernamePath = "principals/users";
        $server->addPlugin($aclPlugin);
    } else {
        $aclPlugin = new Sabre_DAVACL_Plugin();
        $aclPlugin->defaultUsernamePath = "principals/users";
        $server->addPlugin($aclPlugin);
    }
    if ($force_authentication) {
        $server->broadcastEvent('beforeMethod', array("GET", "/"));
    }
    // Make it authenticate
    return $server;
}