2019-09-02 21:27:12 +03:00
|
|
|
<?php
|
2019-12-03 21:57:53 +03:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-09-02 21:27:12 +03:00
|
|
|
/**
|
2019-09-03 16:49:27 +03:00
|
|
|
* @copyright Copyright (c) 2019 Janis Köhr <janiskoehr@icloud.com>
|
2019-09-02 21:27:12 +03:00
|
|
|
*
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Janis Köhr <janis.koehr@novatec-gmbh.de>
|
|
|
|
*
|
2019-09-02 21:27:12 +03:00
|
|
|
* @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
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-09-02 21:27:12 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Accessibility\Migration;
|
|
|
|
|
2019-09-16 22:14:11 +03:00
|
|
|
use OCA\Accessibility\AppInfo\Application;
|
2019-09-02 21:27:12 +03:00
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\IUser;
|
|
|
|
use OCP\IUserManager;
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
|
|
|
|
class RepairUserConfig implements IRepairStep {
|
|
|
|
|
|
|
|
/** @var IUserManager */
|
|
|
|
protected $userManager;
|
|
|
|
|
|
|
|
/** @var IConfig */
|
|
|
|
protected $config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MigrateUserConfig constructor.
|
|
|
|
*
|
|
|
|
* @param IConfig $config
|
|
|
|
* @param IUserManager $userManager
|
|
|
|
*/
|
|
|
|
public function __construct(IConfig $config,
|
|
|
|
IUserManager $userManager) {
|
|
|
|
$this->config = $config;
|
|
|
|
$this->userManager = $userManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the step's name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.1.0
|
|
|
|
*/
|
|
|
|
public function getName() {
|
|
|
|
return 'Migrate old user config';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run repair step.
|
|
|
|
* Must throw exception on error.
|
|
|
|
*
|
|
|
|
* @param IOutput $output
|
|
|
|
* @throws \Exception in case of failure
|
|
|
|
* @since 9.1.0
|
|
|
|
*/
|
|
|
|
public function run(IOutput $output) {
|
|
|
|
$output->startProgress();
|
2020-04-09 14:53:40 +03:00
|
|
|
$this->userManager->callForSeenUsers(function (IUser $user) use ($output) {
|
2019-09-16 22:14:11 +03:00
|
|
|
$theme = $this->config->getUserValue($user->getUID(), Application::APP_NAME, 'theme', false);
|
2019-09-02 21:27:12 +03:00
|
|
|
if ($theme === 'themedark') {
|
2019-09-16 22:14:11 +03:00
|
|
|
$this->config->setUserValue($user->getUID(), Application::APP_NAME, 'theme', 'dark');
|
2019-09-02 21:27:12 +03:00
|
|
|
}
|
|
|
|
if ($theme === 'themehighcontrast') {
|
2019-09-16 22:14:11 +03:00
|
|
|
$this->config->setUserValue($user->getUID(), Application::APP_NAME, 'highcontrast', 'highcontrast');
|
|
|
|
$this->config->deleteUserValue($user->getUID(), Application::APP_NAME, 'theme');
|
2019-09-02 21:27:12 +03:00
|
|
|
}
|
|
|
|
$output->advance();
|
|
|
|
});
|
|
|
|
$output->finishProgress();
|
|
|
|
}
|
|
|
|
}
|