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

[TASK] Add ElectionCircular list

parent ad233ddc
......@@ -113,20 +113,18 @@ abstract class AbstractBeController extends ActionController
}
/**
* @param array $requiredUserGroups Array of UIDs of the user groups
* @param int $requiredUserGroup UID of the user group
* @return bool
*/
protected function backendUserHasUserGroup(array $requiredUserGroups)
protected function backendUserHasUserGroup($requiredUserGroup)
{
foreach ($requiredUserGroups as $requiredUserGroup) {
if (Configuration::AUTH_NONE === $requiredUserGroup) {
if (Configuration::AUTH_NONE === $requiredUserGroup) {
return true;
}
foreach ($this->backendUser->userGroups as $userGroup) {
if ((int)$userGroup['uid'] === $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->getRequiredUserGroups())) {
if (!$this->backendUserHasUserGroup($this->getRequiredUserGroup())) {
$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 getRequiredUserGroups();
abstract protected function getRequiredUserGroup();
}
......@@ -61,13 +61,13 @@ class BeConfigurationController extends AbstractProtectedBeController
}
/**
* @return int[]
* @return int
*/
protected function getRequiredUserGroups()
protected function getRequiredUserGroup()
{
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->backendUserHasUserGroup([$this->configuration->getElectionManagerGroup()])) {
if ($this->backendUserHasUserGroup($this->configuration->getElectionManagerGroup())) {
$this->view->assign('electorImports', $this->objectManager->get(ElectorImportRepository::class)->findAll());
}
}
......
......@@ -17,14 +17,23 @@ namespace TYPO3\Election\Controller;
/**
* Class BeConfigurationController
*/
class BeCircularController extends AbstractProtectedBeController
class BeElectionCircularController extends AbstractProtectedBeController
{
const CONTROLLER_NAME = 'BeCircular';
const CONTROLLER_NAME = 'BeElectionCircular';
const ACTION_LIST = 'list';
/**
* @var \TYPO3\Election\Domain\Repository\ElectionCircularRepository
* @inject
*/
protected $electionCircularRepository = null;
/**
*
*/
public function listAction()
{
$this->view->assign('electionCirculars', $this->electionCircularRepository->findAll());
}
/**
......@@ -41,10 +50,10 @@ class BeCircularController extends AbstractProtectedBeController
}
/**
* @return int[]
* @return int
*/
protected function getRequiredUserGroups()
protected function getRequiredUserGroup()
{
return [$this->configuration->getElectionManagerGroup(), $this->configuration->getPollManagerGroup()];
return $this->configuration->getElectionManagerGroup();
}
}
......@@ -136,10 +136,10 @@ class BeElectionController extends AbstractProtectedBeController
}
/**
* @return int[]
* @return int
*/
protected function getRequiredUserGroups()
protected function getRequiredUserGroup()
{
return [$this->configuration->getElectionManagerGroup()];
return $this->configuration->getElectionManagerGroup();
}
}
......@@ -203,10 +203,10 @@ class BeElectorController extends AbstractProtectedBeController
}
/**
* @return int[]
* @return int
*/
protected function getRequiredUserGroups()
protected function getRequiredUserGroup()
{
return [$this->configuration->getElectionManagerGroup()];
return $this->configuration->getElectionManagerGroup();
}
}
......@@ -114,11 +114,11 @@ class BeElectorateController extends AbstractProtectedBeController
}
/**
* @return int[]
* @return int
*/
protected function getRequiredUserGroups()
protected function getRequiredUserGroup()
{
return [$this->configuration->getElectionManagerGroup()];
return $this->configuration->getElectionManagerGroup();
}
/**
......
......@@ -127,11 +127,11 @@ class BeNomineeController extends AbstractProtectedBeController
}
/**
* @return int[]
* @return int
*/
protected function getRequiredUserGroups()
protected function getRequiredUserGroup()
{
return [$this->configuration->getElectionManagerGroup()];
return $this->configuration->getElectionManagerGroup();
}
/**
......
......@@ -15,15 +15,57 @@ namespace TYPO3\Election\Domain\Model;
*/
/**
* Class Circular
* Class ElectionCircular
*/
class Circular extends AbstractEntity
class ElectionCircular extends AbstractEntity
{
/**
* @var string
*/
protected $subject = '';
/**
* @var string
*/
protected $body = '';
/**
* @var \TYPO3\Election\Domain\Model\Election
*/
protected $election = null;
/**
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* @param string $subject
*/
public function setSubject($subject)
{
$this->subject = $subject;
}
/**
* @return string
*/
public function getBody()
{
return $this->body;
}
/**
* @param string $body
*/
public function setBody($body)
{
$this->body = $body;
}
/**
* @return Election
*/
......
<?php
namespace TYPO3\Election\Domain\Repository;
/*
* 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!
*/
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Class ElectionCircularRepository
*/
class ElectionCircularRepository extends Repository
{
}
......@@ -88,8 +88,8 @@
<trans-unit id="view.be.dashboard.nominee.list">
<source>Nominees</source>
</trans-unit>
<trans-unit id="view.be.dashboard.circular.list">
<source>Circular</source>
<trans-unit id="view.be.dashboard.election_circular.list">
<source>Election Circular</source>
</trans-unit>
<!-- BE CONFIGURATION-->
......@@ -278,7 +278,6 @@
<trans-unit id="model.nominee.field.image">
<source>Image</source>
</trans-unit>
<trans-unit id="model.nominee.field.url">
<source>URL</source>
</trans-unit>
......@@ -291,6 +290,25 @@
<trans-unit id="model.nominee.field.public">
<source>Public</source>
</trans-unit>
</trans-unit>
<!-- BE ELECTION CIRCULARS -->
<trans-unit id="view.be.election_circular.list.welcome">
<source>Election Circulars</source>
</trans-unit>
<!-- MODEL ELECTION CIRCULARS -->
<trans-unit id="model.election_circular.field.subject">
<source>Subject</source>
</trans-unit>
<trans-unit id="model.election_circular.field.body">
<source>Body</source>
</trans-unit>
<trans-unit id="model.election_circular.field.election">
<source>Election</source>
</trans-unit>
</body>
</file>
......
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<table class="table">
<thead>
<tr>
<th>
<f:translate key="model.election_circular.field.subject">Subject</f:translate>
</th>
<th>
<f:translate key="model.election_circular.field.body">Body</f:translate>
</th>
<th>
<f:translate key="model.election_circular.field.election">Election</f:translate>
</th>
<th>
<f:translate key="view.be.anything.options">Options</f:translate>
</th>
</tr>
</thead>
<tbody>
<f:for each="{electionCirculars}" as="electionCircular">
<tr>
<td>
<f:link.action action="edit" controller="BeElectionCircular" arguments="{electionCircular:electionCircular}">
{electionCircular.subject}
</f:link.action>
</td>
<td>
{electionCircular.body}
</td>
<td>
{electionCircular.election.title}
</td>
<td>
<div class="btn-group">
<f:link.action class="btn btn-default" action="edit" controller="BeElectionCircular" arguments="{electionCircular:electionCircular}">
<core:icon identifier="actions-edit-rename"/>
</f:link.action>
<f:link.action class="btn btn-default" action="delete" controller="BeElectionCircular" arguments="{electionCircular:electionCircular}">
<core:icon identifier="actions-edit-delete"/>
</f:link.action>
</div>
</td>
</tr>
</f:for>
</tbody>
</table>
......@@ -12,23 +12,10 @@
<f:link.action class="btn btn-default" action="list" controller="BeElector">
<f:translate key="view.be.dashboard.electors.list">Electors</f:translate>
</f:link.action>
<f:link.action class="btn btn-default" action="list" controller="BeElectionCircular">
<f:translate key="view.be.dashboard.election_circular.list">Election Circular</f:translate>
</f:link.action>
</f:be.security.ifHasRole>
<f:be.security.ifHasRole role="{configuration.electionManagerGroup}">
<f:then>
<f:link.action class="btn btn-default" action="list" controller="BeCircular">
<f:translate key="view.be.dashboard.circular.list">Circular</f:translate>
</f:link.action>
</f:then>
<f:else>
<f:be.security.ifHasRole role="{configuration.electionManagerGroup}">
<f:link.action class="btn btn-default" action="list" controller="BeCircular">
<f:translate key="view.be.dashboard.circular.list">Circular</f:translate>
</f:link.action>
</f:be.security.ifHasRole>
</f:else>
</f:be.security.ifHasRole>
<f:be.security.ifHasRole role="{configuration.administrationGroup}">
<f:link.action class="btn btn-default" action="edit" controller="BeConfiguration">
<core:icon identifier="actions-system-extension-configure"/>
......
<f:layout name="Backend"/>
<f:section name="LeftToolBar">
<f:render partial="View/Menu/ActionButtons/New"/>
</f:section>
<f:section name="RightToolBar">
<f:render partial="View/Menu/GlobalOptions" arguments="{configuration:configuration}"/>
</f:section>
<f:section name="Welcome">
<h1>
<f:translate key="view.be.election_circular.list.welcome">
election circulars
</f:translate>
</h1>
</f:section>
<f:section name="Main">
<f:render partial="Model/ElectionCircular/List" arguments="{electionCirculars:electionCirculars}"/>
</f:section>
......@@ -28,8 +28,8 @@ call_user_func(
\TYPO3\Election\Controller\BeElectorateController::getActionsForModuleConfiguration(),
\TYPO3\Election\Controller\BeNomineeController::CONTROLLER_NAME =>
\TYPO3\Election\Controller\BeNomineeController::getActionsForModuleConfiguration(),
\TYPO3\Election\Controller\BeCircularController::CONTROLLER_NAME =>
\TYPO3\Election\Controller\BeCircularController::getActionsForModuleConfiguration(),
\TYPO3\Election\Controller\BeElectionCircularController::CONTROLLER_NAME =>
\TYPO3\Election\Controller\BeElectionCircularController::getActionsForModuleConfiguration(),
),
array(
'access' => 'user,group',
......
......@@ -97,21 +97,38 @@ CREATE TABLE tx_election_domain_model_electorate (
# Table structure for table 'tx_election_domain_model_nominee'
#
CREATE TABLE tx_election_domain_model_nominee (
uid INT(11) unsigned NOT NULL auto_increment,
pid INT(11) unsigned DEFAULT '0' NOT NULL,
creation_date INT(11) unsigned DEFAULT '0' NOT NULL,
creation_user INT(11) unsigned DEFAULT '0' NOT NULL,
uid INT(11) unsigned NOT NULL auto_increment,
pid INT(11) unsigned DEFAULT '0' NOT NULL,
creation_date INT(11) unsigned DEFAULT '0' NOT NULL,
creation_user INT(11) unsigned DEFAULT '0' NOT NULL,
first_name VARCHAR(255) DEFAULT '' NOT NULL,
middle_name VARCHAR(255) DEFAULT '' NOT NULL,
last_name VARCHAR(255) DEFAULT '' NOT NULL,
gender TINYINT(4) unsigned DEFAULT '0' NOT NULL,
email VARCHAR(255) DEFAULT '' NOT NULL,
url VARCHAR(255) DEFAULT '' NOT NULL,
image INT(11) unsigned DEFAULT '0' NOT NULL,
comment text NOT NULL,
public TINYINT(4) unsigned DEFAULT '0' NOT NULL,
elections INT(11) unsigned DEFAULT '0' NOT NULL,
first_name VARCHAR(255) DEFAULT '' NOT NULL,
middle_name VARCHAR(255) DEFAULT '' NOT NULL,
last_name VARCHAR(255) DEFAULT '' NOT NULL,
gender TINYINT(4) DEFAULT '0' NOT NULL,
email VARCHAR(255) DEFAULT '' NOT NULL,
url VARCHAR(255) DEFAULT '' NOT NULL,
image INT(11) DEFAULT '0' NOT NULL,
comment text NOT NULL,
public TINYINT(4) DEFAULT '0' NOT NULL,
elections INT(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
#
# Table structure for table 'tx_election_domain_model_electioncircular'
#
CREATE TABLE tx_election_domain_model_electioncircular (
uid INT(11) unsigned NOT NULL auto_increment,
pid INT(11) unsigned DEFAULT '0' NOT NULL,
creation_date INT(11) unsigned DEFAULT '0' NOT NULL,
creation_user INT(11) unsigned DEFAULT '0' NOT NULL,
subject VARCHAR(255) DEFAULT '' NOT NULL,
body INT(11) unsigned DEFAULT '0' NOT NULL,
election INT(11) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
......@@ -121,10 +138,10 @@ CREATE TABLE tx_election_domain_model_nominee (
# Table structure for table 'tx_election_domain_model_electorate_elector_mm'
#
CREATE TABLE tx_election_domain_model_electorate_elector_mm (
uid_local INT(11) DEFAULT '0' NOT NULL,
uid_foreign INT(11) DEFAULT '0' NOT NULL,
sorting INT(11) DEFAULT '0' NOT NULL,
sorting_foreign INT(11) DEFAULT '0' NOT NULL,
uid_local INT(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign INT(11) unsigned DEFAULT '0' NOT NULL,
sorting INT(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign INT(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
......@@ -133,10 +150,10 @@ CREATE TABLE tx_election_domain_model_electorate_elector_mm (
# Table structure for table 'tx_election_domain_model_election_nominee_mm'
#
CREATE TABLE tx_election_domain_model_election_nominee_mm (
uid_local INT(11) DEFAULT '0' NOT NULL,
uid_foreign INT(11) DEFAULT '0' NOT NULL,
sorting INT(11) DEFAULT '0' NOT NULL,
sorting_foreign INT(11) DEFAULT '0' NOT NULL,
uid_local INT(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign INT(11) unsigned DEFAULT '0' NOT NULL,
sorting INT(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign INT(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
......@@ -128,4 +128,22 @@ config.tx_extbase.persistence.classes {
}
}
}
TYPO3\Election\Domain\Model\ElectionCircular < temp.abstractEntity
TYPO3\Election\Domain\Model\ElectionCircular {
mapping {
tableName = tx_election_domain_model_electioncircular
columns {
subject.mapOnProperty = subject
body.mapOnProperty = body
election {
mapOnProperty = election
config {
type = select
foreign_table = tx_election_domain_model_election
}
}
}
}
}
}
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