diff options
author | Joas Schilling <coding@schilljs.com> | 2020-06-24 16:49:16 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-06-24 16:49:16 +0200 |
commit | 89ed2c37bf656ceb772bb6759c8977a7dc78b3fb (patch) | |
tree | 4a467f829fcc748531cad54e7c08e06dd98d1b7d /apps/files_sharing/lib | |
parent | 654cd18864c943d9ff93c2e6151bb6529fa44513 (diff) | |
download | nextcloud-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/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/Controller/DeletedShareAPIController.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/lib/ExpireSharesJob.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 14 | ||||
-rw-r--r-- | apps/files_sharing/lib/Migration/OwncloudGuestShareType.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/Migration/SetPasswordColumn.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/MountProvider.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/lib/ShareBackend/File.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/lib/Updater.php | 10 |
9 files changed, 35 insertions, 30 deletions
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); } |