add personal settings page to enabled (or not) the side menu

This commit is contained in:
Simon Vieille
2020-05-11 22:51:27 +02:00
parent 375ed7d2f1
commit 7ac19c7bec
13 changed files with 429 additions and 72 deletions
+3 -1
View File
@@ -27,7 +27,9 @@ use OCP\IRequest;
class CssController extends Controller
{
/** @var \OCP\IConfig */
/**
* @var \OCP\IConfig
*/
protected $config;
/**
+3 -1
View File
@@ -27,7 +27,9 @@ use OCP\IRequest;
class JsController extends Controller
{
/** @var \OCP\IConfig */
/**
* @var \OCP\IConfig
*/
protected $config;
/**
@@ -0,0 +1,72 @@
<?php
/**
* @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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\SideMenu\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\Response;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
class PersonalSettingController extends Controller
{
/**
* @var \OCP\IConfig
*/
protected $config;
/**
* @var IUserSession
*/
private $userSession;
public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession)
{
parent::__construct($appName, $request);
$this->config = $config;
$this->userSession = $userSession;
}
/**
* @NoAdminRequired
*
* @return Response
*/
public function valueSet($name, $value)
{
$doSave = false;
$user = $this->userSession->getUser();
if ($name === 'enabled') {
$doSave = true;
if (!in_array($value, ['0', '1'])) {
$value = '1';
}
}
if ($doSave) {
$this->config->setUserValue($user->getUid(), 'side_menu', 'enabled', $value);
}
return [];
}
}