From 278a73789e777d2ba00fb7d8b311923a590f10fc Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 23 Mar 2021 14:47:10 +0100 Subject: Map old account scope properties to new names Use new scope values in settings page. Adjust all consumers to use the new constants. Map old scope values to new ones in account property getter. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/Controller/ShareController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 31f13ee2756..7e83ffaa7dc 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -343,7 +343,7 @@ class ShareController extends AuthPublicShareController { $ownerAccount = $this->accountManager->getAccount($owner); $ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); - if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) { + if ($ownerName->getScope() === IAccountManager::SCOPE_PUBLISHED) { $shareTmpl['owner'] = $owner->getUID(); $shareTmpl['shareOwner'] = $owner->getDisplayName(); } -- cgit v1.2.3 From 74a7c2eefc60f6cb08f8a04ed6f785d8177d3a63 Mon Sep 17 00:00:00 2001 From: J0WI Date: Mon, 12 Apr 2021 22:53:34 +0200 Subject: Use correct getSystemValue type Signed-off-by: J0WI --- apps/files_sharing/lib/Controller/ShareesAPIController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 131fe918530..ed809e7658d 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -144,7 +144,7 @@ class ShareesAPIController extends OCSController { public function search(string $search = '', string $itemType = null, int $page = 1, int $perPage = 200, $shareType = null, bool $lookup = true): DataResponse { // only search for string larger than a given threshold - $threshold = (int)$this->config->getSystemValue('sharing.minSearchStringLength', 0); + $threshold = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0); if (strlen($search) < $threshold) { return new DataResponse($this->result); } -- cgit v1.2.3 From 8680bafc5c791153488dd32108f4a7d0969edb8c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 25 Jan 2021 15:26:16 +0100 Subject: Implement expiration date for federated shares Add expiration date field in UI. Save expiration date when creating or updating federated share. Read expiration date from DB in federated share provider. Applies to both federated user and group shares. Signed-off-by: Vincent Petry --- .../lib/Controller/ShareAPIController.php | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 922623aa46f..f3b0467fa14 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -587,15 +587,39 @@ class ShareAPIController extends OCSController { throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$path->getPath(), $shareType])); } + if ($shareWith === null) { + throw new OCSNotFoundException($this->l->t('Please specify a valid federated user id')); + } + $share->setSharedWith($shareWith); $share->setPermissions($permissions); + if ($expireDate !== '') { + try { + $expireDate = $this->parseDate($expireDate); + $share->setExpirationDate($expireDate); + } catch (\Exception $e) { + throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD')); + } + } } elseif ($shareType === IShare::TYPE_REMOTE_GROUP) { if (!$this->shareManager->outgoingServer2ServerGroupSharesAllowed()) { throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$path->getPath(), $shareType])); } + if ($shareWith === null) { + throw new OCSNotFoundException($this->l->t('Please specify a valid federated group id')); + } + $share->setSharedWith($shareWith); $share->setPermissions($permissions); + if ($expireDate !== '') { + try { + $expireDate = $this->parseDate($expireDate); + $share->setExpirationDate($expireDate); + } catch (\Exception $e) { + throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD')); + } + } } elseif ($shareType === IShare::TYPE_CIRCLE) { if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) { throw new OCSNotFoundException($this->l->t('You cannot share to a Circle if the app is not enabled')); -- cgit v1.2.3 From b0aaafe259991e733353201f1e2c8aba0b43b3f3 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 16 Mar 2021 14:37:31 +0100 Subject: Fix expire date capability for federated shares Signed-off-by: Vincent Petry --- apps/files_sharing/lib/Capabilities.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php index 88af806b2f9..72cd854591f 100644 --- a/apps/files_sharing/lib/Capabilities.php +++ b/apps/files_sharing/lib/Capabilities.php @@ -111,7 +111,10 @@ class Capabilities implements ICapability { $res['federation'] = [ 'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes', 'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes', - 'expire_date' => ['enabled' => true] + // old bogus one, expire_date was not working before, keeping for compatibility + 'expire_date' => ['enabled' => true], + // the real deal, signifies that expiration date can be set on federated shares + 'expire_date_supported' => ['enabled' => true], ]; // Sharee searches -- cgit v1.2.3 From af61486aea90cfc1a82301ce624dffb59ed01e07 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 25 Mar 2021 17:32:49 +0100 Subject: Separate settings for remote share expiration Added separate settings for default and enforced expiration date for remote shares. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/Capabilities.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php index 72cd854591f..5a0b9d7e71d 100644 --- a/apps/files_sharing/lib/Capabilities.php +++ b/apps/files_sharing/lib/Capabilities.php @@ -86,6 +86,13 @@ class Capabilities implements ICapability { $public['expire_date_internal']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes'; } + $public['expire_date_remote'] = []; + $public['expire_date_remote']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes'; + if ($public['expire_date_remote']['enabled']) { + $public['expire_date_remote']['days'] = $this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7'); + $public['expire_date_remote']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes'; + } + $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes'; $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; $public['upload_files_drop'] = $public['upload']; -- cgit v1.2.3 From 12948aa2175cf0ebde30cceab4f5064f5a793cc8 Mon Sep 17 00:00:00 2001 From: castillo92 <37965565+castillo92@users.noreply.github.com> Date: Fri, 16 Apr 2021 08:56:20 +0200 Subject: Update ShareAPIController.php Change to capital letters in an abbreviation. Signed-off-by: castillo92 javiercizquierdo@gmail.com --- apps/files_sharing/lib/Controller/ShareAPIController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index f3b0467fa14..5c61649c66f 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -588,7 +588,7 @@ class ShareAPIController extends OCSController { } if ($shareWith === null) { - throw new OCSNotFoundException($this->l->t('Please specify a valid federated user id')); + throw new OCSNotFoundException($this->l->t('Please specify a valid federated user ID')); } $share->setSharedWith($shareWith); @@ -607,7 +607,7 @@ class ShareAPIController extends OCSController { } if ($shareWith === null) { - throw new OCSNotFoundException($this->l->t('Please specify a valid federated group id')); + throw new OCSNotFoundException($this->l->t('Please specify a valid federated group ID')); } $share->setSharedWith($shareWith); -- cgit v1.2.3 From dcd45427a6634fc7f302b7f549528e917815335a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 19 Apr 2021 20:05:21 +0200 Subject: Make lookup search explicit Speedsup sharee lookup quite a bit. Signed-off-by: Roeland Jago Douma --- apps/files_sharing/lib/Controller/ShareesAPIController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index ed809e7658d..8018f99e49a 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -141,7 +141,7 @@ class ShareesAPIController extends OCSController { * @return DataResponse * @throws OCSBadRequestException */ - public function search(string $search = '', string $itemType = null, int $page = 1, int $perPage = 200, $shareType = null, bool $lookup = true): DataResponse { + public function search(string $search = '', string $itemType = null, int $page = 1, int $perPage = 200, $shareType = null, bool $lookup = false): DataResponse { // only search for string larger than a given threshold $threshold = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0); -- cgit v1.2.3 From 505863c55ec9f31b74b0e203fbb8e3e651bccd2a Mon Sep 17 00:00:00 2001 From: Valdnet <47037905+Valdnet@users.noreply.github.com> Date: Tue, 27 Apr 2021 12:38:28 +0200 Subject: l10n: Change to a capital letter Signed-off-by: Valdnet <47037905+Valdnet@users.noreply.github.com> --- apps/files_sharing/lib/Controller/ShareAPIController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index f3b0467fa14..e8d48c42cd0 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -477,7 +477,7 @@ class ShareAPIController extends OCSController { } if ($permissions < 0 || $permissions > Constants::PERMISSION_ALL) { - throw new OCSNotFoundException($this->l->t('invalid permissions')); + throw new OCSNotFoundException($this->l->t('Invalid permissions')); } // Shares always require read permissions -- cgit v1.2.3 From 701294520aad315aeae06b03160830a375e98599 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 11 May 2021 15:25:31 +0200 Subject: Add bruteforce protection to the shareinfo endpoint Signed-off-by: Roeland Jago Douma --- .../files_sharing/lib/Controller/ShareInfoController.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index 315a562abef..0fe98a32c7d 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -48,7 +48,7 @@ class ShareInfoController extends ApiController { * @param IRequest $request * @param IManager $shareManager */ - public function __construct($appName, + public function __construct(string $appName, IRequest $request, IManager $shareManager) { parent::__construct($appName, $request); @@ -59,26 +59,32 @@ class ShareInfoController extends ApiController { /** * @PublicPage * @NoCSRFRequired + * @BruteForceProtection(action=shareinfo) * * @param string $t * @param null $password * @param null $dir * @return JSONResponse - * @throws ShareNotFound */ public function info($t, $password = null, $dir = null) { try { $share = $this->shareManager->getShareByToken($t); } catch (ShareNotFound $e) { - return new JSONResponse([], Http::STATUS_NOT_FOUND); + $response = new JSONResponse([], Http::STATUS_NOT_FOUND); + $response->throttle(['token' => $t]); + return $response; } if ($share->getPassword() && !$this->shareManager->checkPassword($share, $password)) { - return new JSONResponse([], Http::STATUS_FORBIDDEN); + $response = new JSONResponse([], Http::STATUS_FORBIDDEN); + $response->throttle(['token' => $t]); + return $response; } if (!($share->getPermissions() & Constants::PERMISSION_READ)) { - return new JSONResponse([], Http::STATUS_FORBIDDEN); + $response = new JSONResponse([], Http::STATUS_FORBIDDEN); + $response->throttle(['token' => $t]); + return $response; } $permissionMask = $share->getPermissions(); -- cgit v1.2.3 From b1dca57a1ce59bacc4089761275e4366e9760313 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 23 Apr 2021 17:29:34 +0200 Subject: load share settings from the share manager in more places Signed-off-by: Robin Appelman --- apps/files_sharing/lib/AppInfo/Application.php | 20 +++++++++----- apps/files_sharing/lib/Capabilities.php | 38 ++++++++++++++------------ 2 files changed, 34 insertions(+), 24 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 078a0a5f59d..213e441cdb8 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -56,7 +56,9 @@ use OCP\Group\Events\UserAddedEvent; use OCP\IDBConnection; use OCP\IGroup; use OCP\IServerContainer; +use OCP\IUserSession; use OCP\Share\Events\ShareCreatedEvent; +use OCP\Share\IManager; use OCP\Util; use Psr\Container\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -166,20 +168,24 @@ class Application extends App { } protected function setupSharingMenus() { - $config = \OC::$server->getConfig(); + /** @var IManager $shareManager */ + $shareManager = \OC::$server->get(IManager::class); - if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes' || !class_exists('\OCA\Files\App')) { + if (!$shareManager->shareApiEnabled() || !class_exists('\OCA\Files\App')) { return; } // show_Quick_Access stored as string - \OCA\Files\App::getNavigationManager()->add(function () { - $config = \OC::$server->getConfig(); + \OCA\Files\App::getNavigationManager()->add(function () use ($shareManager) { $l = \OC::$server->getL10N('files_sharing'); + /** @var IUserSession $userSession */ + $userSession = \OC::$server->get(IUserSession::class); + $user = $userSession->getUser(); + $userId = $user ? $user->getUID() : null; $sharingSublistArray = []; - if (\OCP\Util::isSharingDisabledForUser() === false) { + if ($shareManager->sharingDisabledForUser($userId) === false) { $sharingSublistArray[] = [ 'id' => 'sharingout', 'appname' => 'files_sharing', @@ -197,9 +203,9 @@ class Application extends App { 'name' => $l->t('Shared with you'), ]; - if (\OCP\Util::isSharingDisabledForUser() === false) { + if ($shareManager->sharingDisabledForUser($userId) === false) { // Check if sharing by link is enabled - if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { + if ($shareManager->shareApiAllowLinks()) { $sharingSublistArray[] = [ 'id' => 'sharinglinks', 'appname' => 'files_sharing', diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php index 5a0b9d7e71d..dca32d123f4 100644 --- a/apps/files_sharing/lib/Capabilities.php +++ b/apps/files_sharing/lib/Capabilities.php @@ -28,6 +28,7 @@ namespace OCA\Files_Sharing; use OCP\Capabilities\ICapability; use OCP\Constants; use OCP\IConfig; +use OCP\Share\IManager; /** * Class Capabilities @@ -38,9 +39,12 @@ class Capabilities implements ICapability { /** @var IConfig */ private $config; + /** @var IManager */ + private $shareManager; - public function __construct(IConfig $config) { + public function __construct(IConfig $config, IManager $shareManager) { $this->config = $config; + $this->shareManager = $shareManager; } /** @@ -51,7 +55,7 @@ class Capabilities implements ICapability { public function getCapabilities() { $res = []; - if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { + if (!$this->shareManager->shareApiEnabled()) { $res['api_enabled'] = false; $res['public'] = ['enabled' => false]; $res['user'] = ['send_mail' => false]; @@ -60,10 +64,10 @@ class Capabilities implements ICapability { $res['api_enabled'] = true; $public = []; - $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes'; + $public['enabled'] = $this->shareManager->shareApiAllowLinks(); if ($public['enabled']) { $public['password'] = []; - $public['password']['enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes'); + $public['password']['enforced'] = $this->shareManager->shareApiLinkEnforcePassword(); if ($public['password']['enforced']) { $public['password']['askForOptionalPassword'] = false; @@ -73,28 +77,28 @@ class Capabilities implements ICapability { $public['expire_date'] = []; $public['multiple_links'] = true; - $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; + $public['expire_date']['enabled'] = $this->shareManager->shareApiLinkDefaultExpireDate(); if ($public['expire_date']['enabled']) { - $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); - $public['expire_date']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; + $public['expire_date']['days'] = $this->shareManager->shareApiLinkDefaultExpireDays(); + $public['expire_date']['enforced'] = $this->shareManager->shareApiLinkDefaultExpireDateEnforced(); } $public['expire_date_internal'] = []; - $public['expire_date_internal']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; + $public['expire_date_internal']['enabled'] = $this->shareManager->shareApiInternalDefaultExpireDate(); if ($public['expire_date_internal']['enabled']) { - $public['expire_date_internal']['days'] = $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); - $public['expire_date_internal']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes'; + $public['expire_date_internal']['days'] = $this->shareManager->shareApiInternalDefaultExpireDays(); + $public['expire_date_internal']['enforced'] = $this->shareManager->shareApiInternalDefaultExpireDateEnforced(); } $public['expire_date_remote'] = []; - $public['expire_date_remote']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes'; + $public['expire_date_remote']['enabled'] = $this->shareManager->shareApiRemoteDefaultExpireDate(); if ($public['expire_date_remote']['enabled']) { - $public['expire_date_remote']['days'] = $this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7'); - $public['expire_date_remote']['enforced'] = $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes'; + $public['expire_date_remote']['days'] = $this->shareManager->shareApiRemoteDefaultExpireDays(); + $public['expire_date_remote']['enforced'] = $this->shareManager->shareApiRemoteDefaultExpireDateEnforced(); } $public['send_mail'] = $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no') === 'yes'; - $public['upload'] = $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === 'yes'; + $public['upload'] = $this->shareManager->shareApiLinkAllowPublicUpload(); $public['upload_files_drop'] = $public['upload']; } $res['public'] = $public; @@ -106,17 +110,17 @@ class Capabilities implements ICapability { // deprecated in favour of 'group', but we need to keep it for now // in order to stay compatible with older clients - $res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; + $res['group_sharing'] = $this->shareManager->allowGroupSharing(); $res['group'] = []; - $res['group']['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; + $res['group']['enabled'] = $this->shareManager->allowGroupSharing(); $res['group']['expire_date']['enabled'] = true; $res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL); } //Federated sharing $res['federation'] = [ - 'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes', + 'outgoing' => $this->shareManager->outgoingServer2ServerSharesAllowed(), 'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes', // old bogus one, expire_date was not working before, keeping for compatibility 'expire_date' => ['enabled' => true], -- cgit v1.2.3 From 9749968308d82418096a365d8d8e2e4131e44e34 Mon Sep 17 00:00:00 2001 From: Valdnet <47037905+Valdnet@users.noreply.github.com> Date: Mon, 12 Apr 2021 14:05:56 +0200 Subject: l10n: Unify spelling Spelling unification in Nextcloud applications. --- apps/files_sharing/lib/Controller/ShareAPIController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 0ddee32f7d0..9a2bca486c1 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1103,7 +1103,7 @@ class ShareAPIController extends OCSController { Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE, // allow to edit single files ], true) ) { - throw new OCSBadRequestException($this->l->t('Can\'t change permissions for public share links')); + throw new OCSBadRequestException($this->l->t('Cannot change permissions for public share links')); } if ( -- cgit v1.2.3 From 35d978c2fca0b4ae7961e44a3a9e1a4f77fad6dc Mon Sep 17 00:00:00 2001 From: szaimen Date: Thu, 20 May 2021 12:13:04 +0200 Subject: Rename External storages to External storage Signed-off-by: szaimen --- apps/files_sharing/lib/External/Mount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php index 12874198811..8ed04182143 100644 --- a/apps/files_sharing/lib/External/Mount.php +++ b/apps/files_sharing/lib/External/Mount.php @@ -71,7 +71,7 @@ class Mount extends MountPoint implements MoveableMount { } /** - * Get the type of mount point, used to distinguish things like shares and external storages + * Get the type of mount point, used to distinguish things like shares and external storage * in the web interface * * @return string -- cgit v1.2.3 From 81964200639c585ff523c6303fdb99eb0c7c180c Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 16 Feb 2021 11:56:07 +0100 Subject: Drop \OCP\User Inlines and remaining usages and drops the deprecated public API. Signed-off-by: Christoph Wurst --- apps/files_sharing/lib/Updater.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 2c9ccd10294..976143ab1b0 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -94,11 +94,11 @@ class Updater { * @param string $newPath new path relative to data/user/files */ private static function renameChildren($oldPath, $newPath) { - $absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath); - $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath); + $absNewPath = \OC\Files\Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $newPath); + $absOldPath = \OC\Files\Filesystem::normalizePath('/' . \OC_User::getUser() . '/files/' . $oldPath); $mountManager = \OC\Files\Filesystem::getMountManager(); - $mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath); + $mountedShares = $mountManager->findIn('/' . \OC_User::getUser() . '/files/' . $oldPath); foreach ($mountedShares as $mount) { if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) { $mountPoint = $mount->getMountPoint(); -- cgit v1.2.3 From e4b5645883d89ee3aca4105c1bde6ae4939f927c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 29 Jan 2021 15:59:41 +0100 Subject: Also make other shares listen to the "Allow sharing with groups" Signed-off-by: Joas Schilling --- apps/files_sharing/lib/Controller/ShareesAPIController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 8018f99e49a..571ea707e69 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -192,7 +192,9 @@ class ShareesAPIController extends OCSController { $shareTypes[] = IShare::TYPE_DECK; } } else { - $shareTypes[] = IShare::TYPE_GROUP; + if ($this->shareManager->allowGroupSharing()) { + $shareTypes[] = IShare::TYPE_GROUP; + } $shareTypes[] = IShare::TYPE_EMAIL; } -- cgit v1.2.3 From 215aef3cbdc1963be1bb6bca5218ee0a4b7f1665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Fri, 4 Jun 2021 21:52:51 +0200 Subject: Update php licenses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files_sharing/lib/Activity/Filter.php | 3 +-- apps/files_sharing/lib/Activity/Providers/Base.php | 3 +-- apps/files_sharing/lib/Activity/Providers/Downloads.php | 3 +-- apps/files_sharing/lib/Activity/Providers/Groups.php | 5 ++--- apps/files_sharing/lib/Activity/Providers/PublicLinks.php | 3 +-- apps/files_sharing/lib/Activity/Providers/RemoteShares.php | 3 +-- apps/files_sharing/lib/Activity/Providers/Users.php | 5 ++--- apps/files_sharing/lib/Activity/Settings/PublicLinks.php | 3 +-- apps/files_sharing/lib/Activity/Settings/RemoteShare.php | 3 +-- apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php | 3 +-- apps/files_sharing/lib/Activity/Settings/Shared.php | 3 +-- apps/files_sharing/lib/AppInfo/Application.php | 3 +-- .../files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php | 3 +-- apps/files_sharing/lib/Cache.php | 1 - apps/files_sharing/lib/Capabilities.php | 5 +++-- apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php | 3 +-- apps/files_sharing/lib/Command/CleanupRemoteStorages.php | 3 ++- apps/files_sharing/lib/Command/ExiprationNotification.php | 3 +-- apps/files_sharing/lib/Controller/AcceptController.php | 3 +-- apps/files_sharing/lib/Controller/DeletedShareAPIController.php | 7 +++---- apps/files_sharing/lib/Controller/ExternalSharesController.php | 2 -- apps/files_sharing/lib/Controller/PublicPreviewController.php | 3 +-- apps/files_sharing/lib/Controller/RemoteController.php | 1 - apps/files_sharing/lib/Controller/SettingsController.php | 3 +-- apps/files_sharing/lib/Controller/ShareAPIController.php | 5 +++-- apps/files_sharing/lib/Controller/ShareController.php | 3 +-- apps/files_sharing/lib/Controller/ShareInfoController.php | 5 ++--- apps/files_sharing/lib/Controller/ShareesAPIController.php | 4 ++-- apps/files_sharing/lib/DeleteOrphanedSharesJob.php | 1 - apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php | 3 +-- apps/files_sharing/lib/Exceptions/BrokenPath.php | 2 -- apps/files_sharing/lib/Exceptions/S2SException.php | 2 -- apps/files_sharing/lib/Exceptions/SharingRightsException.php | 3 +-- apps/files_sharing/lib/ExpireSharesJob.php | 3 +-- apps/files_sharing/lib/External/Cache.php | 2 -- apps/files_sharing/lib/External/Manager.php | 1 - apps/files_sharing/lib/External/Mount.php | 3 +-- apps/files_sharing/lib/External/MountProvider.php | 1 - apps/files_sharing/lib/External/Scanner.php | 2 -- apps/files_sharing/lib/External/Storage.php | 1 - apps/files_sharing/lib/External/Watcher.php | 1 - apps/files_sharing/lib/Helper.php | 1 - apps/files_sharing/lib/Hooks.php | 1 - apps/files_sharing/lib/ISharedStorage.php | 2 -- .../lib/Listener/LegacyBeforeTemplateRenderedListener.php | 3 +-- apps/files_sharing/lib/Listener/LoadAdditionalListener.php | 5 ++--- apps/files_sharing/lib/Listener/LoadSidebarListener.php | 5 ++--- apps/files_sharing/lib/Listener/ShareInteractionListener.php | 5 ++--- apps/files_sharing/lib/Listener/UserAddedToGroupListener.php | 3 +-- apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php | 3 +-- apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php | 5 ++--- apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php | 5 ++--- apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php | 2 +- apps/files_sharing/lib/Migration/OwncloudGuestShareType.php | 3 +-- apps/files_sharing/lib/Migration/SetAcceptedStatus.php | 3 +-- apps/files_sharing/lib/Migration/SetPasswordColumn.php | 3 +-- .../files_sharing/lib/Migration/Version11300Date20201120141438.php | 6 +++--- .../files_sharing/lib/Migration/Version21000Date20201223143245.php | 5 ++--- .../files_sharing/lib/Migration/Version22000Date20210216084241.php | 3 +-- apps/files_sharing/lib/MountProvider.php | 1 - apps/files_sharing/lib/Notification/Listener.php | 3 +-- apps/files_sharing/lib/Notification/Notifier.php | 3 +-- apps/files_sharing/lib/Scanner.php | 2 -- apps/files_sharing/lib/Settings/Personal.php | 3 +-- apps/files_sharing/lib/ShareBackend/File.php | 1 - apps/files_sharing/lib/ShareBackend/Folder.php | 1 - apps/files_sharing/lib/SharedMount.php | 1 - apps/files_sharing/lib/SharedStorage.php | 1 - apps/files_sharing/lib/Updater.php | 1 - 69 files changed, 66 insertions(+), 133 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Activity/Filter.php b/apps/files_sharing/lib/Activity/Filter.php index da4539384cf..0ac64301ec8 100644 --- a/apps/files_sharing/lib/Activity/Filter.php +++ b/apps/files_sharing/lib/Activity/Filter.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity; use OCP\Activity\IFilter; diff --git a/apps/files_sharing/lib/Activity/Providers/Base.php b/apps/files_sharing/lib/Activity/Providers/Base.php index 843a0c447f1..948d629c8fc 100644 --- a/apps/files_sharing/lib/Activity/Providers/Base.php +++ b/apps/files_sharing/lib/Activity/Providers/Base.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Providers; use OCP\Activity\IEvent; diff --git a/apps/files_sharing/lib/Activity/Providers/Downloads.php b/apps/files_sharing/lib/Activity/Providers/Downloads.php index be019bdcd65..a6bbe9a4118 100644 --- a/apps/files_sharing/lib/Activity/Providers/Downloads.php +++ b/apps/files_sharing/lib/Activity/Providers/Downloads.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Providers; use OCP\Activity\IEvent; diff --git a/apps/files_sharing/lib/Activity/Providers/Groups.php b/apps/files_sharing/lib/Activity/Providers/Groups.php index 53336057e37..71b1dc65f56 100644 --- a/apps/files_sharing/lib/Activity/Providers/Groups.php +++ b/apps/files_sharing/lib/Activity/Providers/Groups.php @@ -4,7 +4,7 @@ * * @author Christoph Wurst * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * * @license GNU AGPL version 3 or any later version * @@ -15,14 +15,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Providers; use OCP\Activity\IEvent; diff --git a/apps/files_sharing/lib/Activity/Providers/PublicLinks.php b/apps/files_sharing/lib/Activity/Providers/PublicLinks.php index 2742ded4007..5782166704f 100644 --- a/apps/files_sharing/lib/Activity/Providers/PublicLinks.php +++ b/apps/files_sharing/lib/Activity/Providers/PublicLinks.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Providers; use OCP\Activity\IEvent; diff --git a/apps/files_sharing/lib/Activity/Providers/RemoteShares.php b/apps/files_sharing/lib/Activity/Providers/RemoteShares.php index f2217f423ef..29f7c0a298e 100644 --- a/apps/files_sharing/lib/Activity/Providers/RemoteShares.php +++ b/apps/files_sharing/lib/Activity/Providers/RemoteShares.php @@ -15,14 +15,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Providers; use OCP\Activity\IEvent; diff --git a/apps/files_sharing/lib/Activity/Providers/Users.php b/apps/files_sharing/lib/Activity/Providers/Users.php index 828befc471b..8b90ac8ee9d 100644 --- a/apps/files_sharing/lib/Activity/Providers/Users.php +++ b/apps/files_sharing/lib/Activity/Providers/Users.php @@ -4,7 +4,7 @@ * * @author Christoph Wurst * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Kevin Ndung'u * * @license GNU AGPL version 3 or any later version @@ -16,14 +16,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Providers; use OCP\Activity\IEvent; diff --git a/apps/files_sharing/lib/Activity/Settings/PublicLinks.php b/apps/files_sharing/lib/Activity/Settings/PublicLinks.php index 455ae88d5c6..6d91bf16ce2 100644 --- a/apps/files_sharing/lib/Activity/Settings/PublicLinks.php +++ b/apps/files_sharing/lib/Activity/Settings/PublicLinks.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Settings; class PublicLinks extends ShareActivitySettings { diff --git a/apps/files_sharing/lib/Activity/Settings/RemoteShare.php b/apps/files_sharing/lib/Activity/Settings/RemoteShare.php index 24fa753437b..4a796132612 100644 --- a/apps/files_sharing/lib/Activity/Settings/RemoteShare.php +++ b/apps/files_sharing/lib/Activity/Settings/RemoteShare.php @@ -15,14 +15,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Settings; class RemoteShare extends ShareActivitySettings { diff --git a/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php b/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php index 26b307c34e4..e7de3dff8ee 100644 --- a/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php +++ b/apps/files_sharing/lib/Activity/Settings/ShareActivitySettings.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Settings; use OCP\Activity\ActivitySettings; diff --git a/apps/files_sharing/lib/Activity/Settings/Shared.php b/apps/files_sharing/lib/Activity/Settings/Shared.php index 43b26252287..eaef23c1c92 100644 --- a/apps/files_sharing/lib/Activity/Settings/Shared.php +++ b/apps/files_sharing/lib/Activity/Settings/Shared.php @@ -15,14 +15,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Activity\Settings; class Shared extends ShareActivitySettings { diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 213e441cdb8..7f234e63660 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -5,7 +5,7 @@ * @author Bjoern Schiessle * @author Christoph Wurst * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Julius Härtl * @author Morris Jobke * @author Robin Appelman @@ -27,7 +27,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\AppInfo; use OC\AppFramework\Utility\SimpleContainer; diff --git a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php index 913dbf64284..d35f35d20f2 100644 --- a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php +++ b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php @@ -17,14 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\BackgroundJob; use OC\BackgroundJob\TimedJob; diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 3a6ade5a2ac..29224c5fb6b 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -26,7 +26,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Files\Cache\FailedCache; diff --git a/apps/files_sharing/lib/Capabilities.php b/apps/files_sharing/lib/Capabilities.php index dca32d123f4..c5421fe779a 100644 --- a/apps/files_sharing/lib/Capabilities.php +++ b/apps/files_sharing/lib/Capabilities.php @@ -3,9 +3,11 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Bjoern Schiessle - * @author Christoph Wurst + * @author Julius Härtl + * @author Robin Appelman * @author Roeland Jago Douma * @author Tobias Kaminsky + * @author Vincent Petry * * @license AGPL-3.0 * @@ -22,7 +24,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OCP\Capabilities\ICapability; diff --git a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php index 5fbeba7dd01..28d0d26c5be 100644 --- a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php +++ b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Collaboration; use OCP\Collaboration\AutoComplete\ISorter; diff --git a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php index cf0550aef7f..3816a2a5124 100644 --- a/apps/files_sharing/lib/Command/CleanupRemoteStorages.php +++ b/apps/files_sharing/lib/Command/CleanupRemoteStorages.php @@ -2,6 +2,8 @@ /** * @copyright Copyright (c) 2016, ownCloud GmbH. * + * @author Christoph Wurst + * @author Daniel Calviño Sánchez * @author Joas Schilling * @author Jörn Friedrich Dreyer * @author Roeland Jago Douma @@ -21,7 +23,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Command; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/apps/files_sharing/lib/Command/ExiprationNotification.php b/apps/files_sharing/lib/Command/ExiprationNotification.php index 748a640a962..e77b41b1835 100644 --- a/apps/files_sharing/lib/Command/ExiprationNotification.php +++ b/apps/files_sharing/lib/Command/ExiprationNotification.php @@ -17,14 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Command; use OCP\AppFramework\Utility\ITimeFactory; diff --git a/apps/files_sharing/lib/Controller/AcceptController.php b/apps/files_sharing/lib/Controller/AcceptController.php index b25382b45f5..c97780d6f0c 100644 --- a/apps/files_sharing/lib/Controller/AcceptController.php +++ b/apps/files_sharing/lib/Controller/AcceptController.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Controller; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index 75936907fed..1d625b35322 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -3,12 +3,12 @@ declare(strict_types=1); /** - * + * @copyright Copyright (c) 2016 Roeland Jago Douma * * @author Christoph Wurst * @author Daniel Calviño Sánchez * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Julius Härtl * @author Roeland Jago Douma * @@ -21,14 +21,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Controller; use OCP\App\IAppManager; diff --git a/apps/files_sharing/lib/Controller/ExternalSharesController.php b/apps/files_sharing/lib/Controller/ExternalSharesController.php index 96b9ebffac8..9fab8d4e1a0 100644 --- a/apps/files_sharing/lib/Controller/ExternalSharesController.php +++ b/apps/files_sharing/lib/Controller/ExternalSharesController.php @@ -5,7 +5,6 @@ * @author Björn Schießle * @author Joas Schilling * @author Lukas Reschke - * @author Morris Jobke * @author Robin Appelman * @author Roeland Jago Douma * @@ -24,7 +23,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Controller; use OCP\AppFramework\Controller; diff --git a/apps/files_sharing/lib/Controller/PublicPreviewController.php b/apps/files_sharing/lib/Controller/PublicPreviewController.php index 0e58057351f..4a16afa7ac0 100644 --- a/apps/files_sharing/lib/Controller/PublicPreviewController.php +++ b/apps/files_sharing/lib/Controller/PublicPreviewController.php @@ -15,14 +15,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Controller; use OCP\AppFramework\Http; diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php index 72eb8667b96..75684220c52 100644 --- a/apps/files_sharing/lib/Controller/RemoteController.php +++ b/apps/files_sharing/lib/Controller/RemoteController.php @@ -21,7 +21,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Controller; use OCA\Files_Sharing\External\Manager; diff --git a/apps/files_sharing/lib/Controller/SettingsController.php b/apps/files_sharing/lib/Controller/SettingsController.php index 343bec31926..8f542ecb071 100644 --- a/apps/files_sharing/lib/Controller/SettingsController.php +++ b/apps/files_sharing/lib/Controller/SettingsController.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Controller; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 9a2bca486c1..b323e5514a5 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -6,13 +6,14 @@ declare(strict_types=1); * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Bjoern Schiessle + * @author castillo92 <37965565+castillo92@users.noreply.github.com> * @author Christoph Wurst * @author Daniel Calviño Sánchez * @author Daniel Kesselberg * @author Gary Kim * @author Georg Ehrke * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Julius Härtl * @author Lukas Reschke * @author Maxence Lange @@ -22,6 +23,7 @@ declare(strict_types=1); * @author Richard Steinmetz * @author Robin Appelman * @author Roeland Jago Douma + * @author Valdnet <47037905+Valdnet@users.noreply.github.com> * @author Vincent Petry * @author waleczny * @@ -40,7 +42,6 @@ declare(strict_types=1); * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Controller; use OCA\Files_Sharing\Exceptions\SharingRightsException; diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 7e83ffaa7dc..4893a693df3 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -10,7 +10,7 @@ * @author Georg Ehrke * @author j3l11234 <297259024@qq.com> * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Jonas Sulzer * @author Julius Härtl * @author Lukas Reschke @@ -40,7 +40,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Controller; use OC_Files; diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index 0fe98a32c7d..429eb91bc92 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -1,6 +1,6 @@ * * @author Morris Jobke * @author Roeland Jago Douma @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Controller; use OCA\Files_External\NotFoundException; diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 571ea707e69..399cd4e00be 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -11,8 +11,9 @@ declare(strict_types=1); * @author Christoph Wurst * @author Daniel Calviño Sánchez * @author Daniel Kesselberg + * @author J0WI * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Julius Härtl * @author Maxence Lange * @author Morris Jobke @@ -34,7 +35,6 @@ declare(strict_types=1); * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Controller; use OCP\Constants; diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php index eef44cd3400..6a641734680 100644 --- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php +++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php @@ -22,7 +22,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\BackgroundJob\TimedJob; diff --git a/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php b/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php index 6076d50b1f2..1a889cfebe7 100644 --- a/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php +++ b/apps/files_sharing/lib/Event/BeforeTemplateRenderedEvent.php @@ -17,14 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Event; use OCP\EventDispatcher\Event; diff --git a/apps/files_sharing/lib/Exceptions/BrokenPath.php b/apps/files_sharing/lib/Exceptions/BrokenPath.php index c0679c83314..e9908ac293a 100644 --- a/apps/files_sharing/lib/Exceptions/BrokenPath.php +++ b/apps/files_sharing/lib/Exceptions/BrokenPath.php @@ -4,7 +4,6 @@ * * @author Björn Schießle * @author Christoph Wurst - * @author Morris Jobke * * @license AGPL-3.0 * @@ -21,7 +20,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Exceptions; /** diff --git a/apps/files_sharing/lib/Exceptions/S2SException.php b/apps/files_sharing/lib/Exceptions/S2SException.php index e775257034b..c6becc057dd 100644 --- a/apps/files_sharing/lib/Exceptions/S2SException.php +++ b/apps/files_sharing/lib/Exceptions/S2SException.php @@ -3,7 +3,6 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Björn Schießle - * @author Morris Jobke * @author Roeland Jago Douma * * @license AGPL-3.0 @@ -21,7 +20,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\Exceptions; /** diff --git a/apps/files_sharing/lib/Exceptions/SharingRightsException.php b/apps/files_sharing/lib/Exceptions/SharingRightsException.php index db346774bdb..f235e56cbe4 100644 --- a/apps/files_sharing/lib/Exceptions/SharingRightsException.php +++ b/apps/files_sharing/lib/Exceptions/SharingRightsException.php @@ -13,14 +13,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Exceptions; use Exception; diff --git a/apps/files_sharing/lib/ExpireSharesJob.php b/apps/files_sharing/lib/ExpireSharesJob.php index 85a57e855b8..1e56602a0bf 100644 --- a/apps/files_sharing/lib/ExpireSharesJob.php +++ b/apps/files_sharing/lib/ExpireSharesJob.php @@ -4,7 +4,7 @@ * * @author Christoph Wurst * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Roeland Jago Douma * * @license AGPL-3.0 @@ -22,7 +22,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OCP\AppFramework\Utility\ITimeFactory; diff --git a/apps/files_sharing/lib/External/Cache.php b/apps/files_sharing/lib/External/Cache.php index 6a816b166ae..f8d9a2548a8 100644 --- a/apps/files_sharing/lib/External/Cache.php +++ b/apps/files_sharing/lib/External/Cache.php @@ -2,7 +2,6 @@ /** * @copyright Copyright (c) 2016, ownCloud, Inc. * - * @author Morris Jobke * @author Robin Appelman * @author Vincent Petry * @@ -21,7 +20,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; use OCP\Federation\ICloudId; diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 534dd0d2c51..720df28d107 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -30,7 +30,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; use Doctrine\DBAL\Driver\Exception; diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php index 8ed04182143..c8b74202ac7 100644 --- a/apps/files_sharing/lib/External/Mount.php +++ b/apps/files_sharing/lib/External/Mount.php @@ -4,8 +4,8 @@ * * @author Bjoern Schiessle * @author Björn Schießle - * @author Morris Jobke * @author Robin Appelman + * @author szaimen * * @license AGPL-3.0 * @@ -22,7 +22,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; use OC\Files\Mount\MountPoint; diff --git a/apps/files_sharing/lib/External/MountProvider.php b/apps/files_sharing/lib/External/MountProvider.php index 7eb2491619f..36015162530 100644 --- a/apps/files_sharing/lib/External/MountProvider.php +++ b/apps/files_sharing/lib/External/MountProvider.php @@ -22,7 +22,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; use OCP\Federation\ICloudIdManager; diff --git a/apps/files_sharing/lib/External/Scanner.php b/apps/files_sharing/lib/External/Scanner.php index 71187707ad7..8115159d181 100644 --- a/apps/files_sharing/lib/External/Scanner.php +++ b/apps/files_sharing/lib/External/Scanner.php @@ -4,7 +4,6 @@ * * @author Christoph Wurst * @author Lukas Reschke - * @author Morris Jobke * @author Olivier Paroz * @author Robin Appelman * @author Vincent Petry @@ -24,7 +23,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; use OC\ForbiddenException; diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index f612aadfb32..7d9e8f31c98 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -29,7 +29,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; use GuzzleHttp\Exception\ClientException; diff --git a/apps/files_sharing/lib/External/Watcher.php b/apps/files_sharing/lib/External/Watcher.php index fb15944a533..6afd1c6d538 100644 --- a/apps/files_sharing/lib/External/Watcher.php +++ b/apps/files_sharing/lib/External/Watcher.php @@ -19,7 +19,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\External; class Watcher extends \OC\Files\Cache\Watcher { diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index 270eb452419..d8e58e84b7d 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -25,7 +25,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Files\Filesystem; diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php index b3fe09bf9cf..ff4ca59339a 100644 --- a/apps/files_sharing/lib/Hooks.php +++ b/apps/files_sharing/lib/Hooks.php @@ -24,7 +24,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Files\Filesystem; diff --git a/apps/files_sharing/lib/ISharedStorage.php b/apps/files_sharing/lib/ISharedStorage.php index 07c012fd6ff..9f57984803a 100644 --- a/apps/files_sharing/lib/ISharedStorage.php +++ b/apps/files_sharing/lib/ISharedStorage.php @@ -3,7 +3,6 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Christoph Wurst - * @author Morris Jobke * @author Robin Appelman * * @license AGPL-3.0 @@ -21,7 +20,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; interface ISharedStorage { diff --git a/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php b/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php index bd0a668b429..e7e81c3a17a 100644 --- a/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php +++ b/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Listener; use OC\EventDispatcher\SymfonyAdapter; diff --git a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php index 316461e792d..44412023bf8 100644 --- a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php +++ b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php @@ -5,7 +5,7 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma * - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * * @license GNU AGPL version 3 or any later version * @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Listener; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php index 636a8c7757e..145ab25f686 100644 --- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php +++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php @@ -5,7 +5,7 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma * - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * * @license GNU AGPL version 3 or any later version * @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Listener; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/Listener/ShareInteractionListener.php b/apps/files_sharing/lib/Listener/ShareInteractionListener.php index 90fc6e996b3..65ad555f5bd 100644 --- a/apps/files_sharing/lib/Listener/ShareInteractionListener.php +++ b/apps/files_sharing/lib/Listener/ShareInteractionListener.php @@ -6,7 +6,7 @@ declare(strict_types=1); * @copyright 2020 Christoph Wurst * * @author Christoph Wurst - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * * @license GNU AGPL version 3 or any later version * @@ -17,14 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Listener; use OCP\Contacts\Events\ContactInteractedWithEvent; diff --git a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php index 623591da310..9b2975f5833 100644 --- a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php +++ b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Listener; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php b/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php index 91c0aa494bb..160a806f8ac 100644 --- a/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php +++ b/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php @@ -18,14 +18,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Listener; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php index 398682b7833..1c961ffed34 100644 --- a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php +++ b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php @@ -1,6 +1,6 @@ * * @author Lukas Reschke * @author Morris Jobke @@ -15,14 +15,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Middleware; use OCA\Files_Sharing\Controller\ShareAPIController; diff --git a/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php b/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php index 52d83cdc836..adc6116af45 100644 --- a/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php +++ b/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php @@ -1,6 +1,6 @@ * * @author Morris Jobke * @author Roeland Jago Douma @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Middleware; use OCA\Files_Sharing\Controller\ShareInfoController; diff --git a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php index 335b0908a98..b9bab169d1d 100644 --- a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php +++ b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php @@ -1,6 +1,7 @@ * */ - namespace OCA\Files_Sharing\Middleware; use OCA\Files_Sharing\Controller\ExternalSharesController; diff --git a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php index a4eaa5b3989..d1ba645f93d 100644 --- a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php +++ b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php @@ -14,14 +14,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Migration; use OCP\IConfig; diff --git a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php index 386f7299d40..a27f12e87e1 100644 --- a/apps/files_sharing/lib/Migration/SetAcceptedStatus.php +++ b/apps/files_sharing/lib/Migration/SetAcceptedStatus.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Migration; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/apps/files_sharing/lib/Migration/SetPasswordColumn.php b/apps/files_sharing/lib/Migration/SetPasswordColumn.php index 859c49f2991..b4de4f574dd 100644 --- a/apps/files_sharing/lib/Migration/SetPasswordColumn.php +++ b/apps/files_sharing/lib/Migration/SetPasswordColumn.php @@ -13,14 +13,13 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Migration; use OCP\IConfig; diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php index 9d485952ac4..50d0cd9e066 100644 --- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php +++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php @@ -5,7 +5,9 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2020 Julius Härtl * + * @author Christoph Wurst * @author Julius Härtl + * @author Vincent Petry * * @license GNU AGPL version 3 or any later version * @@ -16,15 +18,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - - namespace OCA\Files_Sharing\Migration; use Closure; diff --git a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php index 0138d3298e5..ff7722eaa58 100644 --- a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php +++ b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php @@ -5,6 +5,7 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2020 Vincent Petry * + * @author Christoph Wurst * @author Vincent Petry * * @license GNU AGPL version 3 or any later version @@ -16,15 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - - namespace OCA\Files_Sharing\Migration; use Closure; diff --git a/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php b/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php index e3e8dc8bc55..443f255d031 100644 --- a/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php +++ b/apps/files_sharing/lib/Migration/Version22000Date20210216084241.php @@ -16,14 +16,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Migration; use Closure; diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 05328872c15..42541b77f2d 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -26,7 +26,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Cache\CappedMemoryCache; diff --git a/apps/files_sharing/lib/Notification/Listener.php b/apps/files_sharing/lib/Notification/Listener.php index 385612959a9..db7939767d6 100644 --- a/apps/files_sharing/lib/Notification/Listener.php +++ b/apps/files_sharing/lib/Notification/Listener.php @@ -17,14 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Notification; use OCP\IGroup; diff --git a/apps/files_sharing/lib/Notification/Notifier.php b/apps/files_sharing/lib/Notification/Notifier.php index 2499896653b..7d79165dd26 100644 --- a/apps/files_sharing/lib/Notification/Notifier.php +++ b/apps/files_sharing/lib/Notification/Notifier.php @@ -19,14 +19,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Notification; use OCP\Files\IRootFolder; diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php index 21d2565a4cd..a240d3ffb8f 100644 --- a/apps/files_sharing/lib/Scanner.php +++ b/apps/files_sharing/lib/Scanner.php @@ -3,7 +3,6 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Joas Schilling - * @author Morris Jobke * @author Robin Appelman * @author Roeland Jago Douma * @author Vincent Petry @@ -23,7 +22,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Files\ObjectStore\NoopScanner; diff --git a/apps/files_sharing/lib/Settings/Personal.php b/apps/files_sharing/lib/Settings/Personal.php index c265a279393..3917001e882 100644 --- a/apps/files_sharing/lib/Settings/Personal.php +++ b/apps/files_sharing/lib/Settings/Personal.php @@ -17,14 +17,13 @@ declare(strict_types=1); * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ - namespace OCA\Files_Sharing\Settings; use OCA\Files_Sharing\AppInfo\Application; diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index fdaeb0c5814..c84cbd66c67 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -31,7 +31,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\ShareBackend; use OCA\FederatedFileSharing\FederatedShareProvider; diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php index c51740cd6d0..51d0c709d98 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -26,7 +26,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing\ShareBackend; class Folder extends File implements \OCP\Share_Backend_Collection { diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index be600caef4c..8443ccb8439 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -26,7 +26,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Cache\CappedMemoryCache; diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index eb0af419983..662c5ad3651 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -30,7 +30,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OC\Files\Cache\FailedCache; diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 976143ab1b0..e035ed51ec8 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -24,7 +24,6 @@ * along with this program. If not, see * */ - namespace OCA\Files_Sharing; use OCP\Share\IShare; -- cgit v1.2.3 From 4a2804dae28bf0206d015f2a16db8c35e72687bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 15 Apr 2021 12:51:03 +0200 Subject: Drop share if moved to a parent share that does not allow resharing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_sharing/lib/Updater.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index e035ed51ec8..19ff13d8950 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -26,6 +26,7 @@ */ namespace OCA\Files_Sharing; +use OCP\Constants; use OCP\Share\IShare; class Updater { @@ -81,6 +82,10 @@ class Updater { //Ownership is moved over foreach ($shares as $share) { /** @var IShare $share */ + if (!($dstMount->getShare()->getPermissions() & Constants::PERMISSION_SHARE)) { + $shareManager->deleteShare($share); + continue; + } $share->setShareOwner($newOwner); $shareManager->updateShare($share); } -- cgit v1.2.3 From 06bfbb4a8c709ece9eb0fd2b41a7a3e29ae70960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 15 Apr 2021 12:51:35 +0200 Subject: When changing the share owner, downgrade permissions where needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_sharing/lib/Updater.php | 1 + 1 file changed, 1 insertion(+) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php index 19ff13d8950..9ce114f495d 100644 --- a/apps/files_sharing/lib/Updater.php +++ b/apps/files_sharing/lib/Updater.php @@ -87,6 +87,7 @@ class Updater { continue; } $share->setShareOwner($newOwner); + $share->setPermissions($share->getPermissions() & $dstMount->getShare()->getPermissions()); $shareManager->updateShare($share); } } -- cgit v1.2.3 From ebf35fb38a770f26b5db4d6eebba18a28fa10dcd Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 9 Jun 2021 14:43:15 +0200 Subject: Correctly check the reception of a remote feedback Signed-off-by: Louis Chemineau --- apps/files_sharing/lib/External/Manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 720df28d107..e51bd64cf38 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -365,7 +365,7 @@ class Manager { private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) { $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback); - if ($result === true) { + if (is_array($result)) { return true; } @@ -401,7 +401,7 @@ class Manager { * @param string $token * @param string $remoteId id of the share * @param string $feedback - * @return bool + * @return array|false */ protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) { switch ($feedback) { -- cgit v1.2.3 From e198dc1b200f3ade93498e0ea7b468c87d46748a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 4 May 2021 19:06:02 +0200 Subject: rework search api to allow searching on multiple caches at once Signed-off-by: Robin Appelman --- apps/files_sharing/lib/Cache.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 29224c5fb6b..b703a672a25 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -31,6 +31,7 @@ namespace OCA\Files_Sharing; use OC\Files\Cache\FailedCache; use OC\Files\Cache\Wrapper\CacheJail; use OC\Files\Storage\Wrapper\Jail; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\ICacheEntry; use OCP\Files\StorageNotAvailableException; @@ -181,19 +182,18 @@ class Cache extends CacheJail { // Not a valid action for Shared Cache } - public function search($pattern) { - // Do the normal search on the whole storage for non files + public function getQueryFilterForStorage(IQueryBuilder $builder) { + // Do the normal jail behavior for non files if ($this->storage->getItemType() !== 'file') { - return parent::search($pattern); + return parent::getQueryFilterForStorage($builder); } - $regex = '/' . str_replace('%', '.*', $pattern) . '/i'; - - $data = $this->get(''); - if (preg_match($regex, $data->getName()) === 1) { - return [$data]; - } - - return []; + // for single file shares we don't need to do the LIKE + return $builder->expr()->andX( + parent::getQueryFilterForStorage($builder), + $builder->expr()->orX( + $builder->expr()->eq('path_hash', $builder->createNamedParameter(md5($this->getGetUnjailedRoot()))), + ) + ); } } -- cgit v1.2.3 From 9774fb1573d30e79eb57f8956f64b13b52b7dee9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 5 May 2021 18:09:53 +0200 Subject: use searchoperation for storage filter instead of db expression Signed-off-by: Robin Appelman --- apps/files_sharing/lib/Cache.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index b703a672a25..25e92d23962 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -30,9 +30,13 @@ namespace OCA\Files_Sharing; use OC\Files\Cache\FailedCache; use OC\Files\Cache\Wrapper\CacheJail; +use OC\Files\Search\SearchBinaryOperator; +use OC\Files\Search\SearchComparison; use OC\Files\Storage\Wrapper\Jail; -use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\ICacheEntry; +use OCP\Files\Search\ISearchBinaryOperator; +use OCP\Files\Search\ISearchComparison; +use OCP\Files\Search\ISearchOperator; use OCP\Files\StorageNotAvailableException; /** @@ -182,18 +186,19 @@ class Cache extends CacheJail { // Not a valid action for Shared Cache } - public function getQueryFilterForStorage(IQueryBuilder $builder) { + public function getQueryFilterForStorage(): ISearchOperator { // Do the normal jail behavior for non files if ($this->storage->getItemType() !== 'file') { - return parent::getQueryFilterForStorage($builder); + return parent::getQueryFilterForStorage(); } // for single file shares we don't need to do the LIKE - return $builder->expr()->andX( - parent::getQueryFilterForStorage($builder), - $builder->expr()->orX( - $builder->expr()->eq('path_hash', $builder->createNamedParameter(md5($this->getGetUnjailedRoot()))), - ) + return new SearchBinaryOperator( + ISearchBinaryOperator::OPERATOR_AND, + [ + \OC\Files\Cache\Cache::getQueryFilterForStorage(), + new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()), + ] ); } } -- cgit v1.2.3 From c0474ba3644fc94674788bf21dd3e22d564e019c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 5 Mar 2021 10:04:09 +0100 Subject: Use product name in places where it is appropriate rather than the instance name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_sharing/lib/Controller/ShareController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 4893a693df3..fbee6bf4b77 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -511,7 +511,8 @@ class ShareController extends AuthPublicShareController { $download = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']); $downloadAll = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']); $directLink = new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']); - $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']); + // TRANSLATORS The placeholder refers to the software product name as in 'Add to your Nextcloud' + $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your %s', [$this->defaults->getProductName()]), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']); $responseComposer = []; -- cgit v1.2.3 From 095418493ef909d25808d278ee099fb34070c7fb Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 23 Nov 2020 23:51:19 +0100 Subject: Use proper methods for display name retrieval Signed-off-by: Morris Jobke --- apps/files_sharing/lib/Cache.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 25e92d23962..ab8adda725e 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -38,6 +38,7 @@ use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchOperator; use OCP\Files\StorageNotAvailableException; +use OCP\IUserManager; /** * Metadata cache for shared files @@ -174,7 +175,13 @@ class Cache extends CacheJail { private function getOwnerDisplayName() { if (!$this->ownerDisplayName) { - $this->ownerDisplayName = \OC_User::getDisplayName($this->storage->getOwner('')); + $uid = $this->storage->getOwner(''); + $user = \OC::$server->get(IUserManager::class)->get($uid); + if ($user) { + $this->ownerDisplayName = $user->getDisplayName(); + } else { + $this->ownerDisplayName = $uid; + } } return $this->ownerDisplayName; } -- cgit v1.2.3 From 2690481cbad009b74292fdfbd028fc8b5b01a394 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Sun, 29 Nov 2020 21:45:06 +0100 Subject: Use DI for files_sharing Cache Signed-off-by: Morris Jobke --- apps/files_sharing/lib/Cache.php | 17 +++++++---------- apps/files_sharing/lib/SharedStorage.php | 7 ++++++- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index ab8adda725e..8729426221b 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -46,15 +46,12 @@ use OCP\IUserManager; * don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead */ class Cache extends CacheJail { - /** - * @var \OCA\Files_Sharing\SharedStorage - */ + /** @var \OCA\Files_Sharing\SharedStorage */ private $storage; - - /** - * @var ICacheEntry - */ + /** @var ICacheEntry */ private $sourceRootInfo; + /** @var IUserManager */ + private $userManager; private $rootUnchanged = true; @@ -64,11 +61,11 @@ class Cache extends CacheJail { /** * @param \OCA\Files_Sharing\SharedStorage $storage - * @param ICacheEntry $sourceRootInfo */ - public function __construct($storage, ICacheEntry $sourceRootInfo) { + public function __construct($storage, ICacheEntry $sourceRootInfo, IUserManager $userManager) { $this->storage = $storage; $this->sourceRootInfo = $sourceRootInfo; + $this->userManager = $userManager; $this->numericId = $sourceRootInfo->getStorageId(); parent::__construct( @@ -176,7 +173,7 @@ class Cache extends CacheJail { private function getOwnerDisplayName() { if (!$this->ownerDisplayName) { $uid = $this->storage->getOwner(''); - $user = \OC::$server->get(IUserManager::class)->get($uid); + $user = $this->userManager->get($uid); if ($user) { $this->ownerDisplayName = $user->getDisplayName(); } else { diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 662c5ad3651..f4a525ce871 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -43,6 +43,7 @@ use OCP\Files\Cache\ICacheEntry; use OCP\Files\NotFoundException; use OCP\Files\Storage\IDisableEncryptionStorage; use OCP\Files\Storage\IStorage; +use OCP\IUserManager; use OCP\Lock\ILockingProvider; use OCP\Share\IShare; @@ -385,7 +386,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto return new FailedCache(); } - $this->cache = new \OCA\Files_Sharing\Cache($storage, $sourceRoot, $this->superShare); + $this->cache = new \OCA\Files_Sharing\Cache( + $storage, + $sourceRoot, + \OC::$server->get(IUserManager::class) + ); return $this->cache; } -- cgit v1.2.3 From b78f3a57d1d05fb5f81ec8361139b64a3e54d7b0 Mon Sep 17 00:00:00 2001 From: Gary Kim Date: Tue, 29 Jun 2021 19:20:33 -0400 Subject: Migrate HintException to OCP Signed-off-by: Gary Kim --- apps/files_sharing/lib/Controller/ShareController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index fbee6bf4b77..95c3303ae74 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -42,9 +42,9 @@ */ namespace OCA\Files_Sharing\Controller; +use OC\Security\CSP\ContentSecurityPolicy; use OC_Files; use OC_Util; -use OC\Security\CSP\ContentSecurityPolicy; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Activity\Providers\Downloads; use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; @@ -242,7 +242,7 @@ class ShareController extends AuthPublicShareController { * otherwise token * @param int $errorCode * @param string $errorMessage - * @throws \OC\HintException + * @throws \OCP\HintException * @throws \OC\ServerNotAvailableException */ protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') { -- cgit v1.2.3 From 0c27faf7113d2c4cecfd94e0c02a31032a22b9fa Mon Sep 17 00:00:00 2001 From: szaimen Date: Wed, 7 Jul 2021 12:22:54 +0200 Subject: Update "Sending password by Nextcloud Talk failed" sentence Signed-off-by: szaimen --- apps/files_sharing/lib/Controller/ShareAPIController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index b323e5514a5..668bbb7cca8 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1161,7 +1161,7 @@ class ShareAPIController extends OCSController { if ($sendPasswordByTalk === 'true') { if (!$this->appManager->isEnabledForUser('spreed')) { - throw new OCSForbiddenException($this->l->t('Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled')); + throw new OCSForbiddenException($this->l->t('"Sending the password by Nextcloud Talk" for sharing a file or folder failed because Nextcloud Talk is not enabled.')); } $share->setSendPasswordByTalk(true); -- cgit v1.2.3 From 3a5918d9324a41b0ed0951ab713b8719385c7972 Mon Sep 17 00:00:00 2001 From: Guillaume Colson Date: Thu, 8 Jul 2021 16:37:27 +0200 Subject: No limit in the number of group shares By default, autoaccept doesn't work if the user has more than 50 group shares Signed-off-by: Guillaume COLSON --- apps/files_sharing/lib/Listener/UserAddedToGroupListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php index 9b2975f5833..1f3898b3dcb 100644 --- a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php +++ b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php @@ -60,7 +60,7 @@ class UserAddedToGroupListener implements IEventListener { } // Get all group shares this user has access to now to filter later - $shares = $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP); + $shares = $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP, null, -1); foreach ($shares as $share) { // If this is not the new group we can skip it -- cgit v1.2.3 From 7130a98e4730c9ba4e40593a958beb3683d02ef1 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 2 Jul 2021 09:58:54 +0200 Subject: Fix received federated group shares Fix pending shares endpoint to consider user-specific sub-entries for group shares whenever a share was accepted or declined. Added unit test for adding remote group shares. Fixed "removeUserShares" to not send a remote request as we never send remote requests for group shares. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/External/Manager.php | 50 +++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index e51bd64cf38..247be47ac90 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -571,15 +571,21 @@ class Manager { */ public function removeUserShares($uid): bool { try { + // TODO: use query builder $getShare = $this->connection->prepare(' - SELECT `remote`, `share_token`, `remote_id` + SELECT `id`, `remote`, `share_type`, `share_token`, `remote_id` FROM `*PREFIX*share_external` WHERE `user` = ?'); $result = $getShare->execute([$uid]); $shares = $result->fetchAll(); $result->closeCursor(); + $deletedGroupShares = []; foreach ($shares as $share) { - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); + if ((int)$share['share_type'] === IShare::TYPE_GROUP) { + $deletedGroupShares[] = $share['id']; + } else { + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); + } } $query = $this->connection->prepare(' @@ -588,6 +594,17 @@ class Manager { '); $deleteResult = $query->execute([$uid]); $deleteResult->closeCursor(); + + // delete sub-entries from deleted parents + foreach ($deletedGroupShares as $deletedId) { + // TODO: batch this with query builder + $query = $this->connection->prepare(' + DELETE FROM `*PREFIX*share_external` + WHERE `parent` = ? + '); + $deleteResult = $query->execute([$deletedId]); + $deleteResult->closeCursor(); + } } catch (\Doctrine\DBAL\Exception $ex) { return false; } @@ -629,14 +646,11 @@ class Manager { $userGroups[] = $group->getGID(); } - $query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted` + // FIXME: use query builder + $query = 'SELECT `id`, `share_type`, `parent`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted` FROM `*PREFIX*share_external` WHERE (`user` = ? OR `user` IN (?))'; - $parameters = [$this->uid, implode(',',$userGroups)]; - if (!is_null($accepted)) { - $query .= ' AND `accepted` = ?'; - $parameters[] = (int) $accepted; - } + $parameters = [$this->uid, implode(',', $userGroups)]; $query .= ' ORDER BY `id` ASC'; $sharesQuery = $this->connection->prepare($query); @@ -644,8 +658,26 @@ class Manager { $result = $sharesQuery->execute($parameters); $shares = $result->fetchAll(); $result->closeCursor(); - return $shares; + + // remove parent group share entry if we have a specific user share entry for the user + $toRemove = []; + foreach ($shares as $share) { + if ((int)$share['share_type'] === IShare::TYPE_GROUP && (int)$share['parent'] > 0) { + $toRemove[] = $share['parent']; + } + } + $shares = array_filter($shares, function ($share) use ($toRemove) { + return !in_array($share['id'], $toRemove, true); + }); + + if (!is_null($accepted)) { + $shares = array_filter($shares, function ($share) use ($accepted) { + return (bool)$share['accepted'] === $accepted; + }); + } + return array_values($shares); } catch (\Doctrine\DBAL\Exception $e) { + // FIXME return []; } } -- cgit v1.2.3 From cff8ae7ded95ca035c7a6ec9fe5c4212273e2b6c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 2 Jul 2021 17:45:03 +0200 Subject: Add logging to external shares manager Instead of just returning false, also log the exception to make debugging database issues easier. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/AppInfo/Application.php | 3 ++- apps/files_sharing/lib/External/Manager.php | 37 +++++++++++++++++--------- apps/files_sharing/lib/Hooks.php | 3 ++- 3 files changed, 28 insertions(+), 15 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 7f234e63660..3975a8a3bde 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -98,7 +98,8 @@ class Application extends App { $server->getGroupManager(), $server->getUserManager(), $uid, - $server->query(IEventDispatcher::class) + $server->query(IEventDispatcher::class), + $server->getLogger() ); }); diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 247be47ac90..de566692d6b 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -14,6 +14,7 @@ * @author Robin Appelman * @author Roeland Jago Douma * @author Stefan Weil + * @author Vincent Petry * * @license AGPL-3.0 * @@ -44,6 +45,7 @@ use OCP\Files\Storage\IStorageFactory; use OCP\Http\Client\IClientService; use OCP\IDBConnection; use OCP\IGroupManager; +use OCP\ILogger; use OCP\IUserManager; use OCP\Notification\IManager; use OCP\OCS\IDiscoveryService; @@ -89,18 +91,24 @@ class Manager { /** @var IEventDispatcher */ private $eventDispatcher; - public function __construct(IDBConnection $connection, - \OC\Files\Mount\Manager $mountManager, - IStorageFactory $storageLoader, - IClientService $clientService, - IManager $notificationManager, - IDiscoveryService $discoveryService, - ICloudFederationProviderManager $cloudFederationProviderManager, - ICloudFederationFactory $cloudFederationFactory, - IGroupManager $groupManager, - IUserManager $userManager, - ?string $uid, - IEventDispatcher $eventDispatcher) { + /** @var ILogger */ + private $logger; + + public function __construct( + IDBConnection $connection, + \OC\Files\Mount\Manager $mountManager, + IStorageFactory $storageLoader, + IClientService $clientService, + IManager $notificationManager, + IDiscoveryService $discoveryService, + ICloudFederationProviderManager $cloudFederationProviderManager, + ICloudFederationFactory $cloudFederationFactory, + IGroupManager $groupManager, + IUserManager $userManager, + ?string $uid, + IEventDispatcher $eventDispatcher, + ILogger $logger + ) { $this->connection = $connection; $this->mountManager = $mountManager; $this->storageLoader = $storageLoader; @@ -113,6 +121,7 @@ class Manager { $this->groupManager = $groupManager; $this->userManager = $userManager; $this->eventDispatcher = $eventDispatcher; + $this->logger = $logger; } /** @@ -535,6 +544,7 @@ class Manager { $this->removeReShares($id); } catch (\Doctrine\DBAL\Exception $ex) { + $this->logger->logException($ex); return false; } @@ -606,6 +616,7 @@ class Manager { $deleteResult->closeCursor(); } } catch (\Doctrine\DBAL\Exception $ex) { + $this->logger->logException($ex); return false; } @@ -677,7 +688,7 @@ class Manager { } return array_values($shares); } catch (\Doctrine\DBAL\Exception $e) { - // FIXME + $this->logger->logException($e); return []; } } diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php index ff4ca59339a..26e799297ff 100644 --- a/apps/files_sharing/lib/Hooks.php +++ b/apps/files_sharing/lib/Hooks.php @@ -43,7 +43,8 @@ class Hooks { \OC::$server->getGroupManager(), \OC::$server->getUserManager(), $params['uid'], - \OC::$server->query(IEventDispatcher::class) + \OC::$server->query(IEventDispatcher::class), + \OC::$server->getLogger() ); $manager->removeUserShares($params['uid']); -- cgit v1.2.3 From 4b5bb4d9cfda9a080861a192524500edfe634ca2 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 2 Jul 2021 17:46:16 +0200 Subject: Fix re-accepting or re-rejecting remote group shares When accepting a group share, a sub-share entry is created which also has a different id. When accepting or rejecting the sub-share, simply update the "accepted" flag instead of trying to re-insert the entry. Adjust getShare to also properly validate group share membership when called on a sub-share id. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/External/Manager.php | 139 +++++++++++++++++++--------- 1 file changed, 97 insertions(+), 42 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index de566692d6b..b67ca675c31 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -227,7 +227,7 @@ class Manager { * @param int $id share id * @return mixed share of false */ - public function getShare($id) { + private function fetchShare($id) { $getShare = $this->connection->prepare(' SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash` FROM `*PREFIX*share_external` @@ -235,14 +235,32 @@ class Manager { $result = $getShare->execute([$id]); $share = $result->fetch(); $result->closeCursor(); + return $share; + } + + /** + * get share + * + * @param int $id share id + * @return mixed share of false + */ + public function getShare($id) { + $share = $this->fetchShare($id); $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'] === IShare::TYPE_USER && $share['user'] === $this->uid) { return $share; } elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) { + $parentId = (int)$share['parent']; + if ($parentId !== -1) { + // we just retrieved a sub-share, switch to the parent entry for verification + $groupShare = $this->fetchShare($parentId); + } else { + $groupShare = $share; + } $user = $this->userManager->get($this->uid); - if ($this->groupManager->get($share['user'])->inGroup($user)) { + if ($this->groupManager->get($groupShare['user'])->inGroup($user)) { return $share; } } @@ -250,6 +268,20 @@ class Manager { return false; } + /** + * Updates accepted flag in the database + * + * @param int $id + */ + private function updateAccepted(int $shareId, bool $accepted) : void { + $query = $this->connection->prepare(' + UPDATE `*PREFIX*share_external` + SET `accepted` = ? + WHERE `id` = ?'); + $updateResult = $query->execute([$accepted ? 1 : 0, $shareId]); + $updateResult->closeCursor(); + } + /** * accept server-to-server share * @@ -277,21 +309,34 @@ class Manager { WHERE `id` = ? AND `user` = ?'); $userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]); } else { - try { - $this->writeShareToDb( - $share['remote'], - $share['share_token'], - $share['password'], - $share['name'], - $share['owner'], - $this->uid, - $mountPoint, $hash, 1, - $share['remote_id'], - $id, - $share['share_type']); - $result = true; - } catch (Exception $e) { - $result = false; + $parentId = (int)$share['parent']; + if ($parentId !== -1) { + // this is the sub-share, simply update it to re-accept + try { + $this->updateAccepted((int)$share['id'], true); + $result = true; + } catch (Exception $e) { + $this->logger->logException($e); + $result = false; + } + } else { + try { + $this->writeShareToDb( + $share['remote'], + $share['share_token'], + $share['password'], + $share['name'], + $share['owner'], + $this->uid, + $mountPoint, $hash, 1, + $share['remote_id'], + $id, + $share['share_type']); + $result = true; + } catch (Exception $e) { + $this->logger->logException($e); + $result = false; + } } } if ($userShareAccepted !== false) { @@ -327,23 +372,38 @@ class Manager { $this->processNotification($id); $result = true; } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) { - try { - $this->writeShareToDb( - $share['remote'], - $share['share_token'], - $share['password'], - $share['name'], - $share['owner'], - $this->uid, - $share['mountpoint'], - $share['mountpoint_hash'], - 0, - $share['remote_id'], - $id, - $share['share_type']); - $result = true; - } catch (Exception $e) { - $result = false; + $parent = (int)$share['parent']; + // can only decline an already accepted/mounted group share, + // check if this is the sub-share entry + if ($parent !== -1) { + try { + // this is the sub-share, simply update it to decline + $this->updateAccepted((int)$share['id'], false); + $result = true; + } catch (Exception $e) { + $this->logger->logException($e); + $result = false; + } + } else { + try { + $this->writeShareToDb( + $share['remote'], + $share['share_token'], + $share['password'], + $share['name'], + $share['owner'], + $this->uid, + $share['mountpoint'], + $share['mountpoint_hash'], + 0, + $share['remote_id'], + $id, + $share['share_type']); + $result = true; + } catch (Exception $e) { + $this->logger->logException($e); + $result = false; + } } $this->processNotification($id); } @@ -528,18 +588,13 @@ class Manager { } $query = $this->connection->prepare(' - DELETE FROM `*PREFIX*share_external` - WHERE `id` = ? + DELETE FROM `*PREFIX*share_external` + WHERE `id` = ? '); $deleteResult = $query->execute([(int)$share['id']]); $deleteResult->closeCursor(); } elseif ($share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) { - $query = $this->connection->prepare(' - UPDATE `*PREFIX*share_external` - SET `accepted` = ? - WHERE `id` = ?'); - $updateResult = $query->execute([0, (int)$share['id']]); - $updateResult->closeCursor(); + $this->updateAccepted((int)$share['id'], false); } $this->removeReShares($id); -- cgit v1.2.3 From 15f41a6b727ba437536fc727778cc41ca710d0d5 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 5 Jul 2021 16:07:02 +0200 Subject: Fix remote group share API interactions Accepting and declining can now be done repeatedly on both the parent group share and sub-share with the same effects. Added unit tests to cover these cases, and also when the same operation is repeated. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/External/Manager.php | 44 +++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index b67ca675c31..082e1adef8a 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -238,6 +238,20 @@ class Manager { return $share; } + private function fetchUserShare($parentId, $uid) { + $getShare = $this->connection->prepare(' + SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash` + FROM `*PREFIX*share_external` + WHERE `parent` = ? AND `user` = ?'); + $result = $getShare->execute([$parentId, $uid]); + $share = $result->fetch(); + $result->closeCursor(); + if ($share !== false) { + return $share; + } + return null; + } + /** * get share * @@ -311,9 +325,15 @@ class Manager { } else { $parentId = (int)$share['parent']; if ($parentId !== -1) { - // this is the sub-share, simply update it to re-accept + // this is the sub-share + $subshare = $share; + } else { + $subshare = $this->fetchUserShare($id, $this->uid); + } + + if ($subshare !== null) { try { - $this->updateAccepted((int)$share['id'], true); + $this->updateAccepted((int)$subshare['id'], true); $result = true; } catch (Exception $e) { $this->logger->logException($e); @@ -372,13 +392,17 @@ class Manager { $this->processNotification($id); $result = true; } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) { - $parent = (int)$share['parent']; - // can only decline an already accepted/mounted group share, - // check if this is the sub-share entry - if ($parent !== -1) { + $parentId = (int)$share['parent']; + if ($parentId !== -1) { + // this is the sub-share + $subshare = $share; + } else { + $subshare = $this->fetchUserShare($id, $this->uid); + } + + if ($subshare !== null) { try { - // this is the sub-share, simply update it to decline - $this->updateAccepted((int)$share['id'], false); + $this->updateAccepted((int)$subshare['id'], false); $result = true; } catch (Exception $e) { $this->logger->logException($e); @@ -566,6 +590,10 @@ class Manager { public function removeShare($mountPoint): bool { $mountPointObj = $this->mountManager->find($mountPoint); + if ($mountPointObj === null) { + $this->logger->error('Mount point to remove share not found', ['mountPoint' => $mountPoint]); + return false; + } $id = $mountPointObj->getStorage()->getCache()->getId(''); $mountPoint = $this->stripPath($mountPoint); -- cgit v1.2.3 From e8f4a524a2ae917c62710dd635df2740081bc83f Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 13 Jul 2021 17:51:52 +0200 Subject: Fix external share manager with multiple user groups Use query builder with proper matching for finding the group names. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/External/Manager.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 082e1adef8a..fdc02f104af 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -37,6 +37,7 @@ use Doctrine\DBAL\Driver\Exception; use OC\Files\Filesystem; use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent; use OCA\Files_Sharing\Helper; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; @@ -740,16 +741,22 @@ class Manager { $userGroups[] = $group->getGID(); } - // FIXME: use query builder - $query = 'SELECT `id`, `share_type`, `parent`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted` - FROM `*PREFIX*share_external` - WHERE (`user` = ? OR `user` IN (?))'; - $parameters = [$this->uid, implode(',', $userGroups)]; - $query .= ' ORDER BY `id` ASC'; + $qb = $this->connection->getQueryBuilder(); + $qb->select('id', 'share_type', 'parent', 'remote', 'remote_id', 'share_token', 'name', 'owner', 'user', 'mountpoint', 'accepted') + ->from('share_external') + ->where( + $qb->expr()->orX( + $qb->expr()->eq('user', $qb->createNamedParameter($this->uid)), + $qb->expr()->in( + 'user', + $qb->createNamedParameter($userGroups, IQueryBuilder::PARAM_STR_ARRAY) + ) + ) + ) + ->orderBy('id', 'ASC'); - $sharesQuery = $this->connection->prepare($query); try { - $result = $sharesQuery->execute($parameters); + $result = $qb->execute(); $shares = $result->fetchAll(); $result->closeCursor(); -- cgit v1.2.3 From e67e90afce36edb18cebbc5f5799e427b891e114 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 20 Jul 2021 16:42:19 +0200 Subject: Fix remote group share decline+accept code path When declining a remote group share through the dialog that appears when notifications are off, the mount point is now correctly saved when re-accepting. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/External/Manager.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index fdc02f104af..b74198c8793 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -334,7 +334,13 @@ class Manager { if ($subshare !== null) { try { - $this->updateAccepted((int)$subshare['id'], true); + $acceptShare = $this->connection->prepare(' + UPDATE `*PREFIX*share_external` + SET `accepted` = ?, + `mountpoint` = ?, + `mountpoint_hash` = ? + WHERE `id` = ? AND `user` = ?'); + $acceptShare->execute([1, $mountPoint, $hash, $subshare['id'], $this->uid]); $result = true; } catch (Exception $e) { $this->logger->logException($e); -- cgit v1.2.3 From dac676c14ef7a3bd866a674c2ced666435d977c6 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 20 Jul 2021 20:36:26 +0200 Subject: Replace ILogger with LoggerInterface in remote share manager Signed-off-by: Vincent Petry Co-authored-by: Carl Schwan --- apps/files_sharing/lib/AppInfo/Application.php | 3 ++- apps/files_sharing/lib/External/Manager.php | 20 ++++++++++---------- apps/files_sharing/lib/Hooks.php | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 3975a8a3bde..2dfbe4d86a5 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -60,6 +60,7 @@ use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\IManager; use OCP\Util; use Psr\Container\ContainerInterface; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -99,7 +100,7 @@ class Application extends App { $server->getUserManager(), $uid, $server->query(IEventDispatcher::class), - $server->getLogger() + $server->get(LoggerInterface::class) ); }); diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index b74198c8793..a8b01a74464 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -46,12 +46,12 @@ use OCP\Files\Storage\IStorageFactory; use OCP\Http\Client\IClientService; use OCP\IDBConnection; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUserManager; use OCP\Notification\IManager; use OCP\OCS\IDiscoveryService; use OCP\Share; use OCP\Share\IShare; +use Psr\Log\LoggerInterface; class Manager { public const STORAGE = '\OCA\Files_Sharing\External\Storage'; @@ -92,7 +92,7 @@ class Manager { /** @var IEventDispatcher */ private $eventDispatcher; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct( @@ -108,7 +108,7 @@ class Manager { IUserManager $userManager, ?string $uid, IEventDispatcher $eventDispatcher, - ILogger $logger + LoggerInterface $logger ) { $this->connection = $connection; $this->mountManager = $mountManager; @@ -343,7 +343,7 @@ class Manager { $acceptShare->execute([1, $mountPoint, $hash, $subshare['id'], $this->uid]); $result = true; } catch (Exception $e) { - $this->logger->logException($e); + $this->logger->emergency('Could not update share', ['exception' => $e]); $result = false; } } else { @@ -361,7 +361,7 @@ class Manager { $share['share_type']); $result = true; } catch (Exception $e) { - $this->logger->logException($e); + $this->logger->emergency('Could not create share', ['exception' => $e]); $result = false; } } @@ -412,7 +412,7 @@ class Manager { $this->updateAccepted((int)$subshare['id'], false); $result = true; } catch (Exception $e) { - $this->logger->logException($e); + $this->logger->emergency('Could not update share', ['exception' => $e]); $result = false; } } else { @@ -432,7 +432,7 @@ class Manager { $share['share_type']); $result = true; } catch (Exception $e) { - $this->logger->logException($e); + $this->logger->emergency('Could not create share', ['exception' => $e]); $result = false; } } @@ -634,7 +634,7 @@ class Manager { $this->removeReShares($id); } catch (\Doctrine\DBAL\Exception $ex) { - $this->logger->logException($ex); + $this->logger->emergency('Could not update share', ['exception' => $ex]); return false; } @@ -706,7 +706,7 @@ class Manager { $deleteResult->closeCursor(); } } catch (\Doctrine\DBAL\Exception $ex) { - $this->logger->logException($ex); + $this->logger->emergency('Could not get shares', ['exception' => $ex]); return false; } @@ -784,7 +784,7 @@ class Manager { } return array_values($shares); } catch (\Doctrine\DBAL\Exception $e) { - $this->logger->logException($e); + $this->logger->emergency('Error when retrieving shares', ['exception' => $e]); return []; } } diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php index 26e799297ff..f28f6910abd 100644 --- a/apps/files_sharing/lib/Hooks.php +++ b/apps/files_sharing/lib/Hooks.php @@ -28,6 +28,7 @@ namespace OCA\Files_Sharing; use OC\Files\Filesystem; use OCP\EventDispatcher\IEventDispatcher; +use Psr\Log\LoggerInterface; class Hooks { public static function deleteUser($params) { @@ -44,7 +45,7 @@ class Hooks { \OC::$server->getUserManager(), $params['uid'], \OC::$server->query(IEventDispatcher::class), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) ); $manager->removeUserShares($params['uid']); -- cgit v1.2.3 From f6f2f63016e8183c7054fb28007a7d51666d8475 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 27 Jul 2021 14:32:51 +0200 Subject: Fix remote share deletion when deleting user When deleting a user, we should only delete the direct remote user shares or the remote group based subshares. Signed-off-by: Vincent Petry --- apps/files_sharing/lib/External/Manager.php | 77 ++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 23 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index a8b01a74464..f9ef35b558c 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -675,38 +675,69 @@ class Manager { $getShare = $this->connection->prepare(' SELECT `id`, `remote`, `share_type`, `share_token`, `remote_id` FROM `*PREFIX*share_external` - WHERE `user` = ?'); - $result = $getShare->execute([$uid]); + WHERE `user` = ? + AND `share_type` = ?'); + $result = $getShare->execute([$uid, IShare::TYPE_USER]); $shares = $result->fetchAll(); $result->closeCursor(); - $deletedGroupShares = []; + foreach ($shares as $share) { - if ((int)$share['share_type'] === IShare::TYPE_GROUP) { - $deletedGroupShares[] = $share['id']; - } else { - $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); - } + $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline'); } - $query = $this->connection->prepare(' - DELETE FROM `*PREFIX*share_external` + $qb = $this->connection->getQueryBuilder(); + $qb->delete('share_external') + // user field can specify a user or a group + ->where($qb->expr()->eq('user', $qb->createNamedParameter($uid))) + ->andWhere( + $qb->expr()->orX( + // delete direct shares + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_USER)), + // delete sub-shares of group shares for that user + $qb->expr()->andX( + $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_GROUP)), + $qb->expr()->neq('parent', $qb->expr()->literal(-1)), + ) + ) + ); + $qb->execute(); + } catch (\Doctrine\DBAL\Exception $ex) { + $this->logger->emergency('Could not delete user shares', ['exception' => $ex]); + return false; + } + + return true; + } + + public function removeGroupShares($gid): bool { + try { + $getShare = $this->connection->prepare(' + SELECT `id`, `remote`, `share_type`, `share_token`, `remote_id` + FROM `*PREFIX*share_external` WHERE `user` = ? - '); - $deleteResult = $query->execute([$uid]); - $deleteResult->closeCursor(); + AND `share_type` = ?'); + $result = $getShare->execute([$gid, IShare::TYPE_GROUP]); + $shares = $result->fetchAll(); + $result->closeCursor(); - // delete sub-entries from deleted parents - foreach ($deletedGroupShares as $deletedId) { - // TODO: batch this with query builder - $query = $this->connection->prepare(' - DELETE FROM `*PREFIX*share_external` - WHERE `parent` = ? - '); - $deleteResult = $query->execute([$deletedId]); - $deleteResult->closeCursor(); + $deletedGroupShares = []; + $qb = $this->connection->getQueryBuilder(); + // delete group share entry and matching sub-entries + $qb->delete('share_external') + ->where( + $qb->expr()->orX( + $qb->expr()->eq('id', $qb->createParameter('share_id')), + $qb->expr()->eq('parent', $qb->createParameter('share_parent_id')) + ) + ); + + foreach ($shares as $share) { + $qb->setParameter('share_id', $share['id']); + $qb->setParameter('share_parent_id', $share['id']); + $qb->execute(); } } catch (\Doctrine\DBAL\Exception $ex) { - $this->logger->emergency('Could not get shares', ['exception' => $ex]); + $this->logger->emergency('Could not delete user shares', ['exception' => $ex]); return false; } -- cgit v1.2.3 From 8597d9c7d40a0bc56622d9b2b1aa7925ea09b686 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 9 Aug 2021 15:53:09 +0200 Subject: add event for when a share is mounted Signed-off-by: Robin Appelman --- apps/files_sharing/lib/Event/ShareMountedEvent.php | 56 ++++++++++++++++++++++ apps/files_sharing/lib/MountProvider.php | 20 +++++++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 apps/files_sharing/lib/Event/ShareMountedEvent.php (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Event/ShareMountedEvent.php b/apps/files_sharing/lib/Event/ShareMountedEvent.php new file mode 100644 index 00000000000..15184827389 --- /dev/null +++ b/apps/files_sharing/lib/Event/ShareMountedEvent.php @@ -0,0 +1,56 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Files_Sharing\Event; + +use OCA\Files_Sharing\SharedMount; +use OCP\EventDispatcher\Event; +use OCP\Files\Mount\IMountPoint; + +class ShareMountedEvent extends Event { + /** @var SharedMount */ + private $mount; + + /** @var IMountPoint[] */ + private $additionalMounts = []; + + public function __construct(SharedMount $mount) { + parent::__construct(); + $this->mount = $mount; + } + + public function getMount(): SharedMount { + return $this->mount; + } + + public function addAdditionalMount(IMountPoint $mountPoint): void { + $this->additionalMounts[] = $mountPoint; + } + + /** + * @return IMountPoint[] + */ + public function getAdditionalMounts(): array { + return $this->additionalMounts; + } +} diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 42541b77f2d..102e5d96559 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -30,6 +30,8 @@ namespace OCA\Files_Sharing; use OC\Cache\CappedMemoryCache; use OC\Files\View; +use OCA\Files_Sharing\Event\ShareMountedEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\IMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; @@ -54,15 +56,24 @@ class MountProvider implements IMountProvider { */ protected $logger; + /** @var IEventDispatcher */ + protected $eventDispatcher; + /** * @param \OCP\IConfig $config * @param IManager $shareManager * @param ILogger $logger */ - public function __construct(IConfig $config, IManager $shareManager, ILogger $logger) { + public function __construct( + IConfig $config, + IManager $shareManager, + ILogger $logger, + IEventDispatcher $eventDispatcher + ) { $this->config = $config; $this->shareManager = $shareManager; $this->logger = $logger; + $this->eventDispatcher = $eventDispatcher; } @@ -125,7 +136,14 @@ class MountProvider implements IMountProvider { $view, $foldersExistCache ); + + $event = new ShareMountedEvent($mount); + $this->eventDispatcher->dispatchTyped($event); + $mounts[$mount->getMountPoint()] = $mount; + foreach ($event->getAdditionalMounts() as $additionalMount) { + $mounts[$additionalMount->getMountPoint()] = $additionalMount; + } } catch (\Exception $e) { $this->logger->logException($e); $this->logger->error('Error while trying to create shared mount'); -- cgit v1.2.3 From 961f8958c0df8e60ca9fda88d5f46526534eecd9 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sun, 25 Jul 2021 17:57:11 +0200 Subject: Let users choose a share_folder --- .../lib/Controller/SettingsController.php | 22 +++++++++++++++++++++- apps/files_sharing/lib/External/Manager.php | 2 +- apps/files_sharing/lib/Helper.php | 20 +++++++++++++++++--- apps/files_sharing/lib/Settings/Personal.php | 7 +++++++ apps/files_sharing/lib/SharedMount.php | 2 +- 5 files changed, 47 insertions(+), 6 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/SettingsController.php b/apps/files_sharing/lib/Controller/SettingsController.php index 8f542ecb071..00d627095b8 100644 --- a/apps/files_sharing/lib/Controller/SettingsController.php +++ b/apps/files_sharing/lib/Controller/SettingsController.php @@ -6,6 +6,7 @@ declare(strict_types=1); * @copyright Copyright (c) 2019, Roeland Jago Douma * * @author Roeland Jago Douma + * @author Hinrich Mahler * * @license GNU AGPL version 3 or any later version * @@ -35,10 +36,13 @@ class SettingsController extends Controller { /** @var IConfig */ private $config; + /** @var string */ private $userId; - public function __construct(IRequest $request, IConfig $config, string $userId) { + public function __construct(IRequest $request, + IConfig $config, + string $userId) { parent::__construct(Application::APP_ID, $request); $this->config = $config; @@ -52,4 +56,20 @@ class SettingsController extends Controller { $this->config->setUserValue($this->userId, Application::APP_ID, 'default_accept', $accept ? 'yes' : 'no'); return new JSONResponse(); } + + /** + * @NoAdminRequired + */ + public function setUserShareFolder(string $shareFolder): JSONResponse { + $this->config->setUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolder); + return new JSONResponse(); + } + + /** + * @NoAdminRequired + */ + public function resetUserShareFolder(): JSONResponse { + $this->config->deleteUserValue($this->userId, Application::APP_ID, 'share_folder'); + return new JSONResponse(); + } } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index f9ef35b558c..d967f40cc32 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -309,7 +309,7 @@ class Manager { if ($share) { \OC_Util::setupFS($this->uid); - $shareFolder = Helper::getShareFolder(); + $shareFolder = Helper::getShareFolder(null, $this->uid); $mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']); $mountPoint = Filesystem::normalizePath($mountPoint); $hash = md5($mountPoint); diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index d8e58e84b7d..931301a04c4 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -29,6 +29,7 @@ namespace OCA\Files_Sharing; use OC\Files\Filesystem; use OC\Files\View; +use OCA\Files_Sharing\AppInfo\Application; class Helper { public static function registerHooks() { @@ -63,16 +64,29 @@ class Helper { /** * get default share folder * - * @param \OC\Files\View $view + * @param \OC\Files\View|null $view + * @param string|null $userId * @return string */ - public static function getShareFolder($view = null) { + public static function getShareFolder(View $view = null, string $userId = null): string { if ($view === null) { $view = Filesystem::getView(); } - $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/'); + + $config = \OC::$server->getConfig(); + $systemDefault = $config->getSystemValue('share_folder', '/'); + $allowCustomShareFolder = $config->getSystemValueBool('sharing.allow_custom_share_folder', true); + + // Init custom shareFolder + $shareFolder = $systemDefault; + if ($userId !== null && $allowCustomShareFolder) { + $shareFolder = $config->getUserValue($userId, Application::APP_ID, 'share_folder', $systemDefault); + } + + // Verify and sanitize path $shareFolder = Filesystem::normalizePath($shareFolder); + // Init path if folder doesn't exists if (!$view->file_exists($shareFolder)) { $dir = ''; $subdirs = explode('/', $shareFolder); diff --git a/apps/files_sharing/lib/Settings/Personal.php b/apps/files_sharing/lib/Settings/Personal.php index 3917001e882..d3886321f97 100644 --- a/apps/files_sharing/lib/Settings/Personal.php +++ b/apps/files_sharing/lib/Settings/Personal.php @@ -7,6 +7,7 @@ declare(strict_types=1); * * @author Julius Härtl * @author Roeland Jago Douma + * @author Hinrich Mahler * * @license GNU AGPL version 3 or any later version * @@ -49,10 +50,16 @@ class Personal implements ISettings { public function getForm(): TemplateResponse { $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes'; + $shareFolderSystemConfig = $this->config->getSystemValue('share_folder', '/'); $acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes'; $enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false); + $allowCustomDirectory = $this->config->getSystemValueBool('sharing.allow_custom_share_folder', true); + $shareFolderDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolderSystemConfig); $this->initialState->provideInitialState('accept_default', $acceptDefault); $this->initialState->provideInitialState('enforce_accept', $enforceAccept); + $this->initialState->provideInitialState('allow_custom_share_folder', $allowCustomDirectory); + $this->initialState->provideInitialState('share_folder', $shareFolderDefault); + $this->initialState->provideInitialState('default_share_folder', $shareFolderSystemConfig); return new TemplateResponse('files_sharing', 'Settings/personal'); } diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 8443ccb8439..7fd477d07e4 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -105,7 +105,7 @@ class SharedMount extends MountPoint implements MoveableMount { $folderExistCache->set($parent, $parentExists); } if (!$parentExists) { - $parent = Helper::getShareFolder($this->recipientView); + $parent = Helper::getShareFolder($this->recipientView, $this->user); } $newMountPoint = $this->generateUniqueTarget( -- cgit v1.2.3 From 27865d03c014e3b644408c32967cc7e7a56bf692 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 1 Sep 2021 15:41:02 +0200 Subject: use specific email getter where necessary Signed-off-by: Arthur Schiwon --- apps/files_sharing/lib/Controller/ShareAPIController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 668bbb7cca8..c9853f1e12c 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -238,7 +238,7 @@ class ShareAPIController extends OCSController { $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith(); $result['share_with_displayname_unique'] = $sharedWith !== null ? ( - $sharedWith->getEMailAddress() !== '' ? $sharedWith->getEMailAddress() : $sharedWith->getUID() + !empty($sharedWith->getSystemEMailAddress()) ? $sharedWith->getSystemEMailAddress() : $sharedWith->getUID() ) : $share->getSharedWith(); $result['status'] = []; -- cgit v1.2.3 From c56c317d82e6015739549a606578e963578f4de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Wed, 8 Sep 2021 20:04:37 +0200 Subject: Emit event on link share action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- .../lib/Controller/ShareController.php | 34 ++++++++++- .../lib/Event/ShareLinkAccessedEvent.php | 68 ++++++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 95c3303ae74..614dae7ffba 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -48,6 +48,7 @@ use OC_Util; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Activity\Providers\Downloads; use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; +use OCA\Files_Sharing\Event\ShareLinkAccessedEvent; use OCA\Viewer\Event\LoadViewer; use OCP\Accounts\IAccountManager; use OCP\AppFramework\AuthPublicShareController; @@ -162,6 +163,10 @@ class ShareController extends AuthPublicShareController { $this->shareManager = $shareManager; } + public const SHARE_ACCESS = 'access'; + public const SHARE_AUTH = 'auth'; + public const SHARE_DOWNLOAD = 'download'; + /** * @PublicPage * @NoCSRFRequired @@ -233,6 +238,7 @@ class ShareController extends AuthPublicShareController { protected function authFailed() { $this->emitAccessShareHook($this->share, 403, 'Wrong password'); + $this->emitShareAccessEvent($this->share, self::SHARE_AUTH, 403, 'Wrong password'); } /** @@ -242,10 +248,13 @@ class ShareController extends AuthPublicShareController { * otherwise token * @param int $errorCode * @param string $errorMessage + * * @throws \OCP\HintException * @throws \OC\ServerNotAvailableException + * + * @deprecated use OCP\Files_Sharing\Event\ShareLinkAccessedEvent */ - protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') { + protected function emitAccessShareHook($share, int $errorCode = 200, string $errorMessage = '') { $itemType = $itemSource = $uidOwner = ''; $token = $share; $exception = null; @@ -260,19 +269,33 @@ class ShareController extends AuthPublicShareController { $exception = $e; } } + \OC_Hook::emit(Share::class, 'share_link_access', [ 'itemType' => $itemType, 'itemSource' => $itemSource, 'uidOwner' => $uidOwner, 'token' => $token, 'errorCode' => $errorCode, - 'errorMessage' => $errorMessage, + 'errorMessage' => $errorMessage ]); + if (!is_null($exception)) { throw $exception; } } + /** + * Emit a ShareLinkAccessedEvent event when a share is accessed, downloaded, auth... + */ + protected function emitShareAccessEvent(IShare $share, string $step = '', int $errorCode = 200, string $errorMessage = ''): void { + if ($step !== self::SHARE_ACCESS && + $step !== self::SHARE_AUTH && + $step !== self::SHARE_DOWNLOAD) { + return; + } + $this->eventDispatcher->dispatchTyped(new ShareLinkAccessedEvent($share, $step, $errorCode, $errorMessage)); + } + /** * Validate the permissions of the share * @@ -312,6 +335,7 @@ class ShareController extends AuthPublicShareController { try { $share = $this->shareManager->getShareByToken($this->getToken()); } catch (ShareNotFound $e) { + // The share does not exists, we do not emit an ShareLinkAccessedEvent $this->emitAccessShareHook($this->getToken(), 404, 'Share not found'); throw new NotFoundException(); } @@ -326,10 +350,12 @@ class ShareController extends AuthPublicShareController { try { if ($shareNode instanceof \OCP\Files\File && $path !== '') { $this->emitAccessShareHook($share, 404, 'Share not found'); + $this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found'); throw new NotFoundException(); } } catch (\Exception $e) { $this->emitAccessShareHook($share, 404, 'Share not found'); + $this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found'); throw $e; } @@ -371,6 +397,7 @@ class ShareController extends AuthPublicShareController { $folderNode = $shareNode->get($path); } catch (\OCP\Files\NotFoundException $e) { $this->emitAccessShareHook($share, 404, 'Share not found'); + $this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found'); throw new NotFoundException(); } @@ -534,6 +561,7 @@ class ShareController extends AuthPublicShareController { $response->setContentSecurityPolicy($csp); $this->emitAccessShareHook($share); + $this->emitShareAccessEvent($share, self::SHARE_ACCESS); return $response; } @@ -596,6 +624,7 @@ class ShareController extends AuthPublicShareController { $node = $node->get($path); } catch (NotFoundException $e) { $this->emitAccessShareHook($share, 404, 'Share not found'); + $this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD, 404, 'Share not found'); return new NotFoundResponse(); } } @@ -637,6 +666,7 @@ class ShareController extends AuthPublicShareController { } $this->emitAccessShareHook($share); + $this->emitShareAccessEvent($share, self::SHARE_DOWNLOAD); $server_params = [ 'head' => $this->request->getMethod() === 'HEAD' ]; diff --git a/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php b/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php new file mode 100644 index 00000000000..490ada1eef2 --- /dev/null +++ b/apps/files_sharing/lib/Event/ShareLinkAccessedEvent.php @@ -0,0 +1,68 @@ + + * + * @author John Molakvoæ + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Files_Sharing\Event; + +use OCP\EventDispatcher\Event; +use OCP\Share\IShare; + +class ShareLinkAccessedEvent extends Event { + /** @var IShare */ + private $share; + + /** @var string */ + private $step; + + /** @var int */ + private $errorCode; + + /** @var string */ + private $errorMessage; + + public function __construct(IShare $share, string $step = '', int $errorCode = 200, string $errorMessage = '') { + parent::__construct(); + $this->share = $share; + $this->step = $step; + $this->errorCode = $errorCode; + $this->errorMessage = $errorMessage; + } + + public function getShare(): IShare { + return $this->share; + } + + public function getStep(): string { + return $this->step; + } + + public function getErrorCode(): int { + return $this->errorCode; + } + + public function getErrorMessage(): string { + return $this->errorMessage; + } +} -- cgit v1.2.3 From 719480ad9d74f002065d5661ff1f9fc8ce6ad301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 12 Aug 2021 08:07:18 +0200 Subject: Return proper watcher if SharedStorage originates from ExternalMount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files_sharing/lib/SharedStorage.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index f4a525ce871..66f883e106c 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -34,10 +34,12 @@ namespace OCA\Files_Sharing; use OC\Files\Cache\FailedCache; use OC\Files\Cache\NullWatcher; +use OC\Files\Cache\Watcher; use OC\Files\Filesystem; use OC\Files\Storage\FailedStorage; use OC\Files\Storage\Wrapper\PermissionsMask; use OC\User\NoUserException; +use OCA\Files_External\Config\ExternalMountPoint; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; use OCP\Files\NotFoundException; @@ -405,7 +407,20 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto return $this->superShare->getShareOwner(); } - public function getWatcher($path = '', $storage = null): NullWatcher { + public function getWatcher($path = '', $storage = null): Watcher { + $mountManager = \OC::$server->getMountManager(); + + // Get node informations + $node = $this->getShare()->getNodeCacheEntry(); + if ($node) { + $mount = $mountManager->findByNumericId($node->getStorageId()); + // If the share is originating from an external storage + if (count($mount) > 0 && $mount[0] instanceof ExternalMountPoint) { + // Propagate original storage scan + return parent::getWatcher($path, $storage); + } + } + // cache updating is handled by the share source return new NullWatcher(); } -- cgit v1.2.3 From ab275c5e38de80b6cbc1a60890d8076f5075cace Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 4 Aug 2021 18:59:47 +0200 Subject: move files_sharing to IBootStrap Signed-off-by: Robin Appelman --- apps/files_sharing/lib/AppInfo/Application.php | 84 +++++++++----------------- apps/files_sharing/lib/External/Manager.php | 31 +++++----- 2 files changed, 47 insertions(+), 68 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 2dfbe4d86a5..9d2ddec544a 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -29,10 +29,11 @@ */ namespace OCA\Files_Sharing\AppInfo; -use OC\AppFramework\Utility\SimpleContainer; +use OC\Share\Share; use OCA\Files_Sharing\Capabilities; use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Files_Sharing\External\Manager; +use OCA\Files_Sharing\Helper; use OCA\Files_Sharing\Listener\LegacyBeforeTemplateRenderedListener; use OCA\Files_Sharing\Listener\LoadAdditionalListener; use OCA\Files_Sharing\Listener\LoadSidebarListener; @@ -47,71 +48,35 @@ use OCA\Files_Sharing\Notification\Listener; use OCA\Files_Sharing\Notification\Notifier; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSidebar; +use OCA\Files_Sharing\ShareBackend\File; +use OCA\Files_Sharing\ShareBackend\Folder; use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\ICloudIdManager; use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\UserAddedEvent; use OCP\IDBConnection; use OCP\IGroup; -use OCP\IServerContainer; use OCP\IUserSession; use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\IManager; use OCP\Util; use Psr\Container\ContainerInterface; -use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; -class Application extends App { +class Application extends App implements IBootstrap { public const APP_ID = 'files_sharing'; public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); + } - $container = $this->getContainer(); - - /** @var IServerContainer $server */ - $server = $container->getServer(); - - /** @var IEventDispatcher $dispatcher */ - $dispatcher = $container->query(IEventDispatcher::class); - $oldDispatcher = $container->getServer()->getEventDispatcher(); - $mountProviderCollection = $server->getMountProviderCollection(); - $notifications = $server->getNotificationManager(); - - /** - * Core class wrappers - */ - $container->registerService(Manager::class, function (SimpleContainer $c) use ($server) { - $user = $server->getUserSession()->getUser(); - $uid = $user ? $user->getUID() : null; - return new \OCA\Files_Sharing\External\Manager( - $server->getDatabaseConnection(), - \OC\Files\Filesystem::getMountManager(), - \OC\Files\Filesystem::getLoader(), - $server->getHTTPClientService(), - $server->getNotificationManager(), - $server->query(\OCP\OCS\IDiscoveryService::class), - $server->getCloudFederationProviderManager(), - $server->getCloudFederationFactory(), - $server->getGroupManager(), - $server->getUserManager(), - $uid, - $server->query(IEventDispatcher::class), - $server->get(LoggerInterface::class) - ); - }); - - /** - * Middleware - */ - $container->registerMiddleWare(SharingCheckMiddleware::class); - $container->registerMiddleWare(OCSShareAPIMiddleware::class); - $container->registerMiddleWare(ShareInfoMiddleware::class); - - $container->registerService('ExternalMountProvider', function (ContainerInterface $c) { + public function register(IRegistrationContext $context): void { + $context->registerService('ExternalMountProvider', function (ContainerInterface $c) { return new \OCA\Files_Sharing\External\MountProvider( $c->get(IDBConnection::class), function () use ($c) { @@ -122,15 +87,25 @@ class Application extends App { }); /** - * Register capabilities + * Middleware */ - $container->registerCapability(Capabilities::class); + $context->registerMiddleWare(SharingCheckMiddleware::class); + $context->registerMiddleWare(OCSShareAPIMiddleware::class); + $context->registerMiddleWare(ShareInfoMiddleware::class); - $notifications->registerNotifierService(Notifier::class); + $context->registerCapability(Capabilities::class); - $this->registerMountProviders($mountProviderCollection); - $this->registerEventsScripts($dispatcher, $oldDispatcher); - $this->setupSharingMenus(); + $context->registerNotifierService(Notifier::class); + } + + public function boot(IBootContext $context): void { + $context->injectFn([$this, 'registerMountProviders']); + $context->injectFn([$this, 'registerEventsScripts']); + + Helper::registerHooks(); + + Share::registerBackend('file', File::class); + Share::registerBackend('folder', Folder::class, 'file'); /** * Always add main sharing script @@ -138,12 +113,13 @@ class Application extends App { Util::addScript(self::APP_ID, 'dist/main'); } - protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { + + public function registerMountProviders(IMountProviderCollection $mountProviderCollection) { $mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class)); $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); } - protected function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher) { + public function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher) { // sidebar and files scripts $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class); diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index d967f40cc32..a48e2a63ae4 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -31,6 +31,7 @@ * along with this program. If not, see * */ + namespace OCA\Files_Sharing\External; use Doctrine\DBAL\Driver\Exception; @@ -47,6 +48,7 @@ use OCP\Http\Client\IClientService; use OCP\IDBConnection; use OCP\IGroupManager; use OCP\IUserManager; +use OCP\IUserSession; use OCP\Notification\IManager; use OCP\OCS\IDiscoveryService; use OCP\Share; @@ -83,7 +85,7 @@ class Manager { /** @var ICloudFederationFactory */ private $cloudFederationFactory; - /** @var IGroupManager */ + /** @var IGroupManager */ private $groupManager; /** @var IUserManager */ @@ -96,25 +98,26 @@ class Manager { private $logger; public function __construct( - IDBConnection $connection, - \OC\Files\Mount\Manager $mountManager, - IStorageFactory $storageLoader, - IClientService $clientService, - IManager $notificationManager, - IDiscoveryService $discoveryService, + IDBConnection $connection, + \OC\Files\Mount\Manager $mountManager, + IStorageFactory $storageLoader, + IClientService $clientService, + IManager $notificationManager, + IDiscoveryService $discoveryService, ICloudFederationProviderManager $cloudFederationProviderManager, - ICloudFederationFactory $cloudFederationFactory, - IGroupManager $groupManager, - IUserManager $userManager, - ?string $uid, - IEventDispatcher $eventDispatcher, - LoggerInterface $logger + ICloudFederationFactory $cloudFederationFactory, + IGroupManager $groupManager, + IUserManager $userManager, + IUserSession $userSession, + IEventDispatcher $eventDispatcher, + LoggerInterface $logger ) { + $user = $userSession->getUser(); $this->connection = $connection; $this->mountManager = $mountManager; $this->storageLoader = $storageLoader; $this->clientService = $clientService; - $this->uid = $uid; + $this->uid = $user ? $user->getUID() : null; $this->notificationManager = $notificationManager; $this->discoveryService = $discoveryService; $this->cloudFederationProviderManager = $cloudFederationProviderManager; -- cgit v1.2.3 From 4b82d8d20c5222d0f36b792f3a252c81cbacbb59 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 9 Aug 2021 16:06:23 +0200 Subject: call setupSharingMenus again Signed-off-by: Robin Appelman --- apps/files_sharing/lib/AppInfo/Application.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 9d2ddec544a..7a432650f12 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -33,6 +33,7 @@ use OC\Share\Share; use OCA\Files_Sharing\Capabilities; use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Files_Sharing\External\Manager; +use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider; use OCA\Files_Sharing\Helper; use OCA\Files_Sharing\Listener\LegacyBeforeTemplateRenderedListener; use OCA\Files_Sharing\Listener\LoadAdditionalListener; @@ -60,7 +61,9 @@ use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\UserAddedEvent; use OCP\IDBConnection; use OCP\IGroup; +use OCP\INavigationManager; use OCP\IUserSession; +use OCP\L10N\IFactory; use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\IManager; use OCP\Util; @@ -76,8 +79,8 @@ class Application extends App implements IBootstrap { } public function register(IRegistrationContext $context): void { - $context->registerService('ExternalMountProvider', function (ContainerInterface $c) { - return new \OCA\Files_Sharing\External\MountProvider( + $context->registerService(ExternalMountProvider::class, function (ContainerInterface $c) { + return new ExternalMountProvider( $c->get(IDBConnection::class), function () use ($c) { return $c->get(Manager::class); @@ -101,6 +104,7 @@ class Application extends App implements IBootstrap { public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerMountProviders']); $context->injectFn([$this, 'registerEventsScripts']); + $context->injectFn([$this, 'setupSharingMenus']); Helper::registerHooks(); @@ -114,9 +118,9 @@ class Application extends App implements IBootstrap { } - public function registerMountProviders(IMountProviderCollection $mountProviderCollection) { - $mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class)); - $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); + public function registerMountProviders(IMountProviderCollection $mountProviderCollection, MountProvider $mountProvider, ExternalMountProvider $externalMountProvider) { + $mountProviderCollection->registerProvider($mountProvider); + $mountProviderCollection->registerProvider($externalMountProvider); } public function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher) { @@ -144,19 +148,14 @@ class Application extends App implements IBootstrap { }); } - protected function setupSharingMenus() { - /** @var IManager $shareManager */ - $shareManager = \OC::$server->get(IManager::class); - + public function setupSharingMenus(INavigationManager $navigationManager, IManager $shareManager, IFactory $l10nFactory, IUserSession $userSession) { if (!$shareManager->shareApiEnabled() || !class_exists('\OCA\Files\App')) { return; } // show_Quick_Access stored as string - \OCA\Files\App::getNavigationManager()->add(function () use ($shareManager) { - $l = \OC::$server->getL10N('files_sharing'); - /** @var IUserSession $userSession */ - $userSession = \OC::$server->get(IUserSession::class); + $navigationManager->add(function () use ($shareManager, $l10nFactory, $userSession) { + $l = $l10nFactory->get('files_sharing'); $user = $userSession->getUser(); $userId = $user ? $user->getUID() : null; -- cgit v1.2.3 From 7345de78c582ffcb01c56e2a0c38788eb913d414 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 11 Aug 2021 17:24:37 +0200 Subject: use the correct navigation manager for the shares Signed-off-by: Robin Appelman --- apps/files_sharing/lib/AppInfo/Application.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 7a432650f12..056d246296f 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -61,7 +61,6 @@ use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\UserAddedEvent; use OCP\IDBConnection; use OCP\IGroup; -use OCP\INavigationManager; use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Share\Events\ShareCreatedEvent; @@ -148,11 +147,12 @@ class Application extends App implements IBootstrap { }); } - public function setupSharingMenus(INavigationManager $navigationManager, IManager $shareManager, IFactory $l10nFactory, IUserSession $userSession) { + public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory, IUserSession $userSession) { if (!$shareManager->shareApiEnabled() || !class_exists('\OCA\Files\App')) { return; } + $navigationManager = \OCA\Files\App::getNavigationManager(); // show_Quick_Access stored as string $navigationManager->add(function () use ($shareManager, $l10nFactory, $userSession) { $l = $l10nFactory->get('files_sharing'); -- cgit v1.2.3 From ef93d2ea1c089d65660591857e5f6a1608210d3c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 12 Aug 2021 13:31:29 +0200 Subject: update tests Signed-off-by: Robin Appelman --- apps/files_sharing/lib/Hooks.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php index f28f6910abd..1c93d913eaf 100644 --- a/apps/files_sharing/lib/Hooks.php +++ b/apps/files_sharing/lib/Hooks.php @@ -27,26 +27,10 @@ namespace OCA\Files_Sharing; use OC\Files\Filesystem; -use OCP\EventDispatcher\IEventDispatcher; -use Psr\Log\LoggerInterface; class Hooks { public static function deleteUser($params) { - $manager = new External\Manager( - \OC::$server->getDatabaseConnection(), - \OC\Files\Filesystem::getMountManager(), - \OC\Files\Filesystem::getLoader(), - \OC::$server->getHTTPClientService(), - \OC::$server->getNotificationManager(), - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), - \OC::$server->getCloudFederationProviderManager(), - \OC::$server->getCloudFederationFactory(), - \OC::$server->getGroupManager(), - \OC::$server->getUserManager(), - $params['uid'], - \OC::$server->query(IEventDispatcher::class), - \OC::$server->get(LoggerInterface::class) - ); + $manager = \OC::$server->get(External\Manager::class); $manager->removeUserShares($params['uid']); } -- cgit v1.2.3