Compare commits

...

3 commits

12 changed files with 192 additions and 147 deletions

View file

@ -55,8 +55,9 @@ class Application extends App
public function isEnabled(): bool public function isEnabled(): bool
{ {
$enabled = true; $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'); $enabled = (bool) $this->config->getUserValue($this->user->getUid(), self::APP_ID, 'enabled', '1');
} }

View file

@ -67,13 +67,13 @@ class CssController extends Controller
{ {
$backgroundColor = $this->config->getAppValue('background-color', '#333333'); $backgroundColor = $this->config->getAppValue('background-color', '#333333');
$backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor); $backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor);
$isForced = $this->config->getAppValueBool('force', '0');
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]'); $topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
if ($this->user) { if ($this->user) {
$userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]'); $userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]');
if (!empty($userTopMenuApps)) { if (!empty($userTopMenuApps) && !$isForced) {
$topMenuApps = $userTopMenuApps; $topMenuApps = $userTopMenuApps;
} }
} }

View file

@ -84,19 +84,20 @@ class JsController extends Controller
$topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]'); $topMenuApps = $this->config->getAppValueArray('top-menu-apps', '[]');
$targetBlankApps = $this->config->getAppValueArray('target-blank-apps', '[]'); $targetBlankApps = $this->config->getAppValueArray('target-blank-apps', '[]');
$useAvatar = $this->config->getAppValueBool('use-avatar', '0'); $useAvatar = $this->config->getAppValueBool('use-avatar', '0');
$isForced = $this->config->getAppValueBool('force', '0');
$avatar = null; $avatar = null;
if ($this->user) { if ($this->user) {
$userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]'); $userTopMenuApps = $this->config->getUserValueArray($this->user, 'top-menu-apps', '[]');
if (!empty($userTopMenuApps)) { if (!empty($userTopMenuApps) && !$isForced) {
$topMenuApps = $userTopMenuApps; $topMenuApps = $userTopMenuApps;
} }
$userTargetBlankMode = $this->config->getUserValueInt($this->user, 'target-blank-mode', '1'); $userTargetBlankMode = $this->config->getUserValueInt($this->user, 'target-blank-mode', '1');
$userTargetBlankApps = $this->config->getUserValueArray($this->user, 'target-blank-apps', '[]'); $userTargetBlankApps = $this->config->getUserValueArray($this->user, 'target-blank-apps', '[]');
if (2 === $userTargetBlankMode) { if (2 === $userTargetBlankMode && !$isForced) {
$targetBlankApps = $userTargetBlankApps; $targetBlankApps = $userTargetBlankApps;
} }

View file

@ -24,6 +24,7 @@ use OCP\IConfig;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserSession; use OCP\IUserSession;
use OCA\SideMenu\AppInfo\Application; use OCA\SideMenu\AppInfo\Application;
use OCA\SideMenu\Service\ConfigProxy;
class PersonalSettingController extends Controller class PersonalSettingController extends Controller
{ {
@ -37,11 +38,12 @@ class PersonalSettingController extends Controller
*/ */
private $userSession; 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); parent::__construct($appName, $request);
$this->config = $config; $this->config = $config;
$this->configProxy = $configProxy;
$this->userSession = $userSession; $this->userSession = $userSession;
} }
@ -104,6 +106,10 @@ class PersonalSettingController extends Controller
} }
} }
if ($this->configProxy->getAppValueBool('force', '0')) {
$doSave = false;
}
if ($doSave) { if ($doSave) {
$this->config->setUserValue($user->getUid(), Application::APP_ID, $name, $value); $this->config->setUserValue($user->getUid(), Application::APP_ID, $name, $value);

View file

@ -18,13 +18,13 @@
namespace OCA\SideMenu\Settings; namespace OCA\SideMenu\Settings;
use OCA\SideMenu\AppInfo\Application;
use OCA\SideMenu\Service\AppRepository; use OCA\SideMenu\Service\AppRepository;
use OCA\SideMenu\Service\ConfigProxy;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\Settings\ISettings; use OCP\Settings\ISettings;
use OCA\SideMenu\AppInfo\Application;
class Admin implements ISettings class Admin implements ISettings
{ {
@ -39,7 +39,7 @@ class Admin implements ISettings
private $logger; private $logger;
/** /**
* @var IConfig * @var ConfigProxy
*/ */
private $config; private $config;
@ -48,7 +48,7 @@ class Admin implements ISettings
*/ */
private $appRepository; 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->l = $l;
$this->logger = $logger; $this->logger = $logger;
@ -61,32 +61,33 @@ class Admin implements ISettings
*/ */
public function getForm() public function getForm()
{ {
$backgroundColor = $this->config->getAppValue(Application::APP_ID, 'background-color', '#333333'); $backgroundColor = $this->config->getAppValue('background-color', '#333333');
$backgroundColorTo = $this->config->getAppValue(Application::APP_ID, 'background-color-to', $backgroundColor); $backgroundColorTo = $this->config->getAppValue('background-color-to', $backgroundColor);
$parameters = [ $parameters = [
'background-color' => $backgroundColor, 'background-color' => $backgroundColor,
'background-color-to' => $backgroundColorTo, 'background-color-to' => $backgroundColorTo,
'current-app-background-color' => $this->config->getAppValue(Application::APP_ID, 'current-app-background-color', '#444444'), 'current-app-background-color' => $this->config->getAppValue('current-app-background-color', '#444444'),
'loader-color' => $this->config->getAppValue(Application::APP_ID, 'loader-color', '#0e75ac'), 'loader-color' => $this->config->getAppValue('loader-color', '#0e75ac'),
'icon-invert-filter' => (int) $this->config->getAppValue(Application::APP_ID, 'icon-invert-filter', '0'), 'icon-invert-filter' => $this->config->getAppValueInt('icon-invert-filter', '0'),
'icon-opacity' => (int) $this->config->getAppValue(Application::APP_ID, 'icon-opacity', '100'), 'icon-opacity' => $this->config->getAppValueInt('icon-opacity', '100'),
'loader-enabled' => $this->config->getAppValue(Application::APP_ID, 'loader-enabled', '1'), 'loader-enabled' => $this->config->getAppValue('loader-enabled', '1'),
'text-color' => $this->config->getAppValue(Application::APP_ID, 'text-color', '#FFFFFF'), 'text-color' => $this->config->getAppValue('text-color', '#FFFFFF'),
'cache' => $this->config->getAppValue(Application::APP_ID, 'cache', '0'), 'cache' => $this->config->getAppValue('cache', '0'),
'opener' => $this->config->getAppValue(Application::APP_ID, 'opener', 'side-menu-opener'), 'opener' => $this->config->getAppValue('opener', 'side-menu-opener'),
'always-displayed' => $this->config->getAppValue(Application::APP_ID, 'always-displayed', '0'), 'always-displayed' => $this->config->getAppValue('always-displayed', '0'),
'big-menu' => $this->config->getAppValue(Application::APP_ID, 'big-menu', '0'), 'big-menu' => $this->config->getAppValue('big-menu', '0'),
'display-logo' => $this->config->getAppValue(Application::APP_ID, 'display-logo', '1'), 'display-logo' => $this->config->getAppValue('display-logo', '1'),
'use-avatar' => $this->config->getAppValue(Application::APP_ID, 'use-avatar', '0'), 'use-avatar' => $this->config->getAppValue('use-avatar', '0'),
'opener-position' => $this->config->getAppValue(Application::APP_ID, 'opener-position', 'before'), 'opener-position' => $this->config->getAppValue('opener-position', 'before'),
'opener-hover' => $this->config->getAppValue(Application::APP_ID, 'opener-hover', '0'), 'opener-hover' => $this->config->getAppValue('opener-hover', '0'),
'opener-only' => $this->config->getAppValue(Application::APP_ID, 'opener-only', '0'), 'opener-only' => $this->config->getAppValue('opener-only', '0'),
'hide-when-no-apps' => $this->config->getAppValue(Application::APP_ID, 'hide-when-no-apps', '0'), 'hide-when-no-apps' => $this->config->getAppValue('hide-when-no-apps', '0'),
'size-icon' => $this->config->getAppValue(Application::APP_ID, 'size-icon', 'normal'), 'size-icon' => $this->config->getAppValue('size-icon', 'normal'),
'size-text' => $this->config->getAppValue(Application::APP_ID, 'size-text', 'normal'), 'size-text' => $this->config->getAppValue('size-text', 'normal'),
'target-blank-apps' => (array) json_decode($this->config->getAppValue(Application::APP_ID, 'target-blank-apps', '[]'), true), 'force' => $this->config->getAppValue('force', '0'),
'top-menu-apps' => (array) json_decode($this->config->getAppValue(Application::APP_ID, 'top-menu-apps', '[]'), true), 'target-blank-apps' => $this->config->getAppValueArray('target-blank-apps', '[]'),
'top-menu-apps' => $this->config->getAppValueArray('top-menu-apps', '[]'),
'apps' => $this->appRepository->getVisibleApps(), 'apps' => $this->appRepository->getVisibleApps(),
]; ];

View file

@ -18,14 +18,14 @@
namespace OCA\SideMenu\Settings; 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\AppFramework\Http\TemplateResponse;
use OCP\IL10N; use OCP\IL10N;
use OCP\ILogger; use OCP\ILogger;
use OCP\Settings\ISettings;
use OCP\IConfig;
use OCP\IUserSession; use OCP\IUserSession;
use OCA\SideMenu\Service\AppRepository; use OCP\Settings\ISettings;
use OCA\SideMenu\AppInfo\Application;
class Personal implements ISettings class Personal implements ISettings
{ {
@ -40,7 +40,7 @@ class Personal implements ISettings
private $logger; private $logger;
/** /**
* @var IConfig * @var ConfigProxy
*/ */
private $config; private $config;
@ -54,7 +54,7 @@ class Personal implements ISettings
*/ */
private $appRepository; 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->l = $l;
$this->logger = $logger; $this->logger = $logger;
@ -71,10 +71,11 @@ class Personal implements ISettings
$user = $this->userSession->getUser(); $user = $this->userSession->getUser();
$parameters = [ $parameters = [
'enabled' => $this->config->getUserValue($user->getUid(), Application::APP_ID, 'enabled', '1'), 'force' => $this->config->getAppValueBool('force', '0'),
'top-menu-apps' => (array) json_decode($this->config->getUserValue($user->getUid(), Application::APP_ID, 'top-menu-apps', '[]'), true), 'enabled' => $this->config->getUserValue($user, 'enabled', '1'),
'target-blank-mode' => $this->config->getUserValue($user->getUid(), Application::APP_ID, 'target-blank-mode', '1'), 'top-menu-apps' => $this->config->getUserValueArray($user, 'top-menu-apps', '[]'),
'target-blank-apps' => (array) json_decode($this->config->getUserValue($user->getUid(), Application::APP_ID, 'target-blank-apps', '[]'), true), '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(), 'apps' => $this->appRepository->getVisibleApps(),
]; ];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View file

@ -57,3 +57,5 @@
"Use my selection": "Verwende meine Auswahl" "Use my selection": "Verwende meine Auswahl"
"Show and hide the list of applications": "Ein- und Ausblenden der Anwendungsliste" "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" "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"

View file

@ -57,3 +57,5 @@
"Use my selection": "Utiliser ma sélection" "Use my selection": "Utiliser ma sélection"
"Show and hide the list of applications": "Afficher et masquer la liste des applications" "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" "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"

View file

@ -473,6 +473,20 @@ $choicesSizes = [
</div> </div>
<div class="section"> <div class="section">
<div>
<label for="side-menu-opener-only">
<?php p($l->t('Force this configuration to users')); ?>
</label>
<select id="side-menu-force" name="force" class="side-menu-setting">
<?php foreach ($choicesYesNo as $label => $value): ?>
<option value="<?php echo $value ?>" <?php if ($value === $_['force']): ?>selected<?php endif; ?>>
<?php echo $l->t($label); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<input type="hidden" id="side-menu-cache" name="cache" value="<?php print_unescaped($_['cache']); ?>" class="side-menu-setting"> <input type="hidden" id="side-menu-cache" name="cache" value="<?php print_unescaped($_['cache']); ?>" class="side-menu-setting">
<button id="side-menu-save" class="btn btn-primary"><?php p($l->t('Save')); ?></button> <button id="side-menu-save" class="btn btn-primary"><?php p($l->t('Save')); ?></button>

View file

@ -27,12 +27,26 @@ $choicesYesNo = [
?> ?>
<div id="side-menu-section"> <div id="side-menu-section">
<?php if ($_['force']): ?>
<div class="section"> <div class="section">
<h2> <h2>
<?php p($l->t('Menu')); ?> <?php p($l->t('Menu')); ?>
</h2> </h2>
<p>
<em><?php echo $l->t('You do not have permission to change the settings.'); ?></em>
</p>
</div>
<?php else: ?>
<div class="section">
<h2>
<?php p($l->t('Menu')); ?>
</h2>
<div> <div>
<label for="side-menu-enabled"> <label for="side-menu-enabled">
<?php p($l->t('Enable the custom menu')); ?> <?php p($l->t('Enable the custom menu')); ?>
@ -139,13 +153,16 @@ $choicesYesNo = [
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
<?php endif ?>
<div class="section"> <div class="section">
<?php if (!$_['force']): ?>
<button id="side-menu-save" class="btn btn-primary"><?php p($l->t('Save')); ?></button> <button id="side-menu-save" class="btn btn-primary"><?php p($l->t('Save')); ?></button>
<span id="side-menu-message" class="msg"></span> <span id="side-menu-message" class="msg"></span>
<div style="height: 30px"></div> <div style="height: 30px"></div>
<?php endif ?>
<div> <div>
<span for="side-menu-opener"> <span for="side-menu-opener">