Commit bf630bf2 authored by Oliver Eglseder's avatar Oliver Eglseder
Browse files

[TASK] Test for at least one usergroup instead of one

parent 8b2698dd
......@@ -113,18 +113,20 @@ abstract class AbstractBeController extends ActionController
}
/**
* @param int $requiredUserGroup Uid of the user group
* @param array $requiredUserGroups Array of UIDs of the user groups
* @return bool
*/
protected function backendUserHasUserGroup($requiredUserGroup)
protected function backendUserHasUserGroup(array $requiredUserGroups)
{
if (Configuration::AUTH_NONE === $requiredUserGroup) {
return true;
}
foreach ($this->backendUser->userGroups as $userGroup) {
if ((int)$userGroup['uid'] === $requiredUserGroup) {
foreach ($requiredUserGroups as $requiredUserGroup) {
if (Configuration::AUTH_NONE === $requiredUserGroup) {
return true;
}
foreach ($this->backendUser->userGroups as $userGroup) {
if ((int)$userGroup['uid'] === $requiredUserGroup) {
return true;
}
}
}
return false;
}
......
......@@ -27,7 +27,7 @@ abstract class AbstractProtectedBeController extends AbstractBeController
*/
protected function initializeAction()
{
if (!$this->backendUserHasUserGroup($this->getRequiredUserGroup())) {
if (!$this->backendUserHasUserGroup($this->getRequiredUserGroups())) {
$this->addFlashMessage(
LocalizationUtility::translate('controller.be.protected_controller.no_permission', 'election'),
LocalizationUtility::translate('controller.be.protected_controller.error', 'election'),
......@@ -38,7 +38,7 @@ abstract class AbstractProtectedBeController extends AbstractBeController
}
/**
* @return int
* @return int[]
*/
abstract protected function getRequiredUserGroup();
abstract protected function getRequiredUserGroups();
}
<?php
namespace TYPO3\Election\Controller;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class BeConfigurationController
*/
class BeCircularController extends AbstractProtectedBeController
{
const CONTROLLER_NAME = 'BeCircular';
/**
* @return string
*/
public static function getActionsForModuleConfiguration()
{
return implode(
',',
[
]
);
}
/**
* @return int[]
*/
protected function getRequiredUserGroups()
{
return [$this->configuration->getElectionManagerGroup(), $this->configuration->getPollManagerGroup()];
}
}
......@@ -61,13 +61,13 @@ class BeConfigurationController extends AbstractProtectedBeController
}
/**
* @return int
* @return int[]
*/
protected function getRequiredUserGroup()
protected function getRequiredUserGroups()
{
if (null === $this->configuration) {
return Configuration::AUTH_NONE;
return [Configuration::AUTH_NONE];
}
return $this->configuration->getAdministrationGroup();
return [$this->configuration->getAdministrationGroup()];
}
}
......@@ -39,7 +39,7 @@ class BeDashboardController extends AbstractBeController
'elections' => $this->electionRepository->findAll(),
]
);
if ($this->configuration->getElectionManagerGroup()) {
if ($this->backendUserHasUserGroup([$this->configuration->getElectionManagerGroup()])) {
$this->view->assign('electorImports', $this->objectManager->get(ElectorImportRepository::class)->findAll());
}
}
......
......@@ -136,10 +136,10 @@ class BeElectionController extends AbstractProtectedBeController
}
/**
* @return int
* @return int[]
*/
protected function getRequiredUserGroup()
protected function getRequiredUserGroups()
{
return $this->configuration->getElectionManagerGroup();
return [$this->configuration->getElectionManagerGroup()];
}
}
......@@ -203,10 +203,10 @@ class BeElectorController extends AbstractProtectedBeController
}
/**
* @return int
* @return int[]
*/
protected function getRequiredUserGroup()
protected function getRequiredUserGroups()
{
return $this->configuration->getElectionManagerGroup();
return [$this->configuration->getElectionManagerGroup()];
}
}
......@@ -114,11 +114,11 @@ class BeElectorateController extends AbstractProtectedBeController
}
/**
* @return int
* @return int[]
*/
protected function getRequiredUserGroup()
protected function getRequiredUserGroups()
{
return $this->configuration->getElectionManagerGroup();
return [$this->configuration->getElectionManagerGroup()];
}
/**
......
......@@ -127,11 +127,11 @@ class BeNomineeController extends AbstractProtectedBeController
}
/**
* @return int
* @return int[]
*/
protected function getRequiredUserGroup()
protected function getRequiredUserGroups()
{
return $this->configuration->getElectionManagerGroup();
return [$this->configuration->getElectionManagerGroup()];
}
/**
......
Supports Markdown
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