diff options
Diffstat (limited to 'apps')
44 files changed, 423 insertions, 400 deletions
diff --git a/apps/admin_audit/lib/Actions/Sharing.php b/apps/admin_audit/lib/Actions/Sharing.php index 1384d6f2350..8652ff7d195 100644 --- a/apps/admin_audit/lib/Actions/Sharing.php +++ b/apps/admin_audit/lib/Actions/Sharing.php @@ -30,7 +30,7 @@ declare(strict_types=1); namespace OCA\AdminAudit\Actions; -use OCP\Share; +use OCP\Share\IShare; /** * Class Sharing logs the sharing actions @@ -44,7 +44,7 @@ class Sharing extends Action { * @param array $params */ public function shared(array $params) { - if ($params['shareType'] === Share::SHARE_TYPE_LINK) { + if ($params['shareType'] === IShare::TYPE_LINK) { $this->log( 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', $params, @@ -56,7 +56,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { + } elseif ($params['shareType'] === IShare::TYPE_USER) { $this->log( 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', $params, @@ -69,7 +69,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', $params, @@ -82,7 +82,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) { + } elseif ($params['shareType'] === IShare::TYPE_ROOM) { $this->log( 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', $params, @@ -95,7 +95,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) { + } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { $this->log( 'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)', $params, @@ -108,7 +108,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) { + } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { $this->log( 'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)', $params, @@ -121,7 +121,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { $this->log( 'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)', $params, @@ -134,7 +134,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)', $params, @@ -156,7 +156,7 @@ class Sharing extends Action { * @param array $params */ public function unshare(array $params) { - if ($params['shareType'] === Share::SHARE_TYPE_LINK) { + if ($params['shareType'] === IShare::TYPE_LINK) { $this->log( 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', $params, @@ -167,7 +167,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { + } elseif ($params['shareType'] === IShare::TYPE_USER) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', $params, @@ -179,7 +179,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', $params, @@ -191,7 +191,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) { + } elseif ($params['shareType'] === IShare::TYPE_ROOM) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)', $params, @@ -203,7 +203,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) { + } elseif ($params['shareType'] === IShare::TYPE_EMAIL) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)', $params, @@ -215,7 +215,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) { + } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)', $params, @@ -227,7 +227,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)', $params, @@ -239,7 +239,7 @@ class Sharing extends Action { 'id', ] ); - } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) { + } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) { $this->log( 'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)', $params, diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 83f90fa4ba2..9d7052b5c2d 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -42,7 +42,7 @@ use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCP\Files\FileInfo; use OCP\Files\StorageNotAvailableException; -use OCP\Share; +use OCP\Share\IShare; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; @@ -313,10 +313,10 @@ abstract class Node implements \Sabre\DAV\INode { } $types = [ - Share::SHARE_TYPE_USER, - Share::SHARE_TYPE_GROUP, - Share::SHARE_TYPE_CIRCLE, - Share::SHARE_TYPE_ROOM + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_CIRCLE, + IShare::TYPE_ROOM ]; foreach ($types as $shareType) { diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php index 63c204fda4e..3d80d8674ba 100644 --- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php @@ -113,13 +113,13 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin { private function getShare(\OCP\Files\Node $node): array { $result = []; $requestedShareTypes = [ - \OCP\Share::SHARE_TYPE_USER, - \OCP\Share::SHARE_TYPE_GROUP, - \OCP\Share::SHARE_TYPE_LINK, - \OCP\Share::SHARE_TYPE_REMOTE, - \OCP\Share::SHARE_TYPE_EMAIL, - \OCP\Share::SHARE_TYPE_ROOM, - \OCP\Share::SHARE_TYPE_CIRCLE, + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_LINK, + IShare::TYPE_REMOTE, + IShare::TYPE_EMAIL, + IShare::TYPE_ROOM, + IShare::TYPE_CIRCLE, ]; foreach ($requestedShareTypes as $requestedShareType) { $shares = $this->shareManager->getSharesBy( diff --git a/apps/dav/tests/unit/Connector/PublicAuthTest.php b/apps/dav/tests/unit/Connector/PublicAuthTest.php index bcec84d414c..d3d17b03673 100644 --- a/apps/dav/tests/unit/Connector/PublicAuthTest.php +++ b/apps/dav/tests/unit/Connector/PublicAuthTest.php @@ -134,7 +134,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_REMOTE); + $share->method('getShareType')->willReturn(IShare::TYPE_REMOTE); $this->shareManager->expects($this->once()) ->method('getShareByToken') @@ -150,7 +150,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $this->shareManager->expects($this->once()) ->method('getShareByToken') @@ -172,7 +172,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_EMAIL); + $share->method('getShareType')->willReturn(IShare::TYPE_EMAIL); $this->shareManager->expects($this->once()) ->method('getShareByToken') @@ -194,7 +194,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $share->method('getId')->willReturn('42'); $this->shareManager->expects($this->once()) @@ -220,7 +220,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $share->method('getId')->willReturn('42'); $this->shareManager->expects($this->once()) @@ -247,7 +247,7 @@ class PublicAuthTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_EMAIL); + $share->method('getShareType')->willReturn(IShare::TYPE_EMAIL); $share->method('getId')->willReturn('42'); $this->shareManager->expects($this->once()) diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 8a24c1ae4bb..b1fb8d97f74 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -272,16 +272,16 @@ class SharesPluginTest extends \Test\TestCase { public function sharesGetPropertiesDataProvider() { return [ [[]], - [[\OCP\Share::SHARE_TYPE_USER]], - [[\OCP\Share::SHARE_TYPE_GROUP]], - [[\OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_REMOTE]], - [[\OCP\Share::SHARE_TYPE_ROOM]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]], - [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_REMOTE]], + [[IShare::TYPE_USER]], + [[IShare::TYPE_GROUP]], + [[IShare::TYPE_LINK]], + [[IShare::TYPE_REMOTE]], + [[IShare::TYPE_ROOM]], + [[IShare::TYPE_USER, IShare::TYPE_GROUP]], + [[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]], + [[IShare::TYPE_USER, IShare::TYPE_LINK]], + [[IShare::TYPE_GROUP, IShare::TYPE_LINK]], + [[IShare::TYPE_USER, IShare::TYPE_REMOTE]], ]; } diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 228fab305b9..3cc9c8e58c1 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -171,7 +171,7 @@ class FederatedShareProvider implements IShareProvider { $sharedBy = $share->getSharedBy(); $shareType = $share->getShareType(); - if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP && + if ($shareType === IShare::TYPE_REMOTE_GROUP && !$this->isOutgoingServer2serverGroupShareEnabled() ) { $message = 'It is not allowed to send federated group shares from this server.'; @@ -183,8 +183,8 @@ class FederatedShareProvider implements IShareProvider { /* * Check if file is not already shared with the remote user */ - $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE, $share->getNode(), 1, 0); - $alreadySharedGroup = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE_GROUP, $share->getNode(), 1, 0); + $alreadyShared = $this->getSharedWith($shareWith, IShare::TYPE_REMOTE, $share->getNode(), 1, 0); + $alreadySharedGroup = $this->getSharedWith($shareWith, IShare::TYPE_REMOTE_GROUP, $share->getNode(), 1, 0); if (!empty($alreadyShared) || !empty($alreadySharedGroup)) { $message = 'Sharing %1$s failed, because this item is already shared with %2$s'; $message_t = $this->l->t('Sharing %1$s failed, because this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]); @@ -628,7 +628,7 @@ class FederatedShareProvider implements IShareProvider { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->andWhere( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)) ); /** @@ -945,7 +945,7 @@ class FederatedShareProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))) ->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid))) ->execute(); } @@ -1072,7 +1072,7 @@ class FederatedShareProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->select('share_with', 'token', 'file_source') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 0e9b9dbed62..d427e324e1f 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -209,7 +209,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { } // FIXME this should be a method in the user management instead - if ($shareType === Share::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); Util::emitHook( '\OCA\Files_Sharing\API\Server2Server', @@ -225,7 +225,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { \OC_Util::setupFS($shareWith); } - if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { + if ($shareType === IShare::TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); } @@ -247,7 +247,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); - if ($shareType === Share::SHARE_TYPE_USER) { + if ($shareType === IShare::TYPE_USER) { $event = $this->activityManager->generateEvent(); $event->setApp('files_sharing') ->setType('remote_share') @@ -324,9 +324,9 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { * @return int */ private function mapShareTypeToNextcloud($shareType) { - $result = Share::SHARE_TYPE_USER; + $result = IShare::TYPE_USER; if ($shareType === 'group') { - $result = Share::SHARE_TYPE_GROUP; + $result = IShare::TYPE_GROUP; } return $result; @@ -585,7 +585,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { ->where($qb->expr()->eq('parent', $qb->createNamedParameter((int)$share['id']))); $qb->execute(); - if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ((int)$share['share_type'] === IShare::TYPE_USER) { if ($share['accepted']) { $path = trim($mountpoint, '/'); } else { @@ -792,7 +792,7 @@ class CloudFederationProviderFiles implements ICloudFederationProvider { */ protected function verifyShare(IShare $share, $token) { if ( - $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE && + $share->getShareType() === IShare::TYPE_REMOTE && $share->getToken() === $token ) { return true; diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 825b8382d1e..2b04428848a 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -45,6 +45,7 @@ use OCP\IL10N; use OCP\ILogger; use OCP\IUserManager; use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class FederatedShareProviderTest @@ -149,7 +150,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -186,7 +187,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $stmt->closeCursor(); $expected = [ - 'share_type' => \OCP\Share::SHARE_TYPE_REMOTE, + 'share_type' => IShare::TYPE_REMOTE, 'share_with' => 'user@server.com', 'uid_owner' => 'shareOwner', 'uid_initiator' => 'sharedBy', @@ -200,7 +201,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->assertArraySubset($expected, $data); $this->assertEquals($data['id'], $share->getId()); - $this->assertEquals(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType()); + $this->assertEquals(IShare::TYPE_REMOTE, $share->getShareType()); $this->assertEquals('user@server.com', $share->getSharedWith()); $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals('shareOwner', $share->getShareOwner()); @@ -221,7 +222,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -278,7 +279,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -378,7 +379,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -447,7 +448,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($sharedBy) ->setShareOwner($owner) ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->tokenHandler->method('generateToken')->willReturn('token'); @@ -518,7 +519,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -527,11 +528,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy2') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_REMOTE, null, false, -1, 0); + $shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, null, false, -1, 0); $this->assertCount(1, $shares); $this->assertEquals('user@server.com', $shares[0]->getSharedWith()); @@ -558,7 +559,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -571,11 +572,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node2); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_REMOTE, $node2, false, -1, 0); + $shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, $node2, false, -1, 0); $this->assertCount(1, $shares); $this->assertEquals(43, $shares[0]->getNodeId()); @@ -601,7 +602,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('shareOwner') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -610,11 +611,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_REMOTE, null, true, -1, 0); + $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, -1, 0); $this->assertCount(2, $shares); } @@ -647,7 +648,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share); @@ -656,11 +657,11 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy('sharedBy') ->setShareOwner('shareOwner') ->setPermissions(19) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($node); $this->provider->create($share2); - $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_REMOTE, null, true, 1, 1); + $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, 1, 1); $this->assertCount(1, $shares); $this->assertEquals('user2@server.com', $shares[0]->getSharedWith()); @@ -688,7 +689,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testDeleteUser($owner, $initiator, $recipient, $deletedUser, $rowDeleted) { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') - ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)) + ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)) ->setValue('uid_owner', $qb->createNamedParameter($owner)) ->setValue('uid_initiator', $qb->createNamedParameter($initiator)) ->setValue('share_with', $qb->createNamedParameter($recipient)) @@ -699,7 +700,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $id = $qb->getLastInsertId(); - $this->provider->userDeleted($deletedUser, \OCP\Share::SHARE_TYPE_REMOTE); + $this->provider->userDeleted($deletedUser, IShare::TYPE_REMOTE); $qb = $this->connection->getQueryBuilder(); $qb->select('*') @@ -847,7 +848,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file1); $this->provider->create($share1); @@ -856,7 +857,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u2->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file2); $this->provider->create($share2); @@ -903,7 +904,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file1); $this->provider->create($share1); @@ -912,7 +913,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setSharedBy($u1->getUID()) ->setShareOwner($u1->getUID()) ->setPermissions(\OCP\Constants::PERMISSION_READ) - ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + ->setShareType(IShare::TYPE_REMOTE) ->setNode($file1); $this->provider->create($share2); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 2aa3b777225..2add685133e 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -52,6 +52,7 @@ use OCP\IPreview; use OCP\IRequest; use OCP\IUserSession; use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class ApiController @@ -216,12 +217,12 @@ class ApiController extends Controller { $userId = $this->userSession->getUser()->getUID(); $shareTypes = []; $requestedShareTypes = [ - \OCP\Share::SHARE_TYPE_USER, - \OCP\Share::SHARE_TYPE_GROUP, - \OCP\Share::SHARE_TYPE_LINK, - \OCP\Share::SHARE_TYPE_REMOTE, - \OCP\Share::SHARE_TYPE_EMAIL, - \OCP\Share::SHARE_TYPE_ROOM + IShare::TYPE_USER, + IShare::TYPE_GROUP, + IShare::TYPE_LINK, + IShare::TYPE_REMOTE, + IShare::TYPE_EMAIL, + IShare::TYPE_ROOM ]; foreach ($requestedShareTypes as $requestedShareType) { // one of each type is enough to find out about the types diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 5bec5200b63..535822b999c 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -41,6 +41,7 @@ use OCP\Files\InvalidPathException; use OCP\Files\Mount\IMountManager; use OCP\IUser; use OCP\Share\IManager as IShareManager; +use OCP\Share\IShare; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\OutputInterface; @@ -238,7 +239,7 @@ class OwnershipTransferService { $shares = []; $progress = new ProgressBar($output); - foreach ([\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_ROOM] as $shareType) { + foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM] as $shareType) { $offset = 0; while (true) { $sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset); @@ -290,7 +291,7 @@ class OwnershipTransferService { foreach ($shares as $share) { try { - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === $destinationUid) { // Unmount the shares before deleting, so we don't try to get the storage later on. $shareMountPoint = $this->mountManager->find('/' . $destinationUid . '/files' . $share->getTarget()); diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index bb33711c757..9b367e06544 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -139,11 +139,11 @@ class DeletedShareAPIController extends OCSController { $result['expiration'] = $expiration->format('Y-m-d 00:00:00'); } - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + if ($share->getShareType() === IShare::TYPE_GROUP) { $group = $this->groupManager->get($share->getSharedWith()); $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith(); - } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) { + } elseif ($share->getShareType() === IShare::TYPE_ROOM) { $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = ''; @@ -160,8 +160,8 @@ class DeletedShareAPIController extends OCSController { * @NoAdminRequired */ public function index(): DataResponse { - $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); - $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_ROOM, null, -1, 0); + $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0); + $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0); $shares = array_merge($groupShares, $roomShares); diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 2c6b043c028..9e4e591e40d 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -73,6 +73,7 @@ use OCP\IUserManager; use OCP\Share; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager as ShareManager; +use OCP\Share\IShare; use OCP\Template; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -701,7 +702,7 @@ class ShareController extends AuthPublicShareController { $parameters = [$userPath]; - if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { + if ($share->getShareType() === IShare::TYPE_EMAIL) { if ($node instanceof \OCP\Files\File) { $subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED; } else { diff --git a/apps/files_sharing/lib/ExpireSharesJob.php b/apps/files_sharing/lib/ExpireSharesJob.php index 4ca3b80e343..c2916d260b3 100644 --- a/apps/files_sharing/lib/ExpireSharesJob.php +++ b/apps/files_sharing/lib/ExpireSharesJob.php @@ -25,6 +25,7 @@ namespace OCA\Files_Sharing; use OC\BackgroundJob\TimedJob; +use OCP\Share\IShare; /** * Delete all shares that are expired @@ -59,7 +60,7 @@ class ExpireSharesJob extends TimedJob { ->from('share') ->where( $qb->expr()->andX( - $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)), + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)), $qb->expr()->lte('expiration', $qb->expr()->literal($now)), $qb->expr()->orX( $qb->expr()->eq('item_type', $qb->expr()->literal('file')), @@ -70,7 +71,7 @@ class ExpireSharesJob extends TimedJob { $shares = $qb->execute(); while ($share = $shares->fetch()) { - \OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); + \OC\Share\Share::unshare($share['item_type'], $share['file_source'], IShare::TYPE_LINK, null, $share['uid_owner']); } $shares->closeCursor(); } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index e7ddf6c3a74..943b5abfe01 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -247,9 +247,9 @@ class Manager { $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']); // check if the user is allowed to access it - if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) { + if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) { return $share; - } elseif ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { + } elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) { $user = $this->userManager->get($this->uid); if ($this->groupManager->get($share['user'])->inGroup($user)) { return $share; @@ -277,7 +277,7 @@ class Manager { $hash = md5($mountPoint); $userShareAccepted = false; - if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ((int)$share['share_type'] === IShare::TYPE_USER) { $acceptShare = $this->connection->prepare(' UPDATE `*PREFIX*share_external` SET `accepted` = ?, @@ -321,7 +321,7 @@ class Manager { $share = $this->getShare($id); $result = false; - if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ($share && (int)$share['share_type'] === IShare::TYPE_USER) { $removeShare = $this->connection->prepare(' DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?'); $removeShare->execute([$id, $this->uid]); @@ -329,7 +329,7 @@ class Manager { $this->processNotification($id); $result = true; - } elseif ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { + } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) { $result = $this->writeShareToDb( $share['remote'], $share['share_token'], @@ -517,7 +517,7 @@ class Manager { $share = $getShare->fetch(); $getShare->closeCursor(); - if ($result && $share !== false && (int)$share['share_type'] === Share::SHARE_TYPE_USER) { + if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) { try { $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); } catch (\Throwable $e) { @@ -530,7 +530,7 @@ class Manager { WHERE `id` = ? '); $result = (bool)$query->execute([(int)$share['id']]); - } elseif ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) { + } elseif ($result && (int)$share['share_type'] === IShare::TYPE_GROUP) { $query = $this->connection->prepare(' UPDATE `*PREFIX*share_external` SET `accepted` = ? diff --git a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php index 237c6aca243..a4eaa5b3989 100644 --- a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php +++ b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php @@ -28,7 +28,7 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\Share; +use OCP\Share\IShare; /** * Class OwncloudGuestShareType @@ -69,8 +69,8 @@ class OwncloudGuestShareType implements IRepairStep { $query = $this->connection->getQueryBuilder(); $query->update('share') - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); + ->set('share_type', $query->createNamedParameter(IShare::TYPE_GUEST)) + ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_EMAIL))); $query->execute(); } diff --git a/apps/files_sharing/lib/Migration/SetPasswordColumn.php b/apps/files_sharing/lib/Migration/SetPasswordColumn.php index 5580bd46a5b..859c49f2991 100644 --- a/apps/files_sharing/lib/Migration/SetPasswordColumn.php +++ b/apps/files_sharing/lib/Migration/SetPasswordColumn.php @@ -27,7 +27,7 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\Share; +use OCP\Share\IShare; /** * Class SetPasswordColumn @@ -70,7 +70,7 @@ class SetPasswordColumn implements IRepairStep { $query ->update('share') ->set('password', 'share_with') - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) + ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_LINK))) ->andWhere($query->expr()->isNotNull('share_with')); $result = $query->execute(); @@ -83,7 +83,7 @@ class SetPasswordColumn implements IRepairStep { $clearQuery ->update('share') ->set('share_with', $clearQuery->createNamedParameter(null)) - ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); + ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(IShare::TYPE_LINK))); $clearQuery->execute(); } diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 82d74479d4b..bbb9da3a775 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -75,10 +75,10 @@ class MountProvider implements IMountProvider { * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { - $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1); - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1)); - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)); - $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_ROOM, null, -1)); + $shares = $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_USER, null, -1); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP, null, -1)); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_CIRCLE, null, -1)); + $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_ROOM, null, -1)); // filter out excluded shares and group shares that includes self $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index a0d7e448be4..60deebc5c01 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -36,6 +36,7 @@ namespace OCA\Files_Sharing\ShareBackend; use OCA\FederatedFileSharing\AppInfo\Application; use OCA\FederatedFileSharing\FederatedShareProvider; +use OCP\Share\IShare; class File implements \OCP\Share_Backend_File_Dependent { public const FORMAT_SHARED_STORAGE = 0; @@ -192,11 +193,11 @@ class File implements \OCP\Share_Backend_File_Dependent { * @return boolean */ public function isShareTypeAllowed($shareType) { - if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) { + if ($shareType === IShare::TYPE_REMOTE) { return $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(); } - if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { + if ($shareType === IShare::TYPE_REMOTE_GROUP) { return $this->federatedShareProvider->isOutgoingServer2serverGroupShareEnabled(); } diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 84e31494c92..fd2847f4af9 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -27,6 +27,8 @@ namespace OCA\Files_Sharing; +use OCP\Share\IShare; + class Updater { /** @@ -59,9 +61,9 @@ class Updater { $shareManager = \OC::$server->getShareManager(); - $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1); - $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1)); - $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_ROOM, $src, false, -1)); + $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_USER, $src, false, -1); + $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_GROUP, $src, false, -1)); + $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_ROOM, $src, false, -1)); // If the path we move is not a share we don't care if (empty($shares)) { @@ -79,7 +81,7 @@ class Updater { //Ownership is moved over foreach ($shares as $share) { - /** @var \OCP\Share\IShare $share */ + /** @var IShare $share */ $share->setShareOwner($newOwner); $shareManager->updateShare($share); } diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 9e7d8e5c693..5339128fbef 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -134,7 +134,7 @@ class ApiTest extends TestCase { public function testCreateShareUserFile() { $this->setUp(); // for some reasons phpunit refuses to do this for us only for this test $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -151,7 +151,7 @@ class ApiTest extends TestCase { public function testCreateShareUserFolder() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -168,7 +168,7 @@ class ApiTest extends TestCase { public function testCreateShareGroupFile() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -184,7 +184,7 @@ class ApiTest extends TestCase { public function testCreateShareGroupFolder() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -200,7 +200,7 @@ class ApiTest extends TestCase { public function testCreateShareLink() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $data = $result->getData(); @@ -223,7 +223,7 @@ class ApiTest extends TestCase { public function testCreateShareLinkPublicUpload() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); $ocs->cleanup(); $data = $result->getData(); @@ -256,7 +256,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $this->fail(); } catch (OCSForbiddenException $e) { } @@ -264,7 +264,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', ''); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', ''); $this->fail(); } catch (OCSForbiddenException $e) { } @@ -272,7 +272,7 @@ class ApiTest extends TestCase { // share with password should succeed $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', $password); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', $password); $ocs->cleanup(); $data = $result->getData(); @@ -309,7 +309,7 @@ class ApiTest extends TestCase { \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -325,7 +325,7 @@ class ApiTest extends TestCase { \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -340,7 +340,7 @@ class ApiTest extends TestCase { \OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group'); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); // cleanup @@ -361,7 +361,7 @@ class ApiTest extends TestCase { $share->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share = $this->shareManager->createShare($share); @@ -381,7 +381,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -392,7 +392,7 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -413,7 +413,7 @@ class ApiTest extends TestCase { */ public function testPublicLinkUrl() { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $data = $result->getData(); @@ -466,14 +466,14 @@ class ApiTest extends TestCase { $share->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share); $share = $this->shareManager->newShare(); $share->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share); @@ -499,7 +499,7 @@ class ApiTest extends TestCase { $share1->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -507,7 +507,7 @@ class ApiTest extends TestCase { $share2->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share2 = $this->shareManager->createShare($share2); @@ -540,7 +540,7 @@ class ApiTest extends TestCase { $share1->setNode($node) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -564,7 +564,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -572,7 +572,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); @@ -594,7 +594,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); @@ -620,7 +620,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -630,7 +630,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -640,7 +640,7 @@ class ApiTest extends TestCase { $share3 = $this->shareManager->newShare(); $share3->setNode($node3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); $share3->setStatus(IShare::STATUS_ACCEPTED); @@ -680,7 +680,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -690,7 +690,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -722,7 +722,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); @@ -731,14 +731,14 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); $share3 = $this->shareManager->newShare(); $share3->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); @@ -800,7 +800,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -811,7 +811,7 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -820,7 +820,7 @@ class ApiTest extends TestCase { $share3 = $this->shareManager->newShare(); $share3->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); $share3->setStatus(IShare::STATUS_ACCEPTED); @@ -864,7 +864,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -876,7 +876,7 @@ class ApiTest extends TestCase { $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -887,7 +887,7 @@ class ApiTest extends TestCase { $share3 = $this->shareManager->newShare(); $share3->setNode($node3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER3) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); $share3->setStatus(IShare::STATUS_ACCEPTED); @@ -937,14 +937,14 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); $share2 = $this->shareManager->newShare(); $share2->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); @@ -985,7 +985,7 @@ class ApiTest extends TestCase { $share1 = $this->shareManager->newShare(); $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share1 = $this->shareManager->createShare($share1); @@ -1016,7 +1016,7 @@ class ApiTest extends TestCase { $share1 = $this->shareManager->newShare(); $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -1089,14 +1089,14 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(19); $share1 = $this->shareManager->createShare($share1); $share2 = $this->shareManager->newShare(); $share2->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share1); @@ -1108,8 +1108,8 @@ class ApiTest extends TestCase { $ocs->deleteShare($share2->getId()); $ocs->cleanup(); - $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER)); - $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_LINK)); + $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER)); + $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_LINK)); } /** @@ -1121,7 +1121,7 @@ class ApiTest extends TestCase { $share1->setNode($node1) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(31); $share1 = $this->shareManager->createShare($share1); $share1->setStatus(IShare::STATUS_ACCEPTED); @@ -1132,7 +1132,7 @@ class ApiTest extends TestCase { $share2 = $this->shareManager->newShare(); $share2->setNode($node2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(1); $share2 = $this->shareManager->createShare($share2); $share2->setStatus(IShare::STATUS_ACCEPTED); @@ -1155,7 +1155,7 @@ class ApiTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -1182,7 +1182,7 @@ class ApiTest extends TestCase { $pass = true; try { $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, 'localDir', self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER3, @@ -1229,7 +1229,7 @@ class ApiTest extends TestCase { // user 1 shares the mount point folder with user2 $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -1274,7 +1274,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date); $this->assertTrue($valid); } catch (OCSNotFoundException $e) { $this->assertFalse($valid); @@ -1310,7 +1310,7 @@ class ApiTest extends TestCase { $date->add(new \DateInterval('P5D')); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); + $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); $ocs->cleanup(); $data = $result->getData(); @@ -1344,7 +1344,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); $this->fail(); } catch (OCSException $e) { $this->assertEquals(404, $e->getCode()); @@ -1365,7 +1365,7 @@ class ApiTest extends TestCase { $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); try { - $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); + $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d')); $this->fail(); } catch (OCSException $e) { $this->assertEquals(404, $e->getCode()); @@ -1384,7 +1384,7 @@ class ApiTest extends TestCase { public function testInvisibleSharesUser() { // simulate a post request $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $ocs->cleanup(); $data = $result->getData(); @@ -1395,7 +1395,7 @@ class ApiTest extends TestCase { $ocs->cleanup(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); @@ -1416,7 +1416,7 @@ class ApiTest extends TestCase { public function testInvisibleSharesGroup() { // simulate a post request $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); - $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); + $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1); $ocs->cleanup(); $data = $result->getData(); @@ -1429,7 +1429,7 @@ class ApiTest extends TestCase { \OC_Util::tearDownFS(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2); - $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); $ocs->cleanup(); $ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1); diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 09fc9f6f5a7..7b80bfcaaae 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -100,7 +100,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('container/shareddir'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -111,7 +111,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('container/shared single file.txt'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE)); @@ -135,7 +135,7 @@ class CacheTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER); foreach ($shares as $share) { $this->shareManager->deleteShare($share); } @@ -312,7 +312,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('container/shareddir/subdir'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -398,7 +398,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('test.txt'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); @@ -431,7 +431,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('foo'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -460,7 +460,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('foo'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -497,7 +497,7 @@ class CacheTest extends TestCase { $node = $rootFolder->get('foo/sub'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 577f574f8ed..e186092f0bf 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -52,7 +52,6 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\Lock\LockedException; -use OCP\Share; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\IManager; use OCP\Share\IShare; @@ -260,7 +259,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setSharedWith($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setNode($node); $this->shareManager @@ -355,7 +354,7 @@ class ShareAPIControllerTest extends TestCase { $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group') ->setNode($node); @@ -417,7 +416,7 @@ class ShareAPIControllerTest extends TestCase { $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group') ->setNode($node); @@ -504,9 +503,9 @@ class ShareAPIControllerTest extends TestCase { $share->method('getToken')->willReturn($token); $share->method('getPassword')->willReturn($password); - if ($shareType === \OCP\Share::SHARE_TYPE_USER || - $shareType === \OCP\Share::SHARE_TYPE_GROUP || - $shareType === \OCP\Share::SHARE_TYPE_LINK) { + if ($shareType === IShare::TYPE_USER || + $shareType === IShare::TYPE_GROUP || + $shareType === IShare::TYPE_LINK) { $share->method('getFullId')->willReturn('ocinternal:'.$id); } @@ -547,7 +546,7 @@ class ShareAPIControllerTest extends TestCase { // File shared with user $share = $this->createShare( 100, - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, 'userId', 'initiatorId', 'ownerId', @@ -562,7 +561,7 @@ class ShareAPIControllerTest extends TestCase { ); $expected = [ 'id' => 100, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'share_with' => 'userId', 'share_with_displayname' => 'userDisplay', 'uid_owner' => 'initiatorId', @@ -595,7 +594,7 @@ class ShareAPIControllerTest extends TestCase { // Folder shared with group $share = $this->createShare( 101, - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'groupId', 'initiatorId', 'ownerId', @@ -610,7 +609,7 @@ class ShareAPIControllerTest extends TestCase { ); $expected = [ 'id' => 101, - 'share_type' => \OCP\Share::SHARE_TYPE_GROUP, + 'share_type' => IShare::TYPE_GROUP, 'share_with' => 'groupId', 'share_with_displayname' => 'groupId', 'uid_owner' => 'initiatorId', @@ -644,7 +643,7 @@ class ShareAPIControllerTest extends TestCase { $expire = \DateTime::createFromFormat('Y-m-d h:i:s', '2000-01-02 01:02:03'); $share = $this->createShare( 101, - \OCP\Share::SHARE_TYPE_LINK, + IShare::TYPE_LINK, null, 'initiatorId', 'ownerId', @@ -662,7 +661,7 @@ class ShareAPIControllerTest extends TestCase { ); $expected = [ 'id' => 101, - 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'share_type' => IShare::TYPE_LINK, 'password' => 'password', 'share_with' => 'password', 'share_with_displayname' => '(Shared link)', @@ -1405,7 +1404,7 @@ class ShareAPIControllerTest extends TestCase { $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $share->method('getSharedWith')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); @@ -1425,18 +1424,18 @@ class ShareAPIControllerTest extends TestCase { // getPermissions -> share $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); // getPermissions -> read $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); + $share->method('getShareType')->willReturn(IShare::TYPE_USER); $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->getMockBuilder(IShare::class)->getMock(); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); $share->method('getSharedWith')->willReturn('group'); $user = $this->createMock(IUser::class); @@ -1457,18 +1456,18 @@ class ShareAPIControllerTest extends TestCase { $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); $share->method('getSharedWith')->willReturn('group2'); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); // null group $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); + $share->method('getShareType')->willReturn(IShare::TYPE_GROUP); $share->method('getSharedWith')->willReturn('groupnull'); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK); + $share->method('getShareType')->willReturn(IShare::TYPE_LINK); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); } @@ -1476,7 +1475,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; $share = $this->createMock(IShare::class); - $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_ROOM); + $share->method('getShareType')->willReturn(IShare::TYPE_ROOM); $share->method('getSharedWith')->willReturn('recipientRoom'); $result[] = [ @@ -1623,7 +1622,7 @@ class ShareAPIControllerTest extends TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER); } @@ -1657,7 +1656,7 @@ class ShareAPIControllerTest extends TestCase { ->with('invalidUser') ->willReturn(false); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'invalidUser'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'invalidUser'); } public function testCreateShareUser() { @@ -1713,14 +1712,14 @@ class ShareAPIControllerTest extends TestCase { ~\OCP\Constants::PERMISSION_DELETE & ~\OCP\Constants::PERMISSION_CREATE ) && - $share->getShareType() === \OCP\Share::SHARE_TYPE_USER && + $share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() === 'validUser' && $share->getSharedBy() === 'currentUser'; })) ->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1757,7 +1756,7 @@ class ShareAPIControllerTest extends TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup'); } public function testCreateShareGroup() { @@ -1787,7 +1786,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturnMap([ ['path', null, 'valid-path'], ['permissions', null, \OCP\Constants::PERMISSION_ALL], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP], + ['shareType', '-1', IShare::TYPE_GROUP], ['shareWith', null, 'validGroup'], ]); @@ -1822,14 +1821,14 @@ class ShareAPIControllerTest extends TestCase { ->with($this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && $share->getPermissions() === \OCP\Constants::PERMISSION_ALL && - $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && + $share->getShareType() === IShare::TYPE_GROUP && $share->getSharedWith() === 'validGroup' && $share->getSharedBy() === 'currentUser'; })) ->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'validGroup'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'validGroup'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1866,7 +1865,7 @@ class ShareAPIControllerTest extends TestCase { ->method('allowGroupSharing') ->willReturn(false); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup'); } @@ -1878,7 +1877,7 @@ class ShareAPIControllerTest extends TestCase { ->method('getParam') ->willReturnMap([ ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], + ['shareType', '-1', IShare::TYPE_LINK], ]); $path = $this->getMockBuilder(Folder::class)->getMock(); @@ -1892,7 +1891,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK); } @@ -1912,7 +1911,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare()); $this->shareManager->method('shareApiAllowLinks')->willReturn(true); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); } @@ -1933,7 +1932,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); + $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true'); } public function testCreateShareLinkPublicUploadFolder() { @@ -1955,7 +1954,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once())->method('createShare')->with( $this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) && $share->getSharedBy() === 'currentUser' && $share->getPassword() === null && @@ -1964,7 +1963,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true', '', null, ''); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true', '', null, ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -1989,7 +1988,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once())->method('createShare')->with( $this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === \OCP\Constants::PERMISSION_READ && $share->getSharedBy() === 'currentUser' && $share->getPassword() === 'password' && @@ -1998,7 +1997,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', null, ''); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', null, ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2025,7 +2024,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once())->method('createShare')->with( $this->callback(function (\OCP\Share\IShare $share) use ($path) { return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === \OCP\Constants::PERMISSION_READ && $share->getSharedBy() === 'currentUser' && $share->getPassword() === 'password' && @@ -2035,7 +2034,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', ''); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', ''); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2066,7 +2065,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never())->method('createShare'); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', ''); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', ''); } public function testCreateShareValidExpireDate() { @@ -2076,7 +2075,7 @@ class ShareAPIControllerTest extends TestCase { ->method('getParam') ->willReturnMap([ ['path', null, 'valid-path'], - ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], + ['shareType', '-1', IShare::TYPE_LINK], ['publicUpload', null, 'false'], ['expireDate', '', '2000-01-01'], ['password', '', ''], @@ -2101,7 +2100,7 @@ class ShareAPIControllerTest extends TestCase { $date->setTime(0,0,0); return $share->getNode() === $path && - $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + $share->getShareType() === IShare::TYPE_LINK && $share->getPermissions() === \OCP\Constants::PERMISSION_READ && $share->getSharedBy() === 'currentUser' && $share->getPassword() === null && @@ -2110,7 +2109,7 @@ class ShareAPIControllerTest extends TestCase { )->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, '2000-01-01'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, '2000-01-01'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2136,7 +2135,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('shareApiAllowLinks')->willReturn(true); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, 'a1b2d3'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, 'a1b2d3'); } public function testCreateShareRoom() { @@ -2204,14 +2203,14 @@ class ShareAPIControllerTest extends TestCase { ~\OCP\Constants::PERMISSION_DELETE & ~\OCP\Constants::PERMISSION_CREATE ) && - $share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM && + $share->getShareType() === IShare::TYPE_ROOM && $share->getSharedWith() === 'recipientRoom' && $share->getSharedBy() === 'currentUser'; })) ->willReturnArgument(0); $expected = new DataResponse([]); - $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); + $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom'); $this->assertInstanceOf(get_class($expected), $result); $this->assertEquals($expected->getData(), $result->getData()); @@ -2255,7 +2254,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never())->method('createShare'); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom'); } @@ -2316,7 +2315,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never())->method('createShare'); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom'); } /** @@ -2373,7 +2372,7 @@ class ShareAPIControllerTest extends TestCase { })) ->willReturnArgument(0); - $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); + $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser'); } @@ -2412,7 +2411,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($node); $node->expects($this->once()) @@ -2433,7 +2432,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setNode($node); $node->expects($this->once()) @@ -2454,7 +2453,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setExpirationDate(new \DateTime()) ->setNote('note') @@ -2517,7 +2516,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2575,7 +2574,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setNode($folder); @@ -2625,7 +2624,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2664,7 +2663,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2685,7 +2684,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setNode($file); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -2704,7 +2703,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -2749,7 +2748,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(false) ->setExpirationDate($date) @@ -2800,7 +2799,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(false) ->setExpirationDate($date) @@ -2833,7 +2832,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -2883,7 +2882,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -2951,7 +2950,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate(new \DateTime()) @@ -3016,7 +3015,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -3078,7 +3077,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -3139,7 +3138,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPassword('password') ->setSendPasswordByTalk(true) ->setExpirationDate($date) @@ -3198,7 +3197,7 @@ class ShareAPIControllerTest extends TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setNode($file); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); @@ -3246,7 +3245,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner('anotheruser') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3258,7 +3257,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner('anotheruser') - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3274,9 +3273,9 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('getSharedWith') ->willReturnMap([ - ['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []], - ['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]], - ['currentUser', \OCP\Share::SHARE_TYPE_ROOM, $share->getNode(), -1, 0, []] + ['currentUser', IShare::TYPE_USER, $share->getNode(), -1, 0, []], + ['currentUser', IShare::TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]], + ['currentUser', IShare::TYPE_ROOM, $share->getNode(), -1, 0, []] ]); $userFolder = $this->createMock(Folder::class); @@ -3319,7 +3318,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3331,7 +3330,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42) ->setSharedBy($this->currentUser) ->setShareOwner($this->currentUser) - ->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + ->setShareType(IShare::TYPE_GROUP) ->setSharedWith('group1') ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); @@ -3341,8 +3340,8 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('getSharedWith') ->willReturnMap([ - ['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []], - ['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]] + ['currentUser', IShare::TYPE_USER, $share->getNode(), -1, 0, []], + ['currentUser', IShare::TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]] ]); $this->shareManager->expects($this->once()) @@ -3406,7 +3405,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3421,7 +3420,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3454,7 +3453,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiatorDN', 'permissions' => 1, @@ -3489,7 +3488,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3503,7 +3502,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3534,7 +3533,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedWith('recipient') ->setSharedBy('initiator') ->setShareOwner('currentUser') @@ -3548,7 +3547,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_USER, + 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3581,7 +3580,7 @@ class ShareAPIControllerTest extends TestCase { // with existing group $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipientGroup') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3595,7 +3594,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_GROUP, + 'share_type' => IShare::TYPE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3627,7 +3626,7 @@ class ShareAPIControllerTest extends TestCase { // with unknown group / no group backend $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(Share::SHARE_TYPE_GROUP) + $share->setShareType(IShare::TYPE_GROUP) ->setSharedWith('recipientGroup2') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -3640,7 +3639,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => Share::SHARE_TYPE_GROUP, + 'share_type' => IShare::TYPE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3671,7 +3670,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setSharedBy('initiator') ->setShareOwner('owner') ->setPermissions(\OCP\Constants::PERMISSION_READ) @@ -3688,7 +3687,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'share_type' => IShare::TYPE_LINK, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3722,7 +3721,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + $share->setShareType(IShare::TYPE_LINK) ->setSharedBy('initiator') ->setShareOwner('owner') ->setPermissions(\OCP\Constants::PERMISSION_READ) @@ -3740,7 +3739,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_LINK, + 'share_type' => IShare::TYPE_LINK, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3774,7 +3773,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_REMOTE) + $share->setShareType(IShare::TYPE_REMOTE) ->setSharedBy('initiator') ->setSharedWith('user@server.com') ->setShareOwner('owner') @@ -3788,7 +3787,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_REMOTE, + 'share_type' => IShare::TYPE_REMOTE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3820,7 +3819,7 @@ class ShareAPIControllerTest extends TestCase { // Circle with id, display name and avatar set by the Circles app $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE) + $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]') ->setSharedWithDisplayName('The display name') @@ -3835,7 +3834,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE, + 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3868,7 +3867,7 @@ class ShareAPIControllerTest extends TestCase { // Circle with id set by the Circles app $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE) + $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]') ->setShareOwner('owner') @@ -3881,7 +3880,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE, + 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3914,7 +3913,7 @@ class ShareAPIControllerTest extends TestCase { // Circle with id not set by the Circles app $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE) + $share->setShareType(IShare::TYPE_CIRCLE) ->setSharedBy('initiator') ->setSharedWith('Circle (Public circle, circleOwner)') ->setShareOwner('owner') @@ -3927,7 +3926,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE, + 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -3959,7 +3958,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setSharedBy('initiator') ->setSharedWith('recipient') ->setShareOwner('owner') @@ -3974,7 +3973,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $share->setShareType(IShare::TYPE_EMAIL) ->setSharedBy('initiator') ->setSharedWith('user@server.com') ->setShareOwner('owner') @@ -3988,7 +3987,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_EMAIL, + 'share_type' => IShare::TYPE_EMAIL, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -4021,7 +4020,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL) + $share->setShareType(IShare::TYPE_EMAIL) ->setSharedBy('initiator') ->setSharedWith('user@server.com') ->setShareOwner('owner') @@ -4036,7 +4035,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_EMAIL, + 'share_type' => IShare::TYPE_EMAIL, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -4167,7 +4166,7 @@ class ShareAPIControllerTest extends TestCase { $result = []; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_ROOM) + $share->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipientRoom') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -4181,7 +4180,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_ROOM, + 'share_type' => IShare::TYPE_ROOM, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, @@ -4212,7 +4211,7 @@ class ShareAPIControllerTest extends TestCase { ]; $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_ROOM) + $share->setShareType(IShare::TYPE_ROOM) ->setSharedWith('recipientRoom') ->setSharedBy('initiator') ->setShareOwner('owner') @@ -4226,7 +4225,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ 'id' => 42, - 'share_type' => \OCP\Share::SHARE_TYPE_ROOM, + 'share_type' => IShare::TYPE_ROOM, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', 'permissions' => 1, diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index 7beb4058c4f..8939198d4a8 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -38,7 +38,7 @@ use OCP\Collaboration\Collaborators\ISearch; use OCP\IConfig; use OCP\IRequest; use OCP\IURLGenerator; -use OCP\Share; +use OCP\Share\IShare; use OCP\Share\IManager; /** @@ -91,8 +91,8 @@ class ShareesAPIControllerTest extends TestCase { } public function dataSearch() { - $noRemote = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_EMAIL]; - $allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_REMOTE_GROUP, Share::SHARE_TYPE_EMAIL]; + $noRemote = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_EMAIL]; + $allTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_REMOTE_GROUP, IShare::TYPE_EMAIL]; return [ [[], '', 'yes', true, true, true, $noRemote, false, true, true], @@ -293,7 +293,7 @@ class ShareesAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('shareProviderExists') ->willReturnCallback(function ($shareType) use ($emailSharingEnabled) { - if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { + if ($shareType === \OCP\IShare::TYPE_EMAIL) { return $emailSharingEnabled; } else { return false; diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php index f081c947f53..3936a3b9da2 100644 --- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php +++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php @@ -27,6 +27,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\DeleteOrphanedSharesJob; +use OCP\Share\IShare; /** * Class DeleteOrphanedSharesJobTest @@ -138,7 +139,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setNode($testSubFolder) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setSharedWith($this->user2) ->setSharedBy($this->user1); diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php index 081b720f820..ee2f5b204e3 100644 --- a/apps/files_sharing/tests/EtagPropagationTest.php +++ b/apps/files_sharing/tests/EtagPropagationTest.php @@ -31,6 +31,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; +use OCP\Share\IShare; /** * Class EtagPropagationTest @@ -75,7 +76,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/foo.txt'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); @@ -86,7 +87,7 @@ class EtagPropagationTest extends PropagationTestCase { $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -95,7 +96,7 @@ class EtagPropagationTest extends PropagationTestCase { $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER3) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -109,7 +110,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/directReshare'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -134,7 +135,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/sub1/sub2/folder/inside'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER4) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -148,7 +149,7 @@ class EtagPropagationTest extends PropagationTestCase { ->get('/directReshare'); $share = $shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER4) ->setSharedBy(self::TEST_FILES_SHARING_API_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -284,7 +285,7 @@ class EtagPropagationTest extends PropagationTestCase { $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder'); $shareManager = \OC::$server->getShareManager(); - $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true); + $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node, true); foreach ($shares as $share) { if ($share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2) { @@ -307,7 +308,7 @@ class EtagPropagationTest extends PropagationTestCase { $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder/inside'); $shareManager = \OC::$server->getShareManager(); - $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true); + $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node, true); foreach ($shares as $share) { $shareManager->deleteShare($share); @@ -455,7 +456,7 @@ class EtagPropagationTest extends PropagationTestCase { $userFolder = $this->rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1); $node = $userFolder->get('/sub1/sub2/folder'); - $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node); /** @var \OCP\Share\IShare[] $shares */ $shares = array_filter($shares, function (\OCP\Share\IShare $share) { return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2; diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php index 1854ce4990c..219a91a2829 100644 --- a/apps/files_sharing/tests/ExpireSharesJobTest.php +++ b/apps/files_sharing/tests/ExpireSharesJobTest.php @@ -25,6 +25,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\ExpireSharesJob; +use OCP\Share\IShare; /** * Class ExpireSharesJobTest @@ -140,7 +141,7 @@ class ExpireSharesJobTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setNode($testFolder) - ->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setShareType(IShare::TYPE_LINK) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setSharedBy($this->user1); @@ -197,7 +198,7 @@ class ExpireSharesJobTest extends \Test\TestCase { $share = $shareManager->newShare(); $share->setNode($testFolder) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setSharedBy($this->user1) ->setSharedWith($this->user2); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 5807c3e9fd5..d6fab64dc67 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -39,6 +39,7 @@ use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\IGroupManager; use OCP\IUserManager; +use OCP\Share\IShare; use Test\Traits\UserTrait; /** @@ -130,7 +131,7 @@ class ManagerTest extends TestCase { 'password' => '', 'name' => '/SharedFolder', 'owner' => 'foobar', - 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareType' => IShare::TYPE_USER, 'accepted' => false, 'user' => $this->uid, ]; diff --git a/apps/files_sharing/tests/GroupEtagPropagationTest.php b/apps/files_sharing/tests/GroupEtagPropagationTest.php index 5232a536259..ba688f70263 100644 --- a/apps/files_sharing/tests/GroupEtagPropagationTest.php +++ b/apps/files_sharing/tests/GroupEtagPropagationTest.php @@ -28,6 +28,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; +use OCP\Share\IShare; /** * @group SLOWDB @@ -53,7 +54,7 @@ class GroupEtagPropagationTest extends PropagationTestCase { $view1->mkdir('/test/sub'); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, '/test', self::TEST_FILES_SHARING_API_USER1, 'group1', @@ -68,7 +69,7 @@ class GroupEtagPropagationTest extends PropagationTestCase { $view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, '/test', self::TEST_FILES_SHARING_API_USER2, 'group2', @@ -76,7 +77,7 @@ class GroupEtagPropagationTest extends PropagationTestCase { ); $this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER3); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, '/test/sub', self::TEST_FILES_SHARING_API_USER2, 'group3', diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php index c6a799f64a6..680220e5fa5 100644 --- a/apps/files_sharing/tests/LockingTest.php +++ b/apps/files_sharing/tests/LockingTest.php @@ -29,6 +29,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\Filesystem; use OC\Files\View; use OCP\Lock\ILockingProvider; +use OCP\Share\IShare; /** * Class LockingTest @@ -63,7 +64,7 @@ class LockingTest extends TestCase { $fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId(); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, '/foo/bar.txt', $this->ownerUid, $this->recipientUid, @@ -79,7 +80,7 @@ class LockingTest extends TestCase { parent::tearDown(); } - + public function testLockAsRecipient() { $this->expectException(\OCP\Lock\LockedException::class); diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index 0a1737ba37f..cdba86863f1 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -28,7 +28,7 @@ use OCA\Files_Sharing\Migration\SetPasswordColumn; use OCA\Files_Sharing\Tests\TestCase; use OCP\IConfig; use OCP\Migration\IOutput; -use OCP\Share; +use OCP\Share\IShare; /** * Class SetPasswordColumnTest @@ -74,7 +74,7 @@ class SetPasswordColumnTest extends TestCase { ->with('files_sharing', 'installed_version', '0.0.0') ->willReturn('1.3.0'); - $shareTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL, Share::SHARE_TYPE_LINK]; + $shareTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_EMAIL, IShare::TYPE_LINK]; foreach ($shareTypes as $shareType) { for ($i = 0; $i < 5; $i++) { @@ -109,7 +109,7 @@ class SetPasswordColumnTest extends TestCase { $allShares = $query->execute()->fetchAll(); foreach ($allShares as $share) { - if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) { + if ((int)$share['share_type'] === IShare::TYPE_LINK) { $this->assertNull($share['share_with']); $this->assertSame('shareWith', $share['password']); } else { diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index ec52db8542e..60c622ec4a4 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -129,19 +129,19 @@ class MountProviderTest extends \Test\TestCase { ->willReturn('user1'); $this->shareManager->expects($this->at(0)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_USER) + ->with('user1', IShare::TYPE_USER) ->willReturn($userShares); $this->shareManager->expects($this->at(1)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1) + ->with('user1', IShare::TYPE_GROUP, null, -1) ->willReturn($groupShares); $this->shareManager->expects($this->at(2)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1) + ->with('user1', IShare::TYPE_CIRCLE, null, -1) ->willReturn($circleShares); $this->shareManager->expects($this->at(3)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1) + ->with('user1', IShare::TYPE_ROOM, null, -1) ->willReturn($roomShares); $this->shareManager->expects($this->any()) ->method('newShare') @@ -338,19 +338,19 @@ class MountProviderTest extends \Test\TestCase { $roomShares = []; $this->shareManager->expects($this->at(0)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_USER) + ->with('user1', IShare::TYPE_USER) ->willReturn($userShares); $this->shareManager->expects($this->at(1)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1) + ->with('user1', IShare::TYPE_GROUP, null, -1) ->willReturn($groupShares); $this->shareManager->expects($this->at(2)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1) + ->with('user1', IShare::TYPE_CIRCLE, null, -1) ->willReturn($circleShares); $this->shareManager->expects($this->at(3)) ->method('getSharedWith') - ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1) + ->with('user1', IShare::TYPE_ROOM, null, -1) ->willReturn($roomShares); $this->shareManager->expects($this->any()) ->method('newShare') diff --git a/apps/files_sharing/tests/PermissionsTest.php b/apps/files_sharing/tests/PermissionsTest.php index 30c6c2a73d2..64dad207382 100644 --- a/apps/files_sharing/tests/PermissionsTest.php +++ b/apps/files_sharing/tests/PermissionsTest.php @@ -86,7 +86,7 @@ class PermissionsTest extends TestCase { $node = $rootFolder->get('container/shareddir'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -97,7 +97,7 @@ class PermissionsTest extends TestCase { $node = $rootFolder->get('container/shareddirrestricted'); $share = $this->shareManager->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE); @@ -123,7 +123,7 @@ class PermissionsTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER); foreach ($shares as $share) { $this->shareManager->deleteShare($share); } diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php index ba6b401e65e..3b695493c23 100644 --- a/apps/files_sharing/tests/ShareTest.php +++ b/apps/files_sharing/tests/ShareTest.php @@ -28,6 +28,8 @@ namespace OCA\Files_Sharing\Tests; +use OCP\Share\IShare; + /** * Class ShareTest * @@ -77,7 +79,7 @@ class ShareTest extends TestCase { $testGroup->addUser($user2); $share1 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -85,7 +87,7 @@ class ShareTest extends TestCase { ); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', @@ -131,7 +133,7 @@ class ShareTest extends TestCase { $folderinfo = $this->view->getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -141,7 +143,7 @@ class ShareTest extends TestCase { \OCA\Files_Sharing\Helper::setShareFolder('/Shared/subfolder'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -164,7 +166,7 @@ class ShareTest extends TestCase { \OC\Files\Filesystem::file_put_contents('test.txt', 'test'); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'test.txt', self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_GROUP1, @@ -173,14 +175,14 @@ class ShareTest extends TestCase { $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP); $share = $shares[0]; $this->assertSame('/test.txt' ,$share->getTarget()); $this->assertSame(19, $share->getPermissions()); \OC\Files\Filesystem::rename('test.txt', 'new test.txt'); - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP); $share = $shares[0]; $this->assertSame('/new test.txt' ,$share->getTarget()); $this->assertSame(19, $share->getPermissions()); @@ -189,7 +191,7 @@ class ShareTest extends TestCase { $this->shareManager->updateShare($share); $this->loginHelper(self::TEST_FILES_SHARING_API_USER2); - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP); $share = $shares[0]; $this->assertSame('/new test.txt' ,$share->getTarget()); @@ -204,7 +206,7 @@ class ShareTest extends TestCase { $pass = true; try { $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -235,7 +237,7 @@ class ShareTest extends TestCase { public function testFileOwner() { $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php index 59c0e3b76af..c60039e321a 100644 --- a/apps/files_sharing/tests/SharedMountTest.php +++ b/apps/files_sharing/tests/SharedMountTest.php @@ -32,6 +32,7 @@ namespace OCA\Files_Sharing\Tests; use OCP\IGroupManager; use OCP\IUserManager; +use OCP\Share\IShare; /** * Class SharedMountTest @@ -84,7 +85,7 @@ class SharedMountTest extends TestCase { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -115,7 +116,7 @@ class SharedMountTest extends TestCase { public function testDeleteParentOfMountPoint() { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -154,7 +155,7 @@ class SharedMountTest extends TestCase { public function testMoveSharedFile() { $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -197,7 +198,7 @@ class SharedMountTest extends TestCase { $fileinfo = $this->view->getFileInfo($this->filename); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', @@ -351,7 +352,7 @@ class SharedMountTest extends TestCase { // Share item with group $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $path, self::TEST_FILES_SHARING_API_USER1, 'testGroup', @@ -415,7 +416,7 @@ class SharedMountTest extends TestCase { // Share item with group $fileinfo = $this->view->getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, $this->folder, self::TEST_FILES_SHARING_API_USER1, 'testGroup', diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 7d20d98585f..fb8207a3c1d 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -79,7 +79,7 @@ class SharedStorageTest extends TestCase { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -124,7 +124,7 @@ class SharedStorageTest extends TestCase { // share to user $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -164,7 +164,7 @@ class SharedStorageTest extends TestCase { $file2Size = $this->view->filesize($this->filename); $share1 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -172,7 +172,7 @@ class SharedStorageTest extends TestCase { ); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -194,7 +194,7 @@ class SharedStorageTest extends TestCase { public function testGetPermissions() { $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -226,7 +226,7 @@ class SharedStorageTest extends TestCase { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -259,7 +259,7 @@ class SharedStorageTest extends TestCase { $fileinfoFolder = $this->view->getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -298,7 +298,7 @@ class SharedStorageTest extends TestCase { //cleanup self::loginHelper(self::TEST_FILES_SHARING_API_USER1); - $result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, + $result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2); $this->assertTrue($result); } @@ -307,7 +307,7 @@ class SharedStorageTest extends TestCase { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -353,7 +353,7 @@ class SharedStorageTest extends TestCase { $this->view->file_put_contents($this->folder . '/existing.txt', 'foo'); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -387,14 +387,14 @@ class SharedStorageTest extends TestCase { // share 2 different files with 2 different users $share1 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL ); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER3, @@ -426,7 +426,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -459,7 +459,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -501,7 +501,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share1 = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'foo', self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_GROUP1, @@ -514,7 +514,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER3); $share2 = $this->share( - \OCP\Share::SHARE_TYPE_GROUP, + IShare::TYPE_GROUP, 'foo', self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_GROUP1, @@ -543,7 +543,7 @@ class SharedStorageTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_sharing/tests/SizePropagationTest.php b/apps/files_sharing/tests/SizePropagationTest.php index 93265f9310a..8496341e653 100644 --- a/apps/files_sharing/tests/SizePropagationTest.php +++ b/apps/files_sharing/tests/SizePropagationTest.php @@ -26,6 +26,7 @@ namespace OCA\Files_Sharing\Tests; use OC\Files\View; +use OCP\Share\IShare; use Test\Traits\UserTrait; /** @@ -54,7 +55,7 @@ class SizePropagationTest extends TestCase { $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar'); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, '/sharedfolder', self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER1, @@ -89,7 +90,7 @@ class SizePropagationTest extends TestCase { $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar'); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, '/sharedfolder', self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER1, diff --git a/apps/files_sharing/tests/UnshareChildrenTest.php b/apps/files_sharing/tests/UnshareChildrenTest.php index 3d0f13c7212..b9d06bb7fa4 100644 --- a/apps/files_sharing/tests/UnshareChildrenTest.php +++ b/apps/files_sharing/tests/UnshareChildrenTest.php @@ -28,6 +28,8 @@ namespace OCA\Files_Sharing\Tests; +use OCP\Share\IShare; + /** * Class UnshareChildrenTest * @@ -78,7 +80,7 @@ class UnshareChildrenTest extends TestCase { $fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -88,7 +90,7 @@ class UnshareChildrenTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // one folder should be shared with the user - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER); $this->assertCount(1, $shares); // move shared folder to 'localDir' @@ -101,7 +103,7 @@ class UnshareChildrenTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER2); // after the parent directory was deleted the share should be unshared - $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER); + $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER); $this->assertEmpty($shares); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php index 7f6f3172fcc..30efbac533d 100644 --- a/apps/files_sharing/tests/UpdaterTest.php +++ b/apps/files_sharing/tests/UpdaterTest.php @@ -31,6 +31,8 @@ namespace OCA\Files_Sharing\Tests; +use OCP\Share\IShare; + /** * Class UpdaterTest * @@ -82,7 +84,7 @@ class UpdaterTest extends TestCase { $this->assertTrue($fileinfo instanceof \OC\Files\FileInfo); $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -166,7 +168,7 @@ class UpdaterTest extends TestCase { $this->loginHelper(self::TEST_FILES_SHARING_API_USER1); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, @@ -202,7 +204,7 @@ class UpdaterTest extends TestCase { $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder); $share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, $this->folder, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php index e105bf16161..fc255753060 100644 --- a/apps/files_sharing/tests/WatcherTest.php +++ b/apps/files_sharing/tests/WatcherTest.php @@ -70,7 +70,7 @@ class WatcherTest extends TestCase { // share "shareddir" with user2 $this->_share = $this->share( - \OCP\Share::SHARE_TYPE_USER, + IShare::TYPE_USER, 'container/shareddir', self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index ec0c3d522aa..2efdf1b8958 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -45,6 +45,7 @@ use OCP\Files\Node; use OCP\ILogger; use OCP\IUserManager; use OCP\Lock\ILockingProvider; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -284,7 +285,7 @@ class StorageTest extends \Test\TestCase { $node = \OC::$server->getUserFolder($this->user)->get('share'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy($this->user) ->setSharedWith($recipientUser) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -338,7 +339,7 @@ class StorageTest extends \Test\TestCase { $node = \OC::$server->getUserFolder($this->user)->get('share'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy($this->user) ->setSharedWith($recipientUser) ->setPermissions(\OCP\Constants::PERMISSION_ALL); diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 136d8121cfa..7dfa93bb044 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -30,6 +30,7 @@ */ use OCA\Files_Sharing\AppInfo\Application; +use OCP\Share\IShare; /** * Class Test_Encryption @@ -223,7 +224,7 @@ class TrashbinTest extends \Test\TestCase { //share user1-4.txt with user2 $node = \OC::$server->getUserFolder(self::TEST_TRASHBIN_USER1)->get($folder); $share = \OC::$server->getShareManager()->newShare(); - $share->setShareType(\OCP\Share::SHARE_TYPE_USER) + $share->setShareType(IShare::TYPE_USER) ->setNode($node) ->setSharedBy(self::TEST_TRASHBIN_USER1) ->setSharedWith(self::TEST_TRASHBIN_USER2) diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 72fd313ac16..ffbf4e19f98 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -336,7 +336,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -403,7 +403,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -452,7 +452,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -519,7 +519,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('test.txt'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE); @@ -662,7 +662,7 @@ class VersioningTest extends \Test\TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_READ); @@ -700,7 +700,7 @@ class VersioningTest extends \Test\TestCase { $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); @@ -875,7 +875,7 @@ class VersioningTest extends \Test\TestCase { $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder'); $share = \OC::$server->getShareManager()->newShare(); $share->setNode($node) - ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setShareType(IShare::TYPE_USER) ->setSharedBy(self::TEST_VERSIONS_USER) ->setSharedWith(self::TEST_VERSIONS_USER2) ->setPermissions(\OCP\Constants::PERMISSION_ALL); diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 3a1a069172c..0f1afd43ba4 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -177,7 +177,7 @@ class ShareByMailProvider implements IShareProvider { /* * Check if file is not already shared with the remote user */ - $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_EMAIL, $share->getNode(), 1, 0); + $alreadyShared = $this->getSharedWith($shareWith, IShare::TYPE_EMAIL, $share->getNode(), 1, 0); if (!empty($alreadyShared)) { $message = 'Sharing %1$s failed, this item is already shared with %2$s'; $message_t = $this->l->t('Sharing %1$s failed, this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]); @@ -655,7 +655,7 @@ class ShareByMailProvider implements IShareProvider { $qb->select('*') ->from('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId()))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->orderBy('id'); $cursor = $qb->execute(); @@ -685,7 +685,7 @@ class ShareByMailProvider implements IShareProvider { protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload) { $qb = $this->dbConnection->getQueryBuilder(); $qb->insert('share') - ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)) + ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)) ->setValue('item_type', $qb->createNamedParameter($itemType)) ->setValue('item_source', $qb->createNamedParameter($itemSource)) ->setValue('file_source', $qb->createNamedParameter($itemSource)) @@ -794,7 +794,7 @@ class ShareByMailProvider implements IShareProvider { $qb->select('*') ->from('share'); - $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); + $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); /** * Reshares for this user are shares where they are the owner. @@ -851,7 +851,7 @@ class ShareByMailProvider implements IShareProvider { $qb->select('*') ->from('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); $cursor = $qb->execute(); $data = $cursor->fetch(); @@ -882,7 +882,7 @@ class ShareByMailProvider implements IShareProvider { $cursor = $qb->select('*') ->from('share') ->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId()))) - ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->execute(); $shares = []; @@ -915,7 +915,7 @@ class ShareByMailProvider implements IShareProvider { } $qb->setFirstResult($offset); - $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); + $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))); $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))); // Filter by node if provided @@ -946,7 +946,7 @@ class ShareByMailProvider implements IShareProvider { $cursor = $qb->select('*') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) ->execute(); @@ -1065,7 +1065,7 @@ class ShareByMailProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid))) ->execute(); } @@ -1122,7 +1122,7 @@ class ShareByMailProvider implements IShareProvider { $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->andWhere( - $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)) + $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)) ); /** @@ -1166,7 +1166,7 @@ class ShareByMailProvider implements IShareProvider { $qb = $this->dbConnection->getQueryBuilder(); $qb->select('share_with') ->from('share') - ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))) + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 2dc8ff9c953..61c76ea1f39 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -762,7 +762,7 @@ class ShareByMailProviderTest extends TestCase { $instance = $this->getInstance(['createShareObject']); $idMail = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token); - $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, '', \OCP\Share::SHARE_TYPE_LINK); + $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, '', IShare::TYPE_LINK); $this->assertTrue($idMail !== $idPublic); @@ -795,7 +795,7 @@ class ShareByMailProviderTest extends TestCase { $instance = $this->getInstance(['createShareObject']); $idMail = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token); - $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, "token2", '', \OCP\Share::SHARE_TYPE_LINK); + $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, "token2", '', IShare::TYPE_LINK); $this->assertTrue($idMail !== $idPublic); @@ -858,7 +858,7 @@ class ShareByMailProviderTest extends TestCase { $instance = $this->getInstance(); - $instance->userDeleted($uidOwner, \OCP\Share::SHARE_TYPE_EMAIL); + $instance->userDeleted($uidOwner, IShare::TYPE_EMAIL); $query = $this->connection->getQueryBuilder(); $query->select('*')->from('share'); @@ -913,7 +913,7 @@ class ShareByMailProviderTest extends TestCase { $this->invokePrivate($instance, 'getRawShare', [$id+1]); } - private function createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $note='', $shareType = \OCP\Share::SHARE_TYPE_EMAIL) { + private function createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $note='', $shareType = IShare::TYPE_EMAIL) { $qb = $this->connection->getQueryBuilder(); $qb->insert('share') ->setValue('share_type', $qb->createNamedParameter($shareType)) |