summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-24 16:49:16 +0200
committerJoas Schilling <coding@schilljs.com>2020-06-24 16:49:16 +0200
commit89ed2c37bf656ceb772bb6759c8977a7dc78b3fb (patch)
tree4a467f829fcc748531cad54e7c08e06dd98d1b7d /apps/federatedfilesharing
parent654cd18864c943d9ff93c2e6151bb6529fa44513 (diff)
downloadnextcloud-server-89ed2c37bf656ceb772bb6759c8977a7dc78b3fb.tar.gz
nextcloud-server-89ed2c37bf656ceb772bb6759c8977a7dc78b3fb.zip
Update share type constant usage
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/federatedfilesharing')
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php12
-rw-r--r--apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php14
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php51
3 files changed, 39 insertions, 38 deletions
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);