Skip to content

Commit 1b5c4ee

Browse files
authored
Merge pull request #1260 from nextcloud/fix/legacy
fix: Remove legacy code that caused errors
2 parents 67b0925 + 9681559 commit 1b5c4ee

File tree

6 files changed

+11
-111
lines changed

6 files changed

+11
-111
lines changed

appinfo/routes.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
return [
2323
'routes' => [
24-
['name' => 'Wizard#show', 'url' => '/wizard', 'verb' => 'GET'],
2524
['name' => 'Wizard#disable', 'url' => '/wizard', 'verb' => 'DELETE'],
2625
],
2726
];

lib/Controller/WizardController.php

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -21,107 +21,35 @@
2121

2222
namespace OCA\FirstRunWizard\Controller;
2323

24-
use OCA\FirstRunWizard\AppInfo\Application;
2524
use OCP\AppFramework\Controller;
2625
use OCP\AppFramework\Http\DataResponse;
27-
use OCP\AppFramework\Http\JSONResponse;
28-
use OCP\Defaults;
2926
use OCP\IConfig;
30-
use OCP\IGroupManager;
3127
use OCP\IRequest;
3228

3329
class WizardController extends Controller {
3430

35-
/** @var IConfig */
36-
protected $config;
37-
38-
/** @var string */
39-
protected $userId;
40-
41-
/** @var Defaults */
42-
protected $theming;
43-
44-
/** @var IGroupManager */
45-
protected $groupManager;
46-
47-
/** @var array|false|string[] */
48-
protected $slides = [];
49-
5031
/**
5132
* @param string $appName
5233
* @param IRequest $request
5334
* @param IConfig $config
54-
* @param string $userId
55-
* @param Defaults $theming
35+
* @param string|null $userId
5636
*/
57-
public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming, IGroupManager $groupManager) {
37+
public function __construct(
38+
$appName,
39+
IRequest $request,
40+
private IConfig $config,
41+
private ?string $userId,
42+
) {
5843
parent::__construct($appName, $request);
59-
60-
$this->config = $config;
61-
$this->userId = $userId;
62-
$this->theming = $theming;
63-
$this->groupManager = $groupManager;
64-
65-
$this->slides = explode(',', $this->config->getAppValue(Application::APP_ID, 'slides', 'video,values,apps,clients,final'));
6644
}
6745

6846
/**
6947
* @NoAdminRequired
7048
* @return DataResponse
7149
*/
7250
public function disable() {
51+
\assert($this->userId !== null);
7352
$this->config->setUserValue($this->userId, 'firstrunwizard', 'show', 0);
7453
return new DataResponse();
7554
}
76-
77-
/**
78-
* @NoAdminRequired
79-
* @return JsonResponse
80-
*/
81-
public function show() {
82-
$appStore = $this->config->getSystemValue('appstoreenabled', true);
83-
84-
$data = [
85-
'desktop' => $this->config->getSystemValue('customclient_desktop', $this->theming->getSyncClientUrl()),
86-
'android' => $this->config->getSystemValue('customclient_android', $this->theming->getAndroidClientUrl()),
87-
'fdroid' => $this->config->getSystemValue('customclient_fdroid', $this->theming->getFDroidClientUrl()),
88-
'ios' => $this->config->getSystemValue('customclient_ios', $this->theming->getiOSClientUrl()),
89-
'appStore' => $appStore,
90-
'useTLS' => $this->request->getServerProtocol() === 'https',
91-
'macOSProfile' => \OCP\Util::linkToRemote('dav') . 'provisioning/apple-provisioning.mobileconfig',
92-
];
93-
94-
$slides = [];
95-
96-
$slides[] = $this->staticSlide('page.values', $data);
97-
if ($appStore && $this->groupManager->isAdmin($this->userId)) {
98-
$slides[] = $this->staticSlide('page.apps', $data);
99-
}
100-
$slides[] = $this->staticSlide('page.clients', $data);
101-
$slides[] = $this->staticSlide('page.final', $data);
102-
103-
return new JSONResponse([
104-
'hasVideo' => in_array('video', $this->slides, true),
105-
'slides' => array_values(array_filter($slides, function ($slide) {
106-
return $slide !== null;
107-
}))
108-
]);
109-
}
110-
111-
public function staticSlide($name, $params) {
112-
if (!in_array(substr($name, 5), $this->slides, true)) {
113-
return null;
114-
}
115-
116-
$template = new \OCP\Template($this->appName, $name, false);
117-
118-
foreach ($params as $key => $value) {
119-
$template->assign($key, $value);
120-
}
121-
122-
return [
123-
'type' => 'inline',
124-
'content' => $template->fetchPage($params)
125-
];
126-
}
12755
}

templates/personal-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<p><?php print_unescaped($l->t('Set up sync clients using an <a href="%s">app password</a>. That way you can make sure you are able to revoke access in case you lose that device.', [$appPasswordUrl])); ?></p>
5959
</div>
6060
<div class="section">
61-
<h2><?php p($l->t('Connect other apps to %s', array($theme->getName()))); ?></h2>
61+
<h2><?php p($l->t('Connect other apps to %s', [$theme->getName()])); ?></h2>
6262

6363
<p class="settings-hint"><?php print_unescaped($l->t('Besides the mobile apps and desktop client you can connect any other software that supports the WebDAV/CalDAV/CardDAV protocols to %s.', [$theme->getName()])); ?></p>
6464

tests/AppInfo/ApplicationTest.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
<?php
22
/**
3-
* @copyright Copyright (c) 2016, Joas Schilling <coding@schilljs.com>
4-
*
5-
* @author Joas Schilling <coding@schilljs.com>
6-
*
7-
* @license GNU AGPL version 3 or any later version
8-
*
9-
* This program is free software: you can redistribute it and/or modify
10-
* it under the terms of the GNU Affero General Public License as
11-
* published by the Free Software Foundation, either version 3 of the
12-
* License, or (at your option) any later version.
13-
*
14-
* This program is distributed in the hope that it will be useful,
15-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17-
* GNU Affero General Public License for more details.
18-
*
19-
* You should have received a copy of the GNU Affero General Public License
20-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21-
*
3+
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-License-Identifier: AGPL-3.0-or-later
225
*/
236

247
namespace OCA\FirstRunWizard\Tests\AppInfo;

tests/AppInfo/RoutesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public function testRoutes() {
3838
$this->assertArrayHasKey('routes', $routes);
3939
$this->assertIsArray($routes['routes']);
4040
$this->assertSame([
41-
['name' => 'Wizard#show', 'url' => '/wizard', 'verb' => 'GET'],
4241
['name' => 'Wizard#disable', 'url' => '/wizard', 'verb' => 'DELETE'],
4342
], $routes['routes']);
4443
}

tests/Controller/WizardControllerTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323

2424
namespace OCA\FirstRunWizard\Tests\Controller;
2525

26-
use OCA\FirstRunWizard\AppInfo\Application;
2726
use OCA\FirstRunWizard\Controller\WizardController;
2827
use OCP\AppFramework\Http;
2928
use OCP\AppFramework\Http\DataResponse;
30-
use OCP\Defaults;
3129
use OCP\IConfig;
3230
use OCP\IGroupManager;
3331
use OCP\IRequest;
@@ -60,8 +58,6 @@ protected function getController($user = 'test') {
6058
$this->createMock(IRequest::class),
6159
$this->config,
6260
$user,
63-
\OC::$server->query(Defaults::class),
64-
$this->groupManager
6561
);
6662
}
6763

@@ -77,11 +73,6 @@ public function dataDisable() {
7773
* @param string $user
7874
*/
7975
public function testDisable($user) {
80-
$this->config->expects($this->once())
81-
->method('getAppValue')
82-
->with(Application::APP_ID, 'slides', 'video,values,apps,clients,final')
83-
->willReturnArgument(2);
84-
8576
$controller = $this->getController($user);
8677

8778
$this->config->expects($this->once())

0 commit comments

Comments
 (0)