Skip to content

Commit

Permalink
Merge pull request #23368 from owncloud/use-dav-sabre-plugin-for-browser
Browse files Browse the repository at this point in the history
In debugging mode we enable Sabre's browser plugin since it helps a l…
  • Loading branch information
DeepDiver1975 committed Mar 21, 2016
2 parents c77412b + 520724d commit e983bd7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
13 changes: 9 additions & 4 deletions apps/dav/appinfo/v1/caldav.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

// Backends
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\Connector\LegacyDAVACL;
use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
Expand All @@ -43,12 +44,14 @@
$db = \OC::$server->getDatabaseConnection();
$calDavBackend = new CalDavBackend($db, $principalBackend);

$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);

// Root nodes
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
$principalCollection->disableListing = true; // Disable listing
$principalCollection->disableListing = !$debugging; // Disable listing

$addressBookRoot = new CalendarRoot($principalBackend, $calDavBackend);
$addressBookRoot->disableListing = true; // Disable listing
$addressBookRoot->disableListing = !$debugging; // Disable listing

$nodes = array(
$principalCollection,
Expand All @@ -65,8 +68,10 @@
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud'));
$server->addPlugin(new \Sabre\CalDAV\Plugin());

$acl = new \OCA\DAV\Connector\LegacyDAVACL();
$server->addPlugin($acl);
$server->addPlugin(new LegacyDAVACL());
if ($debugging) {
$server->addPlugin(new Sabre\DAV\Browser\Plugin());
}

$server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
$server->addPlugin(new ExceptionLoggerPlugin('caldav', \OC::$server->getLogger()));
Expand Down
13 changes: 9 additions & 4 deletions apps/dav/appinfo/v1/carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// Backends
use OCA\DAV\CardDAV\AddressBookRoot;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\Connector\LegacyDAVACL;
use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
Expand All @@ -44,12 +45,14 @@
$db = \OC::$server->getDatabaseConnection();
$cardDavBackend = new CardDavBackend($db, $principalBackend);

$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);

// Root nodes
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
$principalCollection->disableListing = true; // Disable listing
$principalCollection->disableListing = !$debugging; // Disable listing

$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend);
$addressBookRoot->disableListing = true; // Disable listing
$addressBookRoot->disableListing = !$debugging; // Disable listing

$nodes = array(
$principalCollection,
Expand All @@ -65,8 +68,10 @@
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud'));
$server->addPlugin(new Plugin());

$acl = new \OCA\DAV\Connector\LegacyDAVACL();
$server->addPlugin($acl);
$server->addPlugin(new LegacyDAVACL());
if ($debugging) {
$server->addPlugin(new Sabre\DAV\Browser\Plugin());
}

$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
$server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->getLogger()));
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/carddav/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ protected function getAddressbookHomeForPrincipal($principal) {
list(, $principalId) = URLUtil::splitPath($principal);
return self::ADDRESSBOOK_ROOT . '/users/' . $principalId;
}
if (strrpos($principal, 'principals/groups', -strlen($principal)) !== false) {
list(, $principalId) = URLUtil::splitPath($principal);
return self::ADDRESSBOOK_ROOT . '/groups/' . $principalId;
}
if (strrpos($principal, 'principals/system', -strlen($principal)) !== false) {
list(, $principalId) = URLUtil::splitPath($principal);
return self::ADDRESSBOOK_ROOT . '/system/' . $principalId;
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/connector/sabre/davaclplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct() {

function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) {
$access = parent::checkPrivileges($uri, $privileges, $recursion, false);
if($access === false) {
if($access === false && $throwExceptions) {
/** @var INode $node */
$node = $this->server->tree->getNodeForPath($uri);

Expand Down
9 changes: 8 additions & 1 deletion apps/dav/lib/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCA\DAV\Connector\Sabre\DavAclPlugin;
use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin;
use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCA\DAV\Files\CustomPropertiesBackend;
use OCP\IRequest;
Expand Down Expand Up @@ -68,7 +69,13 @@ public function __construct(IRequest $request, $baseUri) {
$event = new SabrePluginEvent($this->server);
$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);

$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
// debugging
if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
} else {
$this->server->addPlugin(new DummyGetResponsePlugin());
}

$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
Expand Down

0 comments on commit e983bd7

Please sign in to comment.