Removed duplicate defintion of app name and rebased/rebuilt.

Signed-off-by: Janis Köhr <janis.koehr@novatec-gmbh.de>
This commit is contained in:
Janis Köhr 2019-09-16 21:14:11 +02:00
parent 4a1ce95464
commit d75fbab5d2
No known key found for this signature in database
GPG Key ID: AC5C634CEF63743A
4 changed files with 15 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@ use OCP\IURLGenerator;
class Application extends App {
/** @var string */
protected $appName = 'accessibility';
public const APP_NAME = 'accessibility';
/** @var IConfig */
private $config;
@ -43,7 +43,7 @@ class Application extends App {
private $urlGenerator;
public function __construct() {
parent::__construct($this->appName);
parent::__construct(self::APP_NAME);
$this->config = \OC::$server->getConfig();
$this->userSession = \OC::$server->getUserSession();
$this->urlGenerator = \OC::$server->getURLGenerator();
@ -53,11 +53,11 @@ class Application extends App {
// Inject the fake css on all pages if enabled and user is logged
$loggedUser = $this->userSession->getUser();
if (!is_null($loggedUser)) {
$userValues = $this->config->getUserKeys($loggedUser->getUID(), $this->appName);
$userValues = $this->config->getUserKeys($loggedUser->getUID(), self::APP_NAME);
// we want to check if any theme or font is enabled.
if (count($userValues) > 0) {
$hash = $this->config->getUserValue($loggedUser->getUID(), $this->appName, 'icons-css', md5(implode('-', $userValues)));
$linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => $hash]);
$hash = $this->config->getUserValue($loggedUser->getUID(), self::APP_NAME, 'icons-css', md5(implode('-', $userValues)));
$linkToCSS = $this->urlGenerator->linkToRoute(self::APP_NAME . '.accessibility.getCss', ['md5' => $hash]);
\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
}
}
@ -65,7 +65,7 @@ class Application extends App {
public function injectJavascript() {
$linkToJs = $this->urlGenerator->linkToRoute(
$this->appName . '.accessibility.getJavascript',
self::APP_NAME . '.accessibility.getJavascript',
[
'v' => \OC::$server->getConfig()->getAppValue('accessibility', 'cachebuster', '0'),
]

View File

@ -22,6 +22,7 @@ declare (strict_types = 1);
namespace OCA\Accessibility\Migration;
use OCA\Accessibility\AppInfo\Application;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
@ -30,9 +31,6 @@ use OCP\Migration\IRepairStep;
class RepairUserConfig implements IRepairStep {
/** @var string */
private const APP_NAME = 'accessibility';
/** @var IUserManager */
protected $userManager;
@ -72,13 +70,13 @@ class RepairUserConfig implements IRepairStep {
public function run(IOutput $output) {
$output->startProgress();
$this->userManager->callForSeenUsers(function(IUser $user) use ($output) {
$theme = $this->config->getUserValue($user->getUID(), self::APP_NAME, 'theme', false);
$theme = $this->config->getUserValue($user->getUID(), Application::APP_NAME, 'theme', false);
if ($theme === 'themedark') {
$this->config->setUserValue($user->getUID(), self::APP_NAME, 'theme', 'dark');
$this->config->setUserValue($user->getUID(), Application::APP_NAME, 'theme', 'dark');
}
if ($theme === 'themehighcontrast') {
$this->config->setUserValue($user->getUID(), self::APP_NAME, 'highcontrast', 'highcontrast');
$this->config->deleteUserValue($user->getUID(), self::APP_NAME, 'theme');
$this->config->setUserValue($user->getUID(), Application::APP_NAME, 'highcontrast', 'highcontrast');
$this->config->deleteUserValue($user->getUID(), Application::APP_NAME, 'theme');
}
$output->advance();
});