diff options
author | Robin Appelman <robin@icewind.nl> | 2021-04-23 17:29:34 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-05-12 16:11:28 +0200 |
commit | b1dca57a1ce59bacc4089761275e4366e9760313 (patch) | |
tree | ed79b9ab833ee9af257dc4f0e68afbd28656043c /apps/files | |
parent | 7e1c842d96cde01ebb6854b3e28fb998006575b2 (diff) | |
download | nextcloud-server-b1dca57a1ce59bacc4089761275e4366e9760313.tar.gz nextcloud-server-b1dca57a1ce59bacc4089761275e4366e9760313.zip |
load share settings from the share manager in more places
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 9 | ||||
-rw-r--r-- | apps/files/list.php | 6 | ||||
-rw-r--r-- | apps/files/tests/Controller/ViewControllerTest.php | 7 |
3 files changed, 19 insertions, 3 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index efaf2dc602f..b055f9a38b5 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -55,6 +55,7 @@ use OCP\IL10N; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserSession; +use OCP\Share\IManager; /** * Class ViewController @@ -86,6 +87,8 @@ class ViewController extends Controller { private $initialState; /** @var ITemplateManager */ private $templateManager; + /** @var IManager */ + private $shareManager; public function __construct(string $appName, IRequest $request, @@ -98,7 +101,8 @@ class ViewController extends Controller { IRootFolder $rootFolder, Helper $activityHelper, IInitialState $initialState, - ITemplateManager $templateManager + ITemplateManager $templateManager, + IManager $shareManager ) { parent::__construct($appName, $request); $this->appName = $appName; @@ -113,6 +117,7 @@ class ViewController extends Controller { $this->activityHelper = $activityHelper; $this->initialState = $initialState; $this->templateManager = $templateManager; + $this->shareManager = $shareManager; } /** @@ -302,7 +307,7 @@ class ViewController extends Controller { $params['owner'] = $storageInfo['owner'] ?? ''; $params['ownerDisplayName'] = $storageInfo['ownerDisplayName'] ?? ''; $params['isPublic'] = false; - $params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'); + $params['allowShareWithLink'] = $this->shareManager->shareApiAllowLinks() ? 'yes' : 'no'; $params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name'); $params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc'); $params['showgridview'] = $this->config->getUserValue($user, 'files', 'show_grid', false); diff --git a/apps/files/list.php b/apps/files/list.php index 52d736516c9..308d149c873 100644 --- a/apps/files/list.php +++ b/apps/files/list.php @@ -22,10 +22,14 @@ * */ +use OCP\Share\IManager; + $config = \OC::$server->getConfig(); $userSession = \OC::$server->getUserSession(); // TODO: move this to the generated config.js -$publicUploadEnabled = $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'); +/** @var IManager $shareManager */ +$shareManager = \OC::$server->get(IManager::class); +$publicUploadEnabled = $shareManager->shareApiLinkAllowPublicUpload() ? 'yes' : 'no';; $showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false); $isIE = OC_Util::isIe(); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index bc233599e34..3453914b27a 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -48,6 +48,7 @@ use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; +use OCP\Share\IManager; use OCP\Template; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -84,6 +85,8 @@ class ViewControllerTest extends TestCase { private $initialState; /** @var ITemplateManager|\PHPUnit\Framework\MockObject\MockObject */ private $templateManager; + /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */ + private $shareManager; protected function setUp(): void { parent::setUp(); @@ -105,6 +108,7 @@ class ViewControllerTest extends TestCase { $this->activityHelper = $this->createMock(Helper::class); $this->initialState = $this->createMock(IInitialState::class); $this->templateManager = $this->createMock(ITemplateManager::class); + $this->shareManager = $this->createMock(IManager::class); $this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController') ->setConstructorArgs([ 'files', @@ -119,6 +123,7 @@ class ViewControllerTest extends TestCase { $this->activityHelper, $this->initialState, $this->templateManager, + $this->shareManager, ]) ->setMethods([ 'getStorageInfo', @@ -153,6 +158,8 @@ class ViewControllerTest extends TestCase { ->expects($this->any()) ->method('getAppValue') ->willReturnArgument(2); + $this->shareManager->method('shareApiAllowLinks') + ->willReturn(true); $nav = new Template('files', 'appnavigation'); $nav->assign('usage_relative', 123); |