Merge pull request #23689 from owncloud/revert-23629
Revert "Explicitly add the current principal to the acl in case of gr…
This commit is contained in:
commit
8453073fdb
|
@ -27,7 +27,6 @@ use OCA\DAV\CardDAV\CardDavBackend;
|
|||
use OCA\DAV\CardDAV\ContactsManager;
|
||||
use OCA\DAV\CardDAV\SyncJob;
|
||||
use OCA\DAV\CardDAV\SyncService;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use OCA\DAV\HookManager;
|
||||
use OCA\Dav\Migration\AddressBookAdapter;
|
||||
use OCA\Dav\Migration\CalendarAdapter;
|
||||
|
@ -84,8 +83,7 @@ class Application extends App {
|
|||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager()
|
||||
);
|
||||
$groupPrincipal = new GroupPrincipalBackend($c->getServer()->getGroupManager());
|
||||
return new CardDavBackend($db, $principal, $groupPrincipal, $dispatcher);
|
||||
return new CardDavBackend($db, $principal, $dispatcher);
|
||||
});
|
||||
|
||||
$container->registerService('CalDavBackend', function($c) {
|
||||
|
@ -95,8 +93,7 @@ class Application extends App {
|
|||
$c->getServer()->getUserManager(),
|
||||
$c->getServer()->getGroupManager()
|
||||
);
|
||||
$groupPrincipal = new GroupPrincipalBackend($c->getServer()->getGroupManager());
|
||||
return new CalDavBackend($db, $principal, $groupPrincipal);
|
||||
return new CalDavBackend($db, $principal);
|
||||
});
|
||||
|
||||
$container->registerService('MigrateAddressbooks', function($c) {
|
||||
|
@ -220,7 +217,7 @@ class Application extends App {
|
|||
$migration = $this->getContainer()->query('BirthdayService');
|
||||
$userManager = $this->getContainer()->getServer()->getUserManager();
|
||||
|
||||
$userManager->callForAllUsers(function ($user) use ($migration) {
|
||||
$userManager->callForAllUsers(function($user) use($migration) {
|
||||
/** @var IUser $user */
|
||||
$migration->syncUser($user->getUID());
|
||||
});
|
||||
|
@ -228,11 +225,4 @@ class Application extends App {
|
|||
$this->getContainer()->getServer()->getLogger()->logException($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CardDavBackend
|
||||
*/
|
||||
public function getCardDavBackend() {
|
||||
return $this->getContainer()->query('CardDavBackend');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ $app = new Application();
|
|||
|
||||
/** @var Symfony\Component\Console\Application $application */
|
||||
$application->add(new CreateCalendar($userManager, $groupManager, $dbConnection));
|
||||
$application->add(new CreateAddressBook($userManager, $app->getCardDavBackend()));
|
||||
$application->add(new CreateAddressBook($userManager, $app->getContainer()->query('CardDavBackend')));
|
||||
$application->add(new SyncSystemAddressBook($app->getSyncService()));
|
||||
$application->add(new SyncBirthdayCalendar($userManager, $app->getContainer()->query('BirthdayService')));
|
||||
$application->add(new MigrateAddressbooks($userManager, $app->getContainer()->query('MigrateAddressbooks')));
|
||||
|
|
|
@ -29,7 +29,6 @@ use OCA\DAV\Connector\Sabre\Auth;
|
|||
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
|
||||
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
|
||||
$authBackend = new Auth(
|
||||
\OC::$server->getSession(),
|
||||
|
@ -43,8 +42,7 @@ $principalBackend = new Principal(
|
|||
'principals/'
|
||||
);
|
||||
$db = \OC::$server->getDatabaseConnection();
|
||||
$groupPrincipal = new GroupPrincipalBackend(\OC::$server->getGroupManager());
|
||||
$calDavBackend = new CalDavBackend($db, $principalBackend, $groupPrincipal);
|
||||
$calDavBackend = new CalDavBackend($db, $principalBackend);
|
||||
|
||||
// Root nodes
|
||||
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
|
||||
|
|
|
@ -42,14 +42,14 @@ $principalBackend = new Principal(
|
|||
'principals/'
|
||||
);
|
||||
$db = \OC::$server->getDatabaseConnection();
|
||||
$app = new \OCA\Dav\AppInfo\Application();
|
||||
$cardDavBackend = new CardDavBackend($db, $principalBackend);
|
||||
|
||||
// Root nodes
|
||||
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
|
||||
$principalCollection->disableListing = true; // Disable listing
|
||||
|
||||
$addressBookRoot = new AddressBookRoot($principalBackend, $app->getCardDavBackend());
|
||||
$addressBookRoot->disableListing = false; // Disable listing
|
||||
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend);
|
||||
$addressBookRoot->disableListing = true; // Disable listing
|
||||
|
||||
$nodes = array(
|
||||
$principalCollection,
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace OCA\DAV\Command;
|
|||
|
||||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
|
@ -74,10 +73,9 @@ class CreateCalendar extends Command {
|
|||
$this->userManager,
|
||||
$this->groupManager
|
||||
);
|
||||
$groupPrincipal = new GroupPrincipalBackend($this->groupManager);
|
||||
|
||||
$name = $input->getArgument('name');
|
||||
$caldav = new CalDavBackend($this->dbConnection, $principalBackend, $groupPrincipal);
|
||||
$caldav = new CalDavBackend($this->dbConnection, $principalBackend);
|
||||
$caldav->createCalendar("principals/users/$user", $name, []);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace OCA\DAV\CalDAV;
|
||||
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use OCA\DAV\DAV\Sharing\IShareable;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
|
@ -36,9 +35,7 @@ use Sabre\CalDAV\Plugin;
|
|||
use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
|
||||
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
|
||||
use Sabre\DAV;
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\DAV\Exception\Forbidden;
|
||||
use Sabre\DAV\PropPatch;
|
||||
use Sabre\HTTP\URLUtil;
|
||||
use Sabre\VObject\DateTimeParser;
|
||||
use Sabre\VObject\Reader;
|
||||
|
@ -107,13 +104,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* CalDavBackend constructor.
|
||||
*
|
||||
* @param IDBConnection $db
|
||||
* @param $userPrincipalBackend
|
||||
* @param GroupPrincipalBackend $groupPrincipalBackend
|
||||
* @param Principal $principalBackend
|
||||
*/
|
||||
public function __construct(IDBConnection $db, $userPrincipalBackend, GroupPrincipalBackend $groupPrincipalBackend) {
|
||||
public function __construct(IDBConnection $db, Principal $principalBackend) {
|
||||
$this->db = $db;
|
||||
$this->principalBackend = $userPrincipalBackend;
|
||||
$this->sharingBackend = new Backend($this->db, $userPrincipalBackend, $groupPrincipalBackend, 'calendar');
|
||||
$this->principalBackend = $principalBackend;
|
||||
$this->sharingBackend = new Backend($this->db, $principalBackend, 'calendar');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,7 +343,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* @param string $calendarUri
|
||||
* @param array $properties
|
||||
* @return int
|
||||
* @throws DAV\Exception
|
||||
*/
|
||||
function createCalendar($principalUri, $calendarUri, array $properties) {
|
||||
$values = [
|
||||
|
@ -399,10 +394,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
*
|
||||
* Read the PropPatch documentation for more info and examples.
|
||||
*
|
||||
* @param int $calendarId
|
||||
* @param PropPatch $propPatch
|
||||
* @param \Sabre\DAV\PropPatch $propPatch
|
||||
* @return void
|
||||
*/
|
||||
function updateCalendar($calendarId, PropPatch $propPatch) {
|
||||
function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) {
|
||||
$supportedProperties = array_keys($this->propertyMap);
|
||||
$supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
|
||||
|
||||
|
@ -1042,7 +1037,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* @param string $uri
|
||||
* @param array $properties
|
||||
* @return mixed
|
||||
* @throws Forbidden
|
||||
*/
|
||||
function createSubscription($principalUri, $uri, array $properties) {
|
||||
|
||||
|
@ -1091,10 +1085,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* Read the PropPatch documentation for more info and examples.
|
||||
*
|
||||
* @param mixed $subscriptionId
|
||||
* @param PropPatch $propPatch
|
||||
* @param \Sabre\DAV\PropPatch $propPatch
|
||||
* @return void
|
||||
*/
|
||||
function updateSubscription($subscriptionId, PropPatch $propPatch) {
|
||||
function updateSubscription($subscriptionId, DAV\PropPatch $propPatch) {
|
||||
$supportedProperties = array_keys($this->subscriptionPropertyMap);
|
||||
$supportedProperties[] = '{http://calendarserver.org/ns/}source';
|
||||
|
||||
|
@ -1284,7 +1278,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
*
|
||||
* @param string $calendarData
|
||||
* @return array
|
||||
* @throws BadRequest
|
||||
*/
|
||||
protected function getDenormalizedData($calendarData) {
|
||||
|
||||
|
@ -1302,7 +1295,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
}
|
||||
}
|
||||
if (!$componentType) {
|
||||
throw new BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
|
||||
throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
|
||||
}
|
||||
if ($componentType === 'VEVENT' && $component->DTSTART) {
|
||||
$firstOccurence = $component->DTSTART->getDateTime()->getTimeStamp();
|
||||
|
@ -1369,21 +1362,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
|
||||
/**
|
||||
* @param int $resourceId
|
||||
* @param string $currentPrincipal
|
||||
* @return array
|
||||
*/
|
||||
public function getShares($resourceId, $currentPrincipal) {
|
||||
return $this->sharingBackend->getShares($resourceId, $currentPrincipal);
|
||||
public function getShares($resourceId) {
|
||||
return $this->sharingBackend->getShares($resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $resourceId
|
||||
* @param array $acl
|
||||
* @param string $currentPrincipal
|
||||
* @return array
|
||||
*/
|
||||
public function applyShareAcl($resourceId, $acl, $currentPrincipal) {
|
||||
return $this->sharingBackend->applyShareAcl($resourceId, $acl, $currentPrincipal);
|
||||
public function applyShareAcl($resourceId, $acl) {
|
||||
return $this->sharingBackend->applyShareAcl($resourceId, $acl);
|
||||
}
|
||||
|
||||
private function convertPrincipal($principalUri, $toV2) {
|
||||
|
|
|
@ -75,7 +75,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
|||
function getShares() {
|
||||
/** @var CalDavBackend $calDavBackend */
|
||||
$calDavBackend = $this->caldavBackend;
|
||||
return $calDavBackend->getShares($this->getResourceId(), parent::getOwner());
|
||||
return $calDavBackend->getShares($this->getResourceId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
|||
|
||||
/** @var CalDavBackend $calDavBackend */
|
||||
$calDavBackend = $this->caldavBackend;
|
||||
return $calDavBackend->applyShareAcl($this->getResourceId(), $acl, parent::getOwner());
|
||||
return $calDavBackend->applyShareAcl($this->getResourceId(), $acl);
|
||||
}
|
||||
|
||||
function getChildACL() {
|
||||
|
|
|
@ -67,7 +67,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
|
|||
function getShares() {
|
||||
/** @var CardDavBackend $carddavBackend */
|
||||
$carddavBackend = $this->carddavBackend;
|
||||
return $carddavBackend->getShares($this->getResourceId(), $this->getOwner());
|
||||
return $carddavBackend->getShares($this->getResourceId());
|
||||
}
|
||||
|
||||
function getACL() {
|
||||
|
@ -106,7 +106,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
|
|||
|
||||
/** @var CardDavBackend $carddavBackend */
|
||||
$carddavBackend = $this->carddavBackend;
|
||||
return $carddavBackend->applyShareAcl($this->getResourceId(), $acl, parent::getOwner());
|
||||
return $carddavBackend->applyShareAcl($this->getResourceId(), $acl);
|
||||
}
|
||||
|
||||
function getChildACL() {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
namespace OCA\DAV\CardDAV;
|
||||
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCA\DAV\DAV\Sharing\Backend;
|
||||
use OCA\DAV\DAV\Sharing\IShareable;
|
||||
|
@ -35,7 +34,6 @@ use Sabre\CardDAV\Backend\BackendInterface;
|
|||
use Sabre\CardDAV\Backend\SyncSupport;
|
||||
use Sabre\CardDAV\Plugin;
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\DAV\PropPatch;
|
||||
use Sabre\HTTP\URLUtil;
|
||||
use Sabre\VObject\Component\VCard;
|
||||
use Sabre\VObject\Reader;
|
||||
|
@ -71,18 +69,16 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
* CardDavBackend constructor.
|
||||
*
|
||||
* @param IDBConnection $db
|
||||
* @param Principal $userPrincipalBackend
|
||||
* @param GroupPrincipalBackend $groupPrincipalBackend
|
||||
* @param Principal $principalBackend
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
*/
|
||||
public function __construct(IDBConnection $db,
|
||||
Principal $userPrincipalBackend,
|
||||
GroupPrincipalBackend $groupPrincipalBackend,
|
||||
Principal $principalBackend,
|
||||
EventDispatcherInterface $dispatcher = null) {
|
||||
$this->db = $db;
|
||||
$this->principalBackend = $userPrincipalBackend;
|
||||
$this->principalBackend = $principalBackend;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->sharingBackend = new Backend($this->db, $userPrincipalBackend, $groupPrincipalBackend, 'addressbook');
|
||||
$this->sharingBackend = new Backend($this->db, $principalBackend, 'addressbook');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,7 +161,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
|
||||
/**
|
||||
* @param int $addressBookId
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAddressBookById($addressBookId) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
|
@ -192,8 +187,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $principal
|
||||
* @param string $addressBookUri
|
||||
* @param $addressBookUri
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAddressBooksByUri($principal, $addressBookUri) {
|
||||
|
@ -235,10 +229,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
* Read the PropPatch documentation for more info and examples.
|
||||
*
|
||||
* @param string $addressBookId
|
||||
* @param PropPatch $propPatch
|
||||
* @param \Sabre\DAV\PropPatch $propPatch
|
||||
* @return void
|
||||
*/
|
||||
function updateAddressBook($addressBookId, PropPatch $propPatch) {
|
||||
function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
|
||||
$supportedProperties = [
|
||||
'{DAV:}displayname',
|
||||
'{' . Plugin::NS_CARDDAV . '}addressbook-description',
|
||||
|
@ -873,12 +867,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
* * readOnly - boolean
|
||||
* * summary - Optional, a description for the share
|
||||
*
|
||||
* @param $addressBookId
|
||||
* @param string $currentPrincipal
|
||||
* @return array
|
||||
*/
|
||||
public function getShares($addressBookId, $currentPrincipal) {
|
||||
return $this->sharingBackend->getShares($addressBookId, $currentPrincipal);
|
||||
public function getShares($addressBookId) {
|
||||
return $this->sharingBackend->getShares($addressBookId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -976,11 +968,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
* For shared address books the sharee is set in the ACL of the address book
|
||||
* @param $addressBookId
|
||||
* @param $acl
|
||||
* @param string $currentPrincipal
|
||||
* @return array
|
||||
*/
|
||||
public function applyShareAcl($addressBookId, $acl, $currentPrincipal) {
|
||||
return $this->sharingBackend->applyShareAcl($addressBookId, $acl, $currentPrincipal);
|
||||
public function applyShareAcl($addressBookId, $acl) {
|
||||
return $this->sharingBackend->applyShareAcl($addressBookId, $acl);
|
||||
}
|
||||
|
||||
private function convertPrincipal($principalUri, $toV2) {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
namespace OCA\DAV\DAV\Sharing;
|
||||
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class Backend {
|
||||
|
@ -31,9 +30,7 @@ class Backend {
|
|||
/** @var IDBConnection */
|
||||
private $db;
|
||||
/** @var Principal */
|
||||
private $userPrincipalBackend;
|
||||
/** @var GroupPrincipalBackend */
|
||||
private $groupPrincipalBackend;
|
||||
private $principalBackend;
|
||||
/** @var string */
|
||||
private $resourceType;
|
||||
|
||||
|
@ -43,14 +40,12 @@ class Backend {
|
|||
|
||||
/**
|
||||
* @param IDBConnection $db
|
||||
* @param Principal $userPrincipalBackend
|
||||
* @param GroupPrincipalBackend $groupPrincipalBackend
|
||||
* @param Principal $principalBackend
|
||||
* @param string $resourceType
|
||||
*/
|
||||
public function __construct(IDBConnection $db, Principal $userPrincipalBackend, GroupPrincipalBackend $groupPrincipalBackend, $resourceType) {
|
||||
public function __construct(IDBConnection $db, Principal $principalBackend, $resourceType) {
|
||||
$this->db = $db;
|
||||
$this->userPrincipalBackend = $userPrincipalBackend;
|
||||
$this->groupPrincipalBackend = $groupPrincipalBackend;
|
||||
$this->principalBackend = $principalBackend;
|
||||
$this->resourceType = $resourceType;
|
||||
}
|
||||
|
||||
|
@ -148,10 +143,9 @@ class Backend {
|
|||
* * summary - Optional, a description for the share
|
||||
*
|
||||
* @param int $resourceId
|
||||
* @param string $currentPrincipal
|
||||
* @return array
|
||||
*/
|
||||
public function getShares($resourceId, $currentPrincipal) {
|
||||
public function getShares($resourceId) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$result = $query->select(['principaluri', 'access'])
|
||||
->from('dav_shares')
|
||||
|
@ -161,31 +155,13 @@ class Backend {
|
|||
|
||||
$shares = [];
|
||||
while($row = $result->fetch()) {
|
||||
$p = $this->userPrincipalBackend->getPrincipalByPath($row['principaluri']);
|
||||
if (is_null($p)) {
|
||||
$p = $this->groupPrincipalBackend->getPrincipalByPath($row['principaluri']);
|
||||
if (is_null($p)) {
|
||||
continue;
|
||||
}
|
||||
// also add the current user if it is member of the group
|
||||
$groups = $this->userPrincipalBackend->getGroupMembership($currentPrincipal);
|
||||
if (in_array($row['principaluri'], $groups)) {
|
||||
$ownerPrincipal = $this->userPrincipalBackend->getPrincipalByPath($currentPrincipal);
|
||||
$shares[]= [
|
||||
'href' => "principal:$currentPrincipal",
|
||||
'commonName' => isset($ownerPrincipal['{DAV:}displayname']) ? $ownerPrincipal['{DAV:}displayname'] : '',
|
||||
'status' => 1,
|
||||
'readOnly' => ($row['access'] == self::ACCESS_READ),
|
||||
'{http://owncloud.org/ns}principal' => $currentPrincipal
|
||||
];
|
||||
}
|
||||
}
|
||||
$p = $this->principalBackend->getPrincipalByPath($row['principaluri']);
|
||||
$shares[]= [
|
||||
'href' => "principal:${row['principaluri']}",
|
||||
'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '',
|
||||
'status' => 1,
|
||||
'readOnly' => ($row['access'] == self::ACCESS_READ),
|
||||
'{http://owncloud.org/ns}principal' => $row['principaluri']
|
||||
'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal' => $row['principaluri']
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -197,12 +173,11 @@ class Backend {
|
|||
*
|
||||
* @param int $resourceId
|
||||
* @param array $acl
|
||||
* @param string $currentPrincipal
|
||||
* @return array
|
||||
*/
|
||||
public function applyShareAcl($resourceId, $acl, $currentPrincipal) {
|
||||
public function applyShareAcl($resourceId, $acl) {
|
||||
|
||||
$shares = $this->getShares($resourceId, $currentPrincipal);
|
||||
$shares = $this->getShares($resourceId);
|
||||
foreach ($shares as $share) {
|
||||
$acl[] = [
|
||||
'privilege' => '{DAV:}read',
|
||||
|
|
|
@ -71,4 +71,4 @@ interface IShareable extends INode {
|
|||
*/
|
||||
public function getOwner();
|
||||
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ class RootCollection extends SimpleCollection {
|
|||
$systemPrincipals->disableListing = $disableListing;
|
||||
$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
|
||||
$filesCollection->disableListing = $disableListing;
|
||||
$caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $groupPrincipalBackend);
|
||||
$caldavBackend = new CalDavBackend($db, $userPrincipalBackend);
|
||||
$calendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
|
||||
$calendarRoot->disableListing = $disableListing;
|
||||
|
||||
|
@ -80,13 +80,12 @@ class RootCollection extends SimpleCollection {
|
|||
\OC::$server->getRootFolder(),
|
||||
\OC::$server->getLogger()
|
||||
);
|
||||
$groupPrincipal = new GroupPrincipalBackend(\OC::$server->getGroupManager());
|
||||
|
||||
$usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $groupPrincipal, $dispatcher);
|
||||
$usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $dispatcher);
|
||||
$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
|
||||
$usersAddressBookRoot->disableListing = $disableListing;
|
||||
|
||||
$systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $groupPrincipal, $dispatcher);
|
||||
$systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $dispatcher);
|
||||
$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
|
||||
$systemAddressBookRoot->disableListing = $disableListing;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use DateTimeZone;
|
|||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCA\DAV\CalDAV\Calendar;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
|
||||
use Sabre\DAV\PropPatch;
|
||||
use Sabre\DAV\Xml\Property\Href;
|
||||
|
@ -47,9 +46,6 @@ class CalDavBackendTest extends TestCase {
|
|||
/** @var Principal | \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $principal;
|
||||
|
||||
/** @var GroupPrincipalBackend | \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $groupPrincipal;
|
||||
|
||||
const UNIT_TEST_USER = 'principals/users/caldav-unit-test';
|
||||
const UNIT_TEST_USER1 = 'principals/users/caldav-unit-test1';
|
||||
const UNIT_TEST_GROUP = 'principals/groups/caldav-unit-test-group';
|
||||
|
@ -68,13 +64,9 @@ class CalDavBackendTest extends TestCase {
|
|||
$this->principal->expects($this->any())->method('getGroupMembership')
|
||||
->withAnyParameters()
|
||||
->willReturn([self::UNIT_TEST_GROUP]);
|
||||
$this->groupPrincipal = $this->getMockBuilder('OCA\DAV\DAV\GroupPrincipalBackend')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getPrincipalByPath', 'getGroupMembership'])
|
||||
->getMock();
|
||||
|
||||
$db = \OC::$server->getDatabaseConnection();
|
||||
$this->backend = new CalDavBackend($db, $this->principal, $this->groupPrincipal);
|
||||
$this->backend = new CalDavBackend($db, $this->principal);
|
||||
|
||||
$this->tearDown();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ use InvalidArgumentException;
|
|||
use OCA\DAV\CardDAV\AddressBook;
|
||||
use OCA\DAV\CardDAV\CardDavBackend;
|
||||
use OCA\DAV\Connector\Sabre\Principal;
|
||||
use OCA\DAV\DAV\GroupPrincipalBackend;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
use Sabre\DAV\PropPatch;
|
||||
|
@ -59,9 +58,6 @@ class CardDavBackendTest extends TestCase {
|
|||
/** @var string */
|
||||
private $dbCardsPropertiesTable = 'cards_properties';
|
||||
|
||||
/** @var GroupPrincipalBackend */
|
||||
private $groupPrincipal;
|
||||
|
||||
const UNIT_TEST_USER = 'principals/users/carddav-unit-test';
|
||||
const UNIT_TEST_USER1 = 'principals/users/carddav-unit-test1';
|
||||
const UNIT_TEST_GROUP = 'principals/groups/carddav-unit-test-group';
|
||||
|
@ -73,21 +69,17 @@ class CardDavBackendTest extends TestCase {
|
|||
->disableOriginalConstructor()
|
||||
->setMethods(['getPrincipalByPath', 'getGroupMembership'])
|
||||
->getMock();
|
||||
$this->principal->expects($this->any())->method('getPrincipalByPath')
|
||||
$this->principal->method('getPrincipalByPath')
|
||||
->willReturn([
|
||||
'uri' => 'principals/best-friend'
|
||||
]);
|
||||
$this->principal->expects($this->any())->method('getGroupMembership')
|
||||
$this->principal->method('getGroupMembership')
|
||||
->withAnyParameters()
|
||||
->willReturn([self::UNIT_TEST_GROUP]);
|
||||
$this->groupPrincipal = $this->getMockBuilder('OCA\DAV\DAV\GroupPrincipalBackend')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getPrincipalByPath', 'getGroupMembership'])
|
||||
->getMock();
|
||||
|
||||
$this->db = \OC::$server->getDatabaseConnection();
|
||||
|
||||
$this->backend = new CardDavBackend($this->db, $this->principal, $this->groupPrincipal, null);
|
||||
$this->backend = new CardDavBackend($this->db, $this->principal, null);
|
||||
|
||||
// start every test with a empty cards_properties and cards table
|
||||
$query = $this->db->getQueryBuilder();
|
||||
|
@ -165,7 +157,7 @@ class CardDavBackendTest extends TestCase {
|
|||
|
||||
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */
|
||||
$backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
|
||||
->setConstructorArgs([$this->db, $this->principal, $this->groupPrincipal, null])
|
||||
->setConstructorArgs([$this->db, $this->principal, null])
|
||||
->setMethods(['updateProperties', 'purgeProperties'])->getMock();
|
||||
|
||||
// create a new address book
|
||||
|
@ -211,7 +203,7 @@ class CardDavBackendTest extends TestCase {
|
|||
public function testMultiCard() {
|
||||
|
||||
$this->backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
|
||||
->setConstructorArgs([$this->db, $this->principal, $this->groupPrincipal, null])
|
||||
->setConstructorArgs([$this->db, $this->principal, null])
|
||||
->setMethods(['updateProperties'])->getMock();
|
||||
|
||||
// create a new address book
|
||||
|
@ -256,8 +248,9 @@ class CardDavBackendTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteWithoutCard() {
|
||||
|
||||
$this->backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
|
||||
->setConstructorArgs([$this->db, $this->principal, $this->groupPrincipal, null])
|
||||
->setConstructorArgs([$this->db, $this->principal, null])
|
||||
->setMethods([
|
||||
'getCardId',
|
||||
'addChange',
|
||||
|
@ -296,8 +289,9 @@ class CardDavBackendTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testSyncSupport() {
|
||||
|
||||
$this->backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
|
||||
->setConstructorArgs([$this->db, $this->principal, $this->groupPrincipal, null])
|
||||
->setConstructorArgs([$this->db, $this->principal, null])
|
||||
->setMethods(['updateProperties'])->getMock();
|
||||
|
||||
// create a new address book
|
||||
|
@ -327,13 +321,13 @@ class CardDavBackendTest extends TestCase {
|
|||
$exampleBook = new AddressBook($this->backend, $books[0]);
|
||||
$this->backend->updateShares($exampleBook, [['href' => 'principal:principals/best-friend']], []);
|
||||
|
||||
$shares = $this->backend->getShares($exampleBook->getResourceId(), null);
|
||||
$shares = $this->backend->getShares($exampleBook->getResourceId());
|
||||
$this->assertEquals(1, count($shares));
|
||||
|
||||
// adding the same sharee again has no effect
|
||||
$this->backend->updateShares($exampleBook, [['href' => 'principal:principals/best-friend']], []);
|
||||
|
||||
$shares = $this->backend->getShares($exampleBook->getResourceId(), null);
|
||||
$shares = $this->backend->getShares($exampleBook->getResourceId());
|
||||
$this->assertEquals(1, count($shares));
|
||||
|
||||
$books = $this->backend->getAddressBooksForUser('principals/best-friend');
|
||||
|
@ -341,7 +335,7 @@ class CardDavBackendTest extends TestCase {
|
|||
|
||||
$this->backend->updateShares($exampleBook, [], ['principal:principals/best-friend']);
|
||||
|
||||
$shares = $this->backend->getShares($exampleBook->getResourceId(), null);
|
||||
$shares = $this->backend->getShares($exampleBook->getResourceId());
|
||||
$this->assertEquals(0, count($shares));
|
||||
|
||||
$books = $this->backend->getAddressBooksForUser('principals/best-friend');
|
||||
|
@ -355,7 +349,7 @@ class CardDavBackendTest extends TestCase {
|
|||
$cardId = 2;
|
||||
|
||||
$backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')
|
||||
->setConstructorArgs([$this->db, $this->principal, $this->groupPrincipal, null])
|
||||
->setConstructorArgs([$this->db, $this->principal, null])
|
||||
->setMethods(['getCardId'])->getMock();
|
||||
|
||||
$backend->expects($this->any())->method('getCardId')->willReturn($cardId);
|
||||
|
|
Loading…
Reference in New Issue