Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
voting.typo3.org
extensions
election
Commits
bf630bf2
Commit
bf630bf2
authored
Dec 22, 2015
by
Oliver Eglseder
Browse files
[TASK] Test for at least one usergroup instead of one
parent
8b2698dd
Changes
9
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/AbstractBeController.php
View file @
bf630bf2
...
...
@@ -113,18 +113,20 @@ abstract class AbstractBeController extends ActionController
}
/**
* @param
int
$requiredUserGroup
Uid
of the user group
* @param
array
$requiredUserGroup
s Array of UIDs
of the user group
s
* @return bool
*/
protected
function
backendUserHasUserGroup
(
$requiredUserGroup
)
protected
function
backendUserHasUserGroup
(
array
$requiredUserGroup
s
)
{
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
;
}
...
...
Classes/Controller/AbstractProtectedBeController.php
View file @
bf630bf2
...
...
@@ -27,7 +27,7 @@ abstract class AbstractProtectedBeController extends AbstractBeController
*/
protected
function
initializeAction
()
{
if
(
!
$this
->
backendUserHasUserGroup
(
$this
->
getRequiredUserGroup
()))
{
if
(
!
$this
->
backendUserHasUserGroup
(
$this
->
getRequiredUserGroup
s
()))
{
$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
getRequiredUserGroup
s
();
}
Classes/Controller/BeCircularController.php
0 → 100644
View file @
bf630bf2
<?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
()];
}
}
Classes/Controller/BeConfigurationController.php
View file @
bf630bf2
...
...
@@ -61,13 +61,13 @@ class BeConfigurationController extends AbstractProtectedBeController
}
/**
* @return int
* @return int
[]
*/
protected
function
getRequiredUserGroup
()
protected
function
getRequiredUserGroup
s
()
{
if
(
null
===
$this
->
configuration
)
{
return
Configuration
::
AUTH_NONE
;
return
[
Configuration
::
AUTH_NONE
]
;
}
return
$this
->
configuration
->
getAdministrationGroup
();
return
[
$this
->
configuration
->
getAdministrationGroup
()
]
;
}
}
Classes/Controller/BeDashboardController.php
View file @
bf630bf2
...
...
@@ -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
());
}
}
...
...
Classes/Controller/BeElectionController.php
View file @
bf630bf2
...
...
@@ -136,10 +136,10 @@ class BeElectionController extends AbstractProtectedBeController
}
/**
* @return int
* @return int
[]
*/
protected
function
getRequiredUserGroup
()
protected
function
getRequiredUserGroup
s
()
{
return
$this
->
configuration
->
getElectionManagerGroup
();
return
[
$this
->
configuration
->
getElectionManagerGroup
()
]
;
}
}
Classes/Controller/BeElectorController.php
View file @
bf630bf2
...
...
@@ -203,10 +203,10 @@ class BeElectorController extends AbstractProtectedBeController
}
/**
* @return int
* @return int
[]
*/
protected
function
getRequiredUserGroup
()
protected
function
getRequiredUserGroup
s
()
{
return
$this
->
configuration
->
getElectionManagerGroup
();
return
[
$this
->
configuration
->
getElectionManagerGroup
()
]
;
}
}
Classes/Controller/BeElectorateController.php
View file @
bf630bf2
...
...
@@ -114,11 +114,11 @@ class BeElectorateController extends AbstractProtectedBeController
}
/**
* @return int
* @return int
[]
*/
protected
function
getRequiredUserGroup
()
protected
function
getRequiredUserGroup
s
()
{
return
$this
->
configuration
->
getElectionManagerGroup
();
return
[
$this
->
configuration
->
getElectionManagerGroup
()
]
;
}
/**
...
...
Classes/Controller/BeNomineeController.php
View file @
bf630bf2
...
...
@@ -127,11 +127,11 @@ class BeNomineeController extends AbstractProtectedBeController
}
/**
* @return int
* @return int
[]
*/
protected
function
getRequiredUserGroup
()
protected
function
getRequiredUserGroup
s
()
{
return
$this
->
configuration
->
getElectionManagerGroup
();
return
[
$this
->
configuration
->
getElectionManagerGroup
()
]
;
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment