Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dav/appinfo/v1/caldav.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
\OC::$server->getGroupManager(),
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
Expand Down
1 change: 1 addition & 0 deletions apps/dav/appinfo/v1/carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
\OC::$server->getGroupManager(),
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/Command/CreateCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$this->userManager,
$this->groupManager,
\OC::$server->getShareManager(),
\OC::$server->getUserSession()
\OC::$server->getUserSession(),
\OC::$server->getConfig()
);
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->getLogger();
Expand Down
19 changes: 15 additions & 4 deletions apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace OCA\DAV\Connector\Sabre;

use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
Expand All @@ -54,6 +55,9 @@ class Principal implements BackendInterface {
/** @var IUserSession */
private $userSession;

/** @var IConfig */
private $config;

/** @var string */
private $principalPrefix;

Expand All @@ -65,17 +69,20 @@ class Principal implements BackendInterface {
* @param IGroupManager $groupManager
* @param IShareManager $shareManager
* @param IUserSession $userSession
* @param IConfig $config
* @param string $principalPrefix
*/
public function __construct(IUserManager $userManager,
IGroupManager $groupManager,
IShareManager $shareManager,
IUserSession $userSession,
IConfig $config,
$principalPrefix = 'principals/users/') {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->shareManager = $shareManager;
$this->userSession = $userSession;
$this->config = $config;
$this->principalPrefix = trim($principalPrefix, '/');
$this->hasGroups = ($principalPrefix === 'principals/users/');
}
Expand Down Expand Up @@ -205,8 +212,10 @@ function updatePrincipal($path, PropPatch $propPatch) {
protected function searchUserPrincipals(array $searchProperties, $test = 'allof') {
$results = [];

// If sharing is disabled, return the empty array
if (!$this->shareManager->shareApiEnabled()) {
// If sharing is disabled (or FreeBusy was disabled on purpose), return the empty array
$shareAPIEnabled = $this->shareManager->shareApiEnabled();
$disableFreeBusy = $this->config->getAppValue('dav', 'disableFreeBusy', $shareAPIEnabled ? 'no' : 'yes');
if ($disableFreeBusy === 'yes') {
return [];
}

Expand Down Expand Up @@ -289,8 +298,10 @@ function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
* @return string
*/
function findByUri($uri, $principalPrefix) {
// If sharing is disabled, return null as in user not found
if (!$this->shareManager->shareApiEnabled()) {
// If sharing is disabled (or FreeBusy was disabled on purpose), return the empty array
$shareAPIEnabled = $this->shareManager->shareApiEnabled();
$disableFreeBusy = $this->config->getAppValue('dav', 'disableFreeBusy', $shareAPIEnabled ? 'no' : 'yes');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm I'm not sure this is the right place.

Basically not being able to find principals if sharing is totally disabled makes sense. But if free busy is disabled this will kill all sharing.

Can't we extend this class for calendars? overrwite only this function and then do the extra check? (as for now it is only needed for calendars right?).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then fine by me. If we ever want to extend this we have to the magic then!

if ($disableFreeBusy === 'yes') {
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function __construct() {
$userManager,
$groupManager,
$shareManager,
\OC::$server->getUserSession()
\OC::$server->getUserSession(),
$config
);
$groupPrincipalBackend = new GroupPrincipalBackend($groupManager);
// as soon as debug mode is enabled we allow listing of principals
Expand Down
Loading