Esempio n. 1
0
/**
 * @param App $a
 */
function dav_init(&$a)
{
    /*
     * Recommended settings:
     * ALTER TABLE `photo` ADD INDEX ( `contact-id` )
     */
    dav_include_files();
    if (false) {
        dbg(true);
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
    }
    wdcal_create_std_calendars();
    if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
        if ($a->argc >= 3 && $a->argv[2] == "feed") {
            wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
            killme();
        } elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
            wdcal_addRequiredHeadersEdit();
        } else {
            wdcal_addRequiredHeaders();
        }
        return;
    }
    if ($a->argc >= 2 && $a->argv[1] == "settings") {
        return;
    }
    $authBackend = new Sabre_DAV_Auth_Backend_Friendica();
    $principalBackend = new Sabre_DAVACL_PrincipalBackend_Friendica($authBackend);
    $caldavBackend_std = new Sabre_CalDAV_Backend_Std();
    $caldavBackend_community = new Sabre_CalDAV_Backend_Friendica();
    $carddavBackend_std = new Sabre_CardDAV_Backend_Std();
    $carddavBackend_community = new Sabre_CardDAV_Backend_FriendicaCommunity();
    if (isset($_SERVER["PHP_AUTH_USER"])) {
        $tree = new Sabre_DAV_SimpleCollection('root', array(new Sabre_DAV_SimpleCollection('principals', array(new Sabre_CalDAV_Principal_Collection($principalBackend, "principals/users"))), new Sabre_CalDAV_AnimexxCalendarRootNode($principalBackend, array($caldavBackend_std, $caldavBackend_community)), new Sabre_CardDAV_AddressBookRootFriendica($principalBackend, array($carddavBackend_std, $carddavBackend_community))));
    } else {
        $tree = new Sabre_DAV_SimpleCollection('root', array());
    }
    // The object tree needs in turn to be passed to the server class
    $server = new Sabre_DAV_Server($tree);
    $url = parse_url($a->get_baseurl());
    $server->setBaseUri(CALDAV_URL_PREFIX);
    $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV');
    $server->addPlugin($authPlugin);
    $aclPlugin = new Sabre_DAVACL_Plugin_Friendica();
    $aclPlugin->defaultUsernamePath = "principals/users";
    $server->addPlugin($aclPlugin);
    $caldavPlugin = new Sabre_CalDAV_Plugin();
    $server->addPlugin($caldavPlugin);
    $carddavPlugin = new Sabre_CardDAV_Plugin();
    $server->addPlugin($carddavPlugin);
    $browser = new Sabre_DAV_Browser_Plugin();
    $server->addPlugin($browser);
    $server->exec();
    killme();
}
Esempio n. 2
0
/**
 * @param App $a
 */
function dav_init(&$a)
{
    /*
     * Recommended settings:
     * ALTER TABLE `photo` ADD INDEX ( `contact-id` )
     */
    ini_set("display_errors", 1);
    error_reporting(E_ALL);
    dav_include_files();
    if (false) {
        dbg(true);
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
    }
    wdcal_create_std_calendars();
    wdcal_create_std_addressbooks();
    wdcal_addRequiredHeaders();
    if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
        if ($a->argc >= 3 && $a->argv[2] == "feed") {
            wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
            killme();
        }
        return;
    }
    if ($a->argc >= 2 && $a->argv[1] == "getExceptionDates") {
        echo wdcal_getEditPage_exception_selector();
        killme();
    }
    if ($a->argc >= 2 && $a->argv[1] == "settings") {
        return;
    }
    if (isset($_REQUEST["test"])) {
        renderAllCalDavEntries();
    }
    $server = dav_create_server();
    $browser = new Sabre_DAV_Browser_Plugin();
    $server->addPlugin($browser);
    $server->exec();
    killme();
}