2015-10-21 16:06:48 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\DAV;
|
|
|
|
|
|
|
|
use OCA\DAV\Connector\Sabre\Principal;
|
|
|
|
use Sabre\CalDAV\Principal\Collection;
|
|
|
|
use Sabre\DAV\SimpleCollection;
|
|
|
|
|
|
|
|
class RootCollection extends SimpleCollection {
|
|
|
|
|
|
|
|
public function __construct() {
|
2015-10-26 19:56:33 +03:00
|
|
|
$config = \OC::$server->getConfig();
|
2015-10-21 16:06:48 +03:00
|
|
|
$principalBackend = new Principal(
|
2015-10-26 19:56:33 +03:00
|
|
|
$config,
|
2015-10-21 16:06:48 +03:00
|
|
|
\OC::$server->getUserManager()
|
|
|
|
);
|
2015-10-26 19:56:33 +03:00
|
|
|
// as soon as debug mode is enabled we allow listing of principals
|
|
|
|
$disableListing = !$config->getSystemValue('debug', false);
|
|
|
|
|
|
|
|
// setup the first level of the dav tree
|
2015-10-21 16:06:48 +03:00
|
|
|
$principalCollection = new Collection($principalBackend);
|
2015-10-26 19:56:33 +03:00
|
|
|
$principalCollection->disableListing = $disableListing;
|
2015-10-21 16:06:48 +03:00
|
|
|
$filesCollection = new Files\RootCollection($principalBackend);
|
2015-10-26 19:56:33 +03:00
|
|
|
$filesCollection->disableListing = $disableListing;
|
2015-10-21 16:06:48 +03:00
|
|
|
|
|
|
|
$children = [
|
|
|
|
$principalCollection,
|
|
|
|
$filesCollection,
|
|
|
|
];
|
|
|
|
|
|
|
|
parent::__construct('root', $children);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|