Skip to content

Commit

Permalink
fix: Remove legacy code that caused errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jun 17, 2024
1 parent 9adf39f commit 94e0821
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 78 deletions.
1 change: 0 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

return [
'routes' => [
['name' => 'Wizard#show', 'url' => '/wizard', 'verb' => 'GET'],
['name' => 'Wizard#disable', 'url' => '/wizard', 'verb' => 'DELETE'],
],
];
81 changes: 6 additions & 75 deletions lib/Controller/WizardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,19 @@

class WizardController extends Controller {

/** @var IConfig */
protected $config;

/** @var string */
protected $userId;

/** @var Defaults */
protected $theming;

/** @var IGroupManager */
protected $groupManager;

/** @var array|false|string[] */
protected $slides = [];

/**
* @param string $appName
* @param IRequest $request
* @param IConfig $config
* @param string $userId
* @param Defaults $theming
*/
public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming, IGroupManager $groupManager) {
public function __construct(
$appName,
IRequest $request,
private IConfig $config,
private string $userId,
) {
parent::__construct($appName, $request);

$this->config = $config;
$this->userId = $userId;
$this->theming = $theming;
$this->groupManager = $groupManager;

$this->slides = explode(',', $this->config->getAppValue(Application::APP_ID, 'slides', 'video,values,apps,clients,final'));
}

/**
Expand All @@ -73,55 +55,4 @@ public function disable() {
$this->config->setUserValue($this->userId, 'firstrunwizard', 'show', 0);
return new DataResponse();
}

/**
* @NoAdminRequired
* @return JsonResponse
*/
public function show() {
$appStore = $this->config->getSystemValue('appstoreenabled', true);

$data = [
'desktop' => $this->config->getSystemValue('customclient_desktop', $this->theming->getSyncClientUrl()),
'android' => $this->config->getSystemValue('customclient_android', $this->theming->getAndroidClientUrl()),
'fdroid' => $this->config->getSystemValue('customclient_fdroid', $this->theming->getFDroidClientUrl()),
'ios' => $this->config->getSystemValue('customclient_ios', $this->theming->getiOSClientUrl()),
'appStore' => $appStore,
'useTLS' => $this->request->getServerProtocol() === 'https',
'macOSProfile' => \OCP\Util::linkToRemote('dav') . 'provisioning/apple-provisioning.mobileconfig',
];

$slides = [];

$slides[] = $this->staticSlide('page.values', $data);
if ($appStore && $this->groupManager->isAdmin($this->userId)) {
$slides[] = $this->staticSlide('page.apps', $data);
}
$slides[] = $this->staticSlide('page.clients', $data);
$slides[] = $this->staticSlide('page.final', $data);

return new JSONResponse([
'hasVideo' => in_array('video', $this->slides, true),
'slides' => array_values(array_filter($slides, function ($slide) {
return $slide !== null;
}))
]);
}

public function staticSlide($name, $params) {
if (!in_array(substr($name, 5), $this->slides, true)) {
return null;
}

$template = new \OCP\Template($this->appName, $name, false);

foreach ($params as $key => $value) {
$template->assign($key, $value);
}

return [
'type' => 'inline',
'content' => $template->fetchPage($params)
];
}
}
2 changes: 0 additions & 2 deletions tests/Controller/WizardControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ protected function getController($user = 'test') {
$this->createMock(IRequest::class),
$this->config,
$user,
\OC::$server->query(Defaults::class),
$this->groupManager
);
}

Expand Down

0 comments on commit 94e0821

Please sign in to comment.