diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 78a8cd3..8849a3d 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -55,8 +55,9 @@ class Application extends App public function isEnabled(): bool { $enabled = true; + $isForced = (bool) $this->config->getAppValue(self::APP_ID, 'force', '0'); - if (null !== $this->user) { + if (null !== $this->user && !$isForced) { $enabled = (bool) $this->config->getUserValue($this->user->getUid(), self::APP_ID, 'enabled', '1'); } diff --git a/lib/Controller/CssController.php b/lib/Controller/CssController.php index 852964f..d793087 100644 --- a/lib/Controller/CssController.php +++ b/lib/Controller/CssController.php @@ -67,13 +67,13 @@ class CssController extends Controller { $backgroundColor = $this->config->getAppValue('background-color', '#333333'); $backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor); - + $isForced = $this->config->getAppValueBool('force', '0'); $topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]'); if ($this->user) { $userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]'); - if (!empty($userTopMenuApps)) { + if (!empty($userTopMenuApps) && !$isForced) { $topMenuApps = $userTopMenuApps; } } diff --git a/lib/Controller/JsController.php b/lib/Controller/JsController.php index a83a6ab..9499d45 100644 --- a/lib/Controller/JsController.php +++ b/lib/Controller/JsController.php @@ -84,19 +84,20 @@ class JsController extends Controller $topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]'); $targetBlankApps = $this->config->getAppValueArray('target-blank-apps', '[]'); $useAvatar = $this->config->getAppValueBool('use-avatar', '0'); + $isForced = $this->config->getAppValueBool('force', '0'); $avatar = null; if ($this->user) { $userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]'); - if (!empty($userTopMenuApps)) { + if (!empty($userTopMenuApps) && !$isForced) { $topMenuApps = $userTopMenuApps; } $userTargetBlankMode = $this->config->getUserValueInt($this->user, 'target-blank-mode', '1'); $userTargetBlankApps = $this->config->getUserValueArray($this->user, 'target-blank-apps', '[]'); - if (2 === $userTargetBlankMode) { + if (2 === $userTargetBlankMode && !$isForced) { $targetBlankApps = $userTargetBlankApps; } diff --git a/lib/Controller/PersonalSettingController.php b/lib/Controller/PersonalSettingController.php index 73fbd67..fc42e76 100644 --- a/lib/Controller/PersonalSettingController.php +++ b/lib/Controller/PersonalSettingController.php @@ -24,6 +24,7 @@ use OCP\IConfig; use OCP\IRequest; use OCP\IUserSession; use OCA\SideMenu\AppInfo\Application; +use OCA\SideMenu\Service\ConfigProxy; class PersonalSettingController extends Controller { @@ -37,11 +38,12 @@ class PersonalSettingController extends Controller */ private $userSession; - public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) + public function __construct($appName, IRequest $request, IConfig $config, ConfigProxy $configProxy, IUserSession $userSession) { parent::__construct($appName, $request); $this->config = $config; + $this->configProxy = $configProxy; $this->userSession = $userSession; } @@ -104,6 +106,10 @@ class PersonalSettingController extends Controller } } + if ($this->configProxy->getAppValueBool('force', '0')) { + $doSave = false; + } + if ($doSave) { $this->config->setUserValue($user->getUid(), Application::APP_ID, $name, $value); diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index f77d22b..ce93966 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -18,13 +18,13 @@ namespace OCA\SideMenu\Settings; +use OCA\SideMenu\AppInfo\Application; use OCA\SideMenu\Service\AppRepository; +use OCA\SideMenu\Service\ConfigProxy; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; use OCP\Settings\ISettings; -use OCA\SideMenu\AppInfo\Application; class Admin implements ISettings { @@ -39,7 +39,7 @@ class Admin implements ISettings private $logger; /** - * @var IConfig + * @var ConfigProxy */ private $config; @@ -48,7 +48,7 @@ class Admin implements ISettings */ private $appRepository; - public function __construct(IL10N $l, ILogger $logger, IConfig $config, AppRepository $appRepository) + public function __construct(IL10N $l, ILogger $logger, ConfigProxy $config, AppRepository $appRepository) { $this->l = $l; $this->logger = $logger; @@ -61,32 +61,33 @@ class Admin implements ISettings */ public function getForm() { - $backgroundColor = $this->config->getAppValue(Application::APP_ID, 'background-color', '#333333'); - $backgroundColorTo = $this->config->getAppValue(Application::APP_ID, 'background-color-to', $backgroundColor); + $backgroundColor = $this->config->getAppValue('background-color', '#333333'); + $backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor); $parameters = [ 'background-color' => $backgroundColor, 'background-color-to' => $backgroundColorTo, - 'current-app-background-color' => $this->config->getAppValue(Application::APP_ID, 'current-app-background-color', '#444444'), - 'loader-color' => $this->config->getAppValue(Application::APP_ID, 'loader-color', '#0e75ac'), - 'icon-invert-filter' => (int) $this->config->getAppValue(Application::APP_ID, 'icon-invert-filter', '0'), - 'icon-opacity' => (int) $this->config->getAppValue(Application::APP_ID, 'icon-opacity', '100'), - 'loader-enabled' => $this->config->getAppValue(Application::APP_ID, 'loader-enabled', '1'), - 'text-color' => $this->config->getAppValue(Application::APP_ID, 'text-color', '#FFFFFF'), - 'cache' => $this->config->getAppValue(Application::APP_ID, 'cache', '0'), - 'opener' => $this->config->getAppValue(Application::APP_ID, 'opener', 'side-menu-opener'), - 'always-displayed' => $this->config->getAppValue(Application::APP_ID, 'always-displayed', '0'), - 'big-menu' => $this->config->getAppValue(Application::APP_ID, 'big-menu', '0'), - 'display-logo' => $this->config->getAppValue(Application::APP_ID, 'display-logo', '1'), - 'use-avatar' => $this->config->getAppValue(Application::APP_ID, 'use-avatar', '0'), - 'opener-position' => $this->config->getAppValue(Application::APP_ID, 'opener-position', 'before'), - 'opener-hover' => $this->config->getAppValue(Application::APP_ID, 'opener-hover', '0'), - 'opener-only' => $this->config->getAppValue(Application::APP_ID, 'opener-only', '0'), - 'hide-when-no-apps' => $this->config->getAppValue(Application::APP_ID, 'hide-when-no-apps', '0'), - 'size-icon' => $this->config->getAppValue(Application::APP_ID, 'size-icon', 'normal'), - 'size-text' => $this->config->getAppValue(Application::APP_ID, 'size-text', 'normal'), - 'target-blank-apps' => (array) json_decode($this->config->getAppValue(Application::APP_ID, 'target-blank-apps', '[]'), true), - 'top-menu-apps' => (array) json_decode($this->config->getAppValue(Application::APP_ID, 'top-menu-apps', '[]'), true), + 'current-app-background-color' => $this->config->getAppValue('current-app-background-color', '#444444'), + 'loader-color' => $this->config->getAppValue('loader-color', '#0e75ac'), + 'icon-invert-filter' => $this->config->getAppValueInt('icon-invert-filter', '0'), + 'icon-opacity' => $this->config->getAppValueInt('icon-opacity', '100'), + 'loader-enabled' => $this->config->getAppValue('loader-enabled', '1'), + 'text-color' => $this->config->getAppValue('text-color', '#FFFFFF'), + 'cache' => $this->config->getAppValue('cache', '0'), + 'opener' => $this->config->getAppValue('opener', 'side-menu-opener'), + 'always-displayed' => $this->config->getAppValue('always-displayed', '0'), + 'big-menu' => $this->config->getAppValue('big-menu', '0'), + 'display-logo' => $this->config->getAppValue('display-logo', '1'), + 'use-avatar' => $this->config->getAppValue('use-avatar', '0'), + 'opener-position' => $this->config->getAppValue('opener-position', 'before'), + 'opener-hover' => $this->config->getAppValue('opener-hover', '0'), + 'opener-only' => $this->config->getAppValue('opener-only', '0'), + 'hide-when-no-apps' => $this->config->getAppValue('hide-when-no-apps', '0'), + 'size-icon' => $this->config->getAppValue('size-icon', 'normal'), + 'size-text' => $this->config->getAppValue('size-text', 'normal'), + 'force' => $this->config->getAppValue('force', '0'), + 'target-blank-apps' => $this->config->getAppValueArray('target-blank-apps', '[]'), + 'top-menu-apps' => $this->config->getAppValueArray('top-menu-apps', '[]'), 'apps' => $this->appRepository->getVisibleApps(), ]; diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index bf2364e..ac8ac1a 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -18,14 +18,14 @@ namespace OCA\SideMenu\Settings; +use OCA\SideMenu\AppInfo\Application; +use OCA\SideMenu\Service\AppRepository; +use OCA\SideMenu\Service\ConfigProxy; use OCP\AppFramework\Http\TemplateResponse; use OCP\IL10N; use OCP\ILogger; -use OCP\Settings\ISettings; -use OCP\IConfig; use OCP\IUserSession; -use OCA\SideMenu\Service\AppRepository; -use OCA\SideMenu\AppInfo\Application; +use OCP\Settings\ISettings; class Personal implements ISettings { @@ -40,7 +40,7 @@ class Personal implements ISettings private $logger; /** - * @var IConfig + * @var ConfigProxy */ private $config; @@ -54,7 +54,7 @@ class Personal implements ISettings */ private $appRepository; - public function __construct(IL10N $l, ILogger $logger, IConfig $config, IUserSession $userSession, AppRepository $appRepository) + public function __construct(IL10N $l, ILogger $logger, ConfigProxy $config, IUserSession $userSession, AppRepository $appRepository) { $this->l = $l; $this->logger = $logger; @@ -71,10 +71,11 @@ class Personal implements ISettings $user = $this->userSession->getUser(); $parameters = [ - 'enabled' => $this->config->getUserValue($user->getUid(), Application::APP_ID, 'enabled', '1'), - 'top-menu-apps' => (array) json_decode($this->config->getUserValue($user->getUid(), Application::APP_ID, 'top-menu-apps', '[]'), true), - 'target-blank-mode' => $this->config->getUserValue($user->getUid(), Application::APP_ID, 'target-blank-mode', '1'), - 'target-blank-apps' => (array) json_decode($this->config->getUserValue($user->getUid(), Application::APP_ID, 'target-blank-apps', '[]'), true), + 'force' => $this->config->getAppValueBool('force', '0'), + 'enabled' => $this->config->getUserValue($user, 'enabled', '1'), + 'top-menu-apps' => $this->config->getUserValueArray($user, 'top-menu-apps', '[]'), + 'target-blank-mode' => $this->config->getUserValue($user, 'target-blank-mode', '1'), + 'target-blank-apps' => $this->config->getUserValueArray($user, 'target-blank-apps', '[]'), 'apps' => $this->appRepository->getVisibleApps(), ]; @@ -91,8 +92,8 @@ class Personal implements ISettings /** * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. + * the admin section. The forms are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. * * E.g.: 70 */ diff --git a/src/l10n/fixtures/de.yaml b/src/l10n/fixtures/de.yaml index e156663..18fd5b4 100644 --- a/src/l10n/fixtures/de.yaml +++ b/src/l10n/fixtures/de.yaml @@ -57,3 +57,5 @@ "Use my selection": "Verwende meine Auswahl" "Show and hide the list of applications": "Ein- und Ausblenden der Anwendungsliste" "Use the avatar instead of the logo": "Verwenden Sie den Avatar anstelle des Logos" +"You do not have permission to change the settings.": "Sie haben keine Berechtigung zum Ändern der Einstellungen." +"Force this configuration to users": "Erzwingen Sie diese Konfiguration für Benutzer" diff --git a/src/l10n/fixtures/fr.yaml b/src/l10n/fixtures/fr.yaml index 44d24e9..0f44280 100644 --- a/src/l10n/fixtures/fr.yaml +++ b/src/l10n/fixtures/fr.yaml @@ -57,3 +57,5 @@ "Use my selection": "Utiliser ma sélection" "Show and hide the list of applications": "Afficher et masquer la liste des applications" "Use the avatar instead of the logo": "Utiliser l'avatar à la place du logo" +"You do not have permission to change the settings.": "Vous n'avez pas la permission de changer les paramètres." +"Force this configuration to users": "Forcer cette configuration aux utilisateurs" diff --git a/templates/settings/admin-form.php b/templates/settings/admin-form.php index f7077ec..3f6b0d3 100644 --- a/templates/settings/admin-form.php +++ b/templates/settings/admin-form.php @@ -473,6 +473,20 @@ $choicesSizes = [
+
+ + + +
+ diff --git a/templates/settings/personal-form.php b/templates/settings/personal-form.php index 41e9540..33f0cc9 100644 --- a/templates/settings/personal-form.php +++ b/templates/settings/personal-form.php @@ -27,125 +27,142 @@ $choicesYesNo = [ ?> +
-
-

- t('Menu')); ?> -

+ +
+

+ t('Menu')); ?> +

-
- +

+ t('You do not have permission to change the settings.'); ?> +

+ +
+

+ t('Menu')); ?> +

-

- t('Use the shortcut Ctrl+o to open and to hide the side menu. Use tab to navigate.'); ?> -

-
- + $value): ?> + + + +
+ +
+ +
+ +
+ '1', + 'Use my selection' => '2', + ]; ?> + + +
+ +

+ + 🖱️ t('Show and hide the list of applications')); ?> + +

+ +
-
- -
+
+

+ t('Top menu')); ?> +

+
+ +
-
- '1', - 'Use my selection' => '2', - ]; ?> +

+ + t('If there is no selection then the global configuration is applied.')); ?> + +

- checked + /> + + +
- +
- -

- - 🖱️ t('Show and hide the list of applications')); ?> - -

- - -
+
-

- t('Top menu')); ?> -

-
- -
+ + -

- - t('If there is no selection then the global configuration is applied.')); ?> - -

+ -

- - 🖱️ t('Show and hide the list of applications')); ?> - -

- - -
- -
- - - - -
+
+