Skip to content
Snippets Groups Projects
Commit b0d59e65 authored by Robert Lange's avatar Robert Lange Committed by Dorian Merz
Browse files

refs #16586 [finc] set permission handling for I18nController

* extend AbstractAdmin to check for access permission for AdminModule
** admin module must be activated in config.ini by admin_enabled = true
** permission access.AdminModule should be set in permissions.ini
parent 4983010a
No related merge requests found
...@@ -20,18 +20,17 @@ ...@@ -20,18 +20,17 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
namespace finc\Controller\Admin; namespace finc\Controller\Admin;
use Symfony\Component\Filesystem\Filesystem as Fs; use Symfony\Component\Filesystem\Filesystem as Fs;
use VuFind\Auth\InvalidArgumentException; use VuFind\Auth\InvalidArgumentException;
use VuFind\Config\Writer as ConfigWriter; use VuFind\Config\Writer as ConfigWriter;
use VuFind\Controller\AbstractBase;
use VuFind\I18n\Translator\Loader\ExtendedIni; use VuFind\I18n\Translator\Loader\ExtendedIni;
use VuFindAdmin\Controller\AbstractAdmin;
use Zend\I18n\Translator\Translator; use Zend\I18n\Translator\Translator;
use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceLocatorInterface;
class I18nController extends AbstractBase class I18nController extends AbstractAdmin
{ {
/** /**
* @var string[] * @var string[]
...@@ -89,7 +88,6 @@ class I18nController extends AbstractBase ...@@ -89,7 +88,6 @@ class I18nController extends AbstractBase
$this->languages = array_combine($locales, $languages); $this->languages = array_combine($locales, $languages);
} }
public function homeAction() public function homeAction()
{ {
$params = $this->params(); $params = $this->params();
...@@ -165,7 +163,6 @@ class I18nController extends AbstractBase ...@@ -165,7 +163,6 @@ class I18nController extends AbstractBase
$locale, $locale,
$reset ? null : $value $reset ? null : $value
); );
} }
protected function getTranslations(): array protected function getTranslations(): array
...@@ -243,14 +240,13 @@ class I18nController extends AbstractBase ...@@ -243,14 +240,13 @@ class I18nController extends AbstractBase
protected function saveTranslation($domain, $token, $locale, $value) protected function saveTranslation($domain, $token, $locale, $value)
{ {
$fs = new FS(); $fs = new FS();
list($filename) = array_slice($this->dirs, -1);; list($filename) = array_slice($this->dirs, -1);
if ($domain !== 'default') { if ($domain !== 'default') {
$filename .= "/$domain"; $filename .= "/$domain";
} }
$filename .= "/$locale.ini"; $filename .= "/$locale.ini";
try { try {
if (empty($token)) { if (empty($token)) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
$this->translate('This field is required') . ": Token" $this->translate('This field is required') . ": Token"
...@@ -366,4 +362,4 @@ class I18nController extends AbstractBase ...@@ -366,4 +362,4 @@ class I18nController extends AbstractBase
$response->setStatusCode(205); $response->setStatusCode(205);
return $response; return $response;
} }
} }
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment