diff options
-rw-r--r-- | apps/dav/lib/Upload/AssemblyStream.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/routes.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareControllerTest.php | 38 | ||||
-rw-r--r-- | apps/settings/templates/settings/admin/server.php | 2 | ||||
-rw-r--r-- | apps/settings/templates/settings/admin/sharing.php | 4 | ||||
-rw-r--r-- | apps/workflowengine/lib/Check/RequestRemoteAddress.php | 6 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/User/User.php | 11 | ||||
-rw-r--r-- | lib/public/User/GetQuotaEvent.php | 72 | ||||
-rw-r--r-- | version.php | 4 |
12 files changed, 120 insertions, 29 deletions
diff --git a/apps/dav/lib/Upload/AssemblyStream.php b/apps/dav/lib/Upload/AssemblyStream.php index ecd73cdf518..e42a1ceb9e5 100644 --- a/apps/dav/lib/Upload/AssemblyStream.php +++ b/apps/dav/lib/Upload/AssemblyStream.php @@ -73,7 +73,7 @@ class AssemblyStream implements \Icewind\Streams\File { $this->loadContext('assembly'); $nodes = $this->nodes; - // http://stackoverflow.com/a/10985500 + // https://stackoverflow.com/a/10985500 @usort($nodes, function (IFile $a, IFile $b) { return strnatcmp($a->getName(), $b->getName()); }); diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index a4edada738c..8915f135ba2 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -50,9 +50,10 @@ return [ ], [ 'name' => 'Share#downloadShare', - 'url' => '/s/{token}/download', + 'url' => '/s/{token}/download/{filename}', 'verb' => 'GET', 'root' => '', + 'defaults' => ['filename' => ''] ], [ 'name' => 'PublicPreview#directLink', diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 359382441d6..fdf69abd9ac 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -414,7 +414,10 @@ class ShareController extends AuthPublicShareController { $shareTmpl['showgridview'] = false; $shareTmpl['hideFileList'] = $hideFileList; - $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', ['token' => $this->getToken()]); + $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', [ + 'token' => $this->getToken(), + 'filename' => $shareIsFolder ? null : $shareNode->getName() + ]); $shareTmpl['shareUrl'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $this->getToken()]); $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10); $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true); diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 18b663f09bc..33dff13cafe 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -211,6 +211,7 @@ class ShareControllerTest extends \Test\TestCase { public function testShowShare() { $note = 'personal note'; + $filename = 'file1.txt'; $this->shareController->setToken('token'); @@ -225,7 +226,7 @@ class ShareControllerTest extends \Test\TestCase { $initiator->method('isEnabled')->willReturn(true); $file = $this->createMock(File::class); - $file->method('getName')->willReturn('file1.txt'); + $file->method('getName')->willReturn($filename); $file->method('getMimetype')->willReturn('text/plain'); $file->method('getSize')->willReturn(33); $file->method('isReadable')->willReturn(true); @@ -250,14 +251,14 @@ class ShareControllerTest extends \Test\TestCase { ->setSharedBy('initiatorUID') ->setNode($file) ->setNote($note) - ->setTarget('/file1.txt'); + ->setTarget("/$filename"); $this->session->method('exists')->with('public_link_authenticated')->willReturn(true); $this->session->method('get')->with('public_link_authenticated')->willReturn('42'); $this->urlGenerator->expects($this->at(0)) ->method('linkToRouteAbsolute') - ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token']) + ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename]) ->willReturn('downloadURL'); $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true); @@ -312,8 +313,8 @@ class ShareControllerTest extends \Test\TestCase { $response = $this->shareController->showShare(); $sharedTmplParams = [ 'owner' => 'ownerUID', - 'filename' => 'file1.txt', - 'directory_path' => '/file1.txt', + 'filename' => $filename, + 'directory_path' => "/$filename", 'mimetype' => 'text/plain', 'dirToken' => 'token', 'sharingToken' => 'token', @@ -357,6 +358,7 @@ class ShareControllerTest extends \Test\TestCase { public function testShowShareWithPrivateName() { $note = 'personal note'; + $filename = 'file1.txt'; $this->shareController->setToken('token'); @@ -371,7 +373,7 @@ class ShareControllerTest extends \Test\TestCase { $initiator->method('isEnabled')->willReturn(true); $file = $this->createMock(File::class); - $file->method('getName')->willReturn('file1.txt'); + $file->method('getName')->willReturn($filename); $file->method('getMimetype')->willReturn('text/plain'); $file->method('getSize')->willReturn(33); $file->method('isReadable')->willReturn(true); @@ -396,14 +398,14 @@ class ShareControllerTest extends \Test\TestCase { ->setSharedBy('initiatorUID') ->setNode($file) ->setNote($note) - ->setTarget('/file1.txt'); + ->setTarget("/$filename"); $this->session->method('exists')->with('public_link_authenticated')->willReturn(true); $this->session->method('get')->with('public_link_authenticated')->willReturn('42'); $this->urlGenerator->expects($this->at(0)) ->method('linkToRouteAbsolute') - ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token']) + ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename]) ->willReturn('downloadURL'); $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true); @@ -458,8 +460,8 @@ class ShareControllerTest extends \Test\TestCase { $response = $this->shareController->showShare(); $sharedTmplParams = [ 'owner' => '', - 'filename' => 'file1.txt', - 'directory_path' => '/file1.txt', + 'filename' => $filename, + 'directory_path' => "/$filename", 'mimetype' => 'text/plain', 'dirToken' => 'token', 'sharingToken' => 'token', @@ -503,6 +505,7 @@ class ShareControllerTest extends \Test\TestCase { public function testShowShareHideDownload() { $note = 'personal note'; + $filename = 'file1.txt'; $this->shareController->setToken('token'); @@ -517,7 +520,7 @@ class ShareControllerTest extends \Test\TestCase { $initiator->method('isEnabled')->willReturn(true); $file = $this->getMockBuilder('OCP\Files\File')->getMock(); - $file->method('getName')->willReturn('file1.txt'); + $file->method('getName')->willReturn($filename); $file->method('getMimetype')->willReturn('text/plain'); $file->method('getSize')->willReturn(33); $file->method('isReadable')->willReturn(true); @@ -542,7 +545,7 @@ class ShareControllerTest extends \Test\TestCase { ->setSharedBy('initiatorUID') ->setNode($file) ->setNote($note) - ->setTarget('/file1.txt') + ->setTarget("/$filename") ->setHideDownload(true); $this->session->method('exists')->with('public_link_authenticated')->willReturn(true); @@ -553,7 +556,7 @@ class ShareControllerTest extends \Test\TestCase { // files. $this->urlGenerator->expects($this->at(0)) ->method('linkToRouteAbsolute') - ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token']) + ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename]) ->willReturn('downloadURL'); $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true); @@ -608,8 +611,8 @@ class ShareControllerTest extends \Test\TestCase { $response = $this->shareController->showShare(); $sharedTmplParams = [ 'owner' => 'ownerUID', - 'filename' => 'file1.txt', - 'directory_path' => '/file1.txt', + 'filename' => $filename, + 'directory_path' => "/$filename", 'mimetype' => 'text/plain', 'dirToken' => 'token', 'sharingToken' => 'token', @@ -774,6 +777,7 @@ class ShareControllerTest extends \Test\TestCase { public function testShowShareInvalid() { $this->expectException(\OCP\Files\NotFoundException::class); + $filename = 'file1.txt'; $this->shareController->setToken('token'); $owner = $this->getMockBuilder(IUser::class)->getMock(); @@ -781,7 +785,7 @@ class ShareControllerTest extends \Test\TestCase { $owner->method('getUID')->willReturn('ownerUID'); $file = $this->getMockBuilder('OCP\Files\File')->getMock(); - $file->method('getName')->willReturn('file1.txt'); + $file->method('getName')->willReturn($filename); $file->method('getMimetype')->willReturn('text/plain'); $file->method('getSize')->willReturn(33); $file->method('isShareable')->willReturn(false); @@ -792,7 +796,7 @@ class ShareControllerTest extends \Test\TestCase { $share->setPassword('password') ->setShareOwner('ownerUID') ->setNode($file) - ->setTarget('/file1.txt'); + ->setTarget("/$filename"); $this->session->method('exists')->with('public_link_authenticated')->willReturn(true); $this->session->method('get')->with('public_link_authenticated')->willReturn('42'); diff --git a/apps/settings/templates/settings/admin/server.php b/apps/settings/templates/settings/admin/server.php index c848ef5c494..45203e48901 100644 --- a/apps/settings/templates/settings/admin/server.php +++ b/apps/settings/templates/settings/admin/server.php @@ -78,7 +78,7 @@ print_unescaped('checked="checked"'); } ?>> <label for="backgroundjobs_ajax">AJAX</label><br/> - <em><?php p($l->t("Execute one task with each page loaded")); ?></em> + <em><?php p($l->t("Execute one task with each page loaded.")); ?></em> </p> <p> <input type="radio" name="mode" value="webcron" class="radio" diff --git a/apps/settings/templates/settings/admin/sharing.php b/apps/settings/templates/settings/admin/sharing.php index bd75b04eedb..59915c581e7 100644 --- a/apps/settings/templates/settings/admin/sharing.php +++ b/apps/settings/templates/settings/admin/sharing.php @@ -163,7 +163,7 @@ <?php if ($_['allowShareDialogUserEnumeration'] === 'yes') { print_unescaped('checked="checked"'); } ?> /> - <label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog. If this is disabled the full username or email address needs to be entered.'));?></label><br /> + <label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog (if this is disabled the full username or email address needs to be entered)'));?></label><br /> </p> <p id="shareapi_restrict_user_enumeration_to_group_setting" class="indent <?php if ($_['shareAPIEnabled'] === 'no' || $_['allowShareDialogUserEnumeration'] === 'no') { @@ -181,7 +181,7 @@ <?php if ($_['publicShareDisclaimerText'] !== null) { print_unescaped('checked="checked"'); } ?> /> - <label for="publicShareDisclaimer"><?php p($l->t('Show disclaimer text on the public link upload page. (Only shown when the file list is hidden.)'));?></label> + <label for="publicShareDisclaimer"><?php p($l->t('Show disclaimer text on the public link upload page (only shown when the file list is hidden)'));?></label> <span id="publicShareDisclaimerStatus" class="msg" style="display:none"></span> <br/> <textarea placeholder="<?php p($l->t('This text will be shown on the public link upload page when the file list is hidden.')) ?>" id="publicShareDisclaimerText" <?php if ($_['publicShareDisclaimerText'] === null) { diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index 00d3d9b2577..abc13bf9e38 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -95,7 +95,7 @@ class RequestRemoteAddress implements ICheck { } /** - * Based on http://stackoverflow.com/a/594134 + * Based on https://stackoverflow.com/a/594134 * @param string $ip * @param string $rangeIp * @param int $bits @@ -109,7 +109,7 @@ class RequestRemoteAddress implements ICheck { } /** - * Based on http://stackoverflow.com/a/7951507 + * Based on https://stackoverflow.com/a/7951507 * @param string $ip * @param string $rangeIp * @param int $bits @@ -128,7 +128,7 @@ class RequestRemoteAddress implements ICheck { } /** - * Based on http://stackoverflow.com/a/7951507 + * Based on https://stackoverflow.com/a/7951507 * @param string $packedIp * @return string */ diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index a1960f678fd..f28e7977a03 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -530,6 +530,7 @@ return array( 'OCP\\User\\Events\\UserLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', 'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php', + 'OCP\\User\\GetQuotaEvent' => $baseDir . '/lib/public/User/GetQuotaEvent.php', 'OCP\\Util' => $baseDir . '/lib/public/Util.php', 'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php', 'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 8c7db5e5723..e584c63c644 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -559,6 +559,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\User\\Events\\UserLoggedInEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', 'OCP\\User\\Events\\UserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedOutEvent.php', + 'OCP\\User\\GetQuotaEvent' => __DIR__ . '/../../..' . '/lib/public/User/GetQuotaEvent.php', 'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php', 'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php', 'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php', diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 2d27b204d09..365b8ae33a1 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -50,6 +50,7 @@ use OCP\IImage; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserBackend; +use OCP\User\GetQuotaEvent; use OCP\UserInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -406,7 +407,15 @@ class User implements IUser { * @since 9.0.0 */ public function getQuota() { - $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); + // allow apps to modify the user quota by hooking into the event + $event = new GetQuotaEvent($this); + $this->dispatcher->dispatchTyped($event); + $overwriteQuota = $event->getQuota(); + if ($overwriteQuota) { + $quota = $overwriteQuota; + } else { + $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); + } if ($quota === 'default') { $quota = $this->config->getAppValue('files', 'default_quota', 'none'); } diff --git a/lib/public/User/GetQuotaEvent.php b/lib/public/User/GetQuotaEvent.php new file mode 100644 index 00000000000..7f1cc39e5f8 --- /dev/null +++ b/lib/public/User/GetQuotaEvent.php @@ -0,0 +1,72 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\User; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * Event to allow apps to + * + * @since 20.0.0 + */ +class GetQuotaEvent extends Event { + /** @var IUser */ + private $user; + /** @var string|null */ + private $quota = null; + + /** + * @since 20.0.0 + */ + public function __construct(IUser $user) { + parent::__construct(); + $this->user = $user; + } + + /** + * @since 20.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * Get the set quota as human readable string, or null if no overwrite is set + * + * @since 20.0.0 + */ + public function getQuota(): ?string { + return $this->quota; + } + + /** + * Set the quota overwrite as human readable string + * + * @since 20.0.0 + */ + public function setQuota(string $quota): void { + $this->quota = $quota; + } +} diff --git a/version.php b/version.php index bb27fba74fb..d817ce91ce7 100644 --- a/version.php +++ b/version.php @@ -29,10 +29,10 @@ // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = [20, 0, 0, 6]; +$OC_Version = [20, 0, 0, 7]; // The human readable string -$OC_VersionString = '20.0.0 Beta 4'; +$OC_VersionString = '20.0.0 RC1'; $OC_VersionCanBeUpgradedFrom = [ 'nextcloud' => [ |