Commit cfad0caa authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch '1-typo3-8-7-compatibility' into 'master'

Resolve "TYPO3 8.7 compatibility"

Closes #1

See merge request t3o/election!1
parents 64638664 9b46dcd1
......@@ -14,7 +14,9 @@ namespace TYPO3\Election\Controller;
* The TYPO3 project - inspiring people to share!
*/
use Doctrine\Common\Util\Debug;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
......@@ -41,4 +43,38 @@ abstract class AbstractProtectedBeController extends AbstractBeController
* @return int
*/
abstract protected function getRequiredUserGroup();
protected function errorAction()
{
$this->clearCacheOnError();
$message="";
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $propertyPath => $errors) {
foreach ($errors as $error) {
$message .= PHP_EOL. 'Error for ' . $propertyPath . ': ' . $error->render();
}
}
$errorFlashMessage = $this->getErrorFlashMessage();
if ($errorFlashMessage !== FALSE) {
$errorFlashMessageObject = new \TYPO3\CMS\Core\Messaging\FlashMessage(
$errorFlashMessage." ".$message,
'',
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
);
$this->controllerContext->getFlashMessageQueue()->enqueue($errorFlashMessageObject);
}
$referringRequest = $this->request->getReferringRequest();
if ($referringRequest !== NULL) {
$originalRequest = clone $this->request;
$this->request->setOriginalRequest($originalRequest);
$this->request->setOriginalRequestMappingResults($this->arguments->getValidationResults());
$this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $referringRequest->getControllerExtensionName(), $referringRequest->getArguments());
}
DebuggerUtility::var_dump($this->request['nominee.image']);
$message = 'An error occurred while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL;
return $message;
}
}
......@@ -156,7 +156,7 @@ class FeElectionController extends ActionController
$this->addFlashMessage(
LocalizationUtility::translate('controller.fe.election.vote.thank_you', 'election'),
LocalizationUtility::translate('controller.fe.election.vote.success', 'election'),
AbstractMessage::SUCCESS
AbstractMessage::OK
);
$this->redirect(FeDashboardController::ACTION_INDEX, FeDashboardController::CONTROLLER_NAME);
}
......@@ -167,6 +167,7 @@ class FeElectionController extends ActionController
public function showAction(Election $election)
{
$this->view->assign('election', $election);
$this->view->assign('results',$election->getElectedNomineesAndVotes());
}
......
......@@ -260,7 +260,7 @@ class Election extends AbstractEntity
{
$nominees = [];
/** @var ElectionVote $electionVote */
foreach ($this->electionVotes as $electionVote) {
foreach ($this->getElectionVotes() as $electionVote) {
$nominee = $electionVote->getNominee();
$uid = $nominee->getUid();
if (isset($nominees[$uid])) {
......@@ -269,6 +269,10 @@ class Election extends AbstractEntity
$nominees[$uid]['votes'] = 1;
$nominees[$uid]['nominee'] = $nominee;
}
if($this->getElectionVotes()>0){
$nominees[$uid]['relativevotes'] =
round($nominees[$uid]['votes'] / count($this->getElectionVotes()) * 100,2);
}
}
uasort(
$nominees,
......
......@@ -20,6 +20,7 @@ use TYPO3\Election\Domain\Model\Configuration;
use TYPO3\Election\Domain\Model\ElectionCircular;
use TYPO3\Election\Domain\Model\ElectionInvitation;
use TYPO3\Election\Domain\Model\Elector;
use TYPO3\CMS\Core\Crypto\Random;
/**
* Class ElectionInvitationService
......@@ -49,7 +50,7 @@ class ElectionInvitationService
$electionInvitation = new ElectionInvitation();
$electionInvitation->setElector($possibleReceiver);
$electionInvitation->setElectionCircular($electionCircular);
$electionInvitation->setSecret(GeneralUtility::getRandomHexString(mt_rand(180, 220)));
$electionInvitation->setSecret(GeneralUtility::makeInstance(Random::class)->generateRandomHexString(mt_rand(180,220)));
$this->electionInvitationRepository->add($electionInvitation);
$this->electionInvitationRepository->persistAll();
$electionInvitation->setSuccess($this->sendElectionInvitation($configuration, $electionInvitation));
......
......@@ -22,6 +22,7 @@ use TYPO3\Election\Domain\Model\ElectionCircular;
use TYPO3\Election\Domain\Model\ElectionInvitation;
use TYPO3\Election\Domain\Model\Elector;
use TYPO3\Election\Domain\Repository\ElectionInvitationRepository;
use TYPO3\CMS\Core\Crypto\Random;
/**
* Class MailUtility
......@@ -46,7 +47,7 @@ class MailUtility
$electionInvitation = new ElectionInvitation();
$electionInvitation->setElector($elector);
$electionInvitation->setElectionCircular($electionCircular);
$electionInvitation->setSecret(GeneralUtility::getRandomHexString(mt_rand(180, 220)));
$electionInvitation->setSecret(GeneralUtility::makeInstance(Random::class)->generateRandomHexString(mt_rand(180,220)));
$electionInvitationRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(ElectionInvitationRepository::class);
$electionInvitationRepository->add($electionInvitation);
......
......@@ -86,4 +86,9 @@ class UploadViewHelper extends CoreUploadViewHelper
}
return $this->propertyMapper->convert($resource, FileReference::class);
}
private function getValue($param){
//TODO
return null;
}
}
......@@ -223,6 +223,9 @@
<trans-unit id="model.election.field.title">
<source>Title</source>
</trans-unit>
<trans-unit id="model.election.date_format">
<source>Y-m-d</source>
</trans-unit>
<!-- MODEL ELECTOR -->
......@@ -469,6 +472,18 @@
<trans-unit id="view.fe.election.vote.vote">
<source>Vote</source>
</trans-unit>
<trans-unit id="view.fe.election.show.result">
<source>Voting Results</source>
</trans-unit>
<trans-unit id="view.fe.election.show.active">
<source>Voting in Progress</source>
</trans-unit>
<trans-unit id="view.fe.election.show.nominee">
<source>Nominee</source>
</trans-unit>
<trans-unit id="view.fe.election.show.votes">
<source>Votes</source>
</trans-unit>
<!-- FE ELECTION VOTING VALIDATION-->
......
......@@ -24,7 +24,14 @@
<f:for each="{nominees}" as="nominee">
<tr {f:if(condition:'{nominee.public}',else:'style="background-color:#ddd;"')}>
<td>
<f:image image="{nominee.image}" width="50c" height="50c"/>
<f:if condition="{nominee.image}">
<f:then>
<f:image image="{nominee.image}" width="50c" height="50c"/>
</f:then>
<f:else>
<f:image src="EXT:core/Resources/Public/Icons/T3Icons/avatar/avatar-default.svg" width="50c" height="50c"/>
</f:else>
</f:if>
</td>
<td>
<f:link.action action="edit" controller="BeNominee" arguments="{nominee:nominee}">
......
......@@ -22,7 +22,14 @@
<f:if condition="{nominee.public}">
<tr>
<td>
<f:image image="{nominee.image}" width="50c" height="50c"/>
<f:if condition="{nominee.image}">
<f:then>
<f:image image="{nominee.image}" width="50c" height="50c"/>
</f:then>
<f:else>
<f:image src="EXT:core/Resources/Public/Icons/T3Icons/avatar/avatar-default.svg" width="50c" height="50c"/>
</f:else>
</f:if>
</td>
<td>
{nominee.fullName}
......
......@@ -27,10 +27,10 @@
<f:link.action controller="FeElection" action="show" arguments="{election:election}">{election.title}</f:link.action>
</td>
<td>
{election.title}
<f:format.date format="{f:translate(key: 'LLL:EXT:election/Resources/Private/Language/locallang.xlf:model.election.date_format')}">{election.startDate}</f:format.date>
</td>
<td>
{election.title}
<f:format.date format="{f:translate(key: 'LLL:EXT:election/Resources/Private/Language/locallang.xlf:model.election.date_format')}">{election.endDate}</f:format.date>
</td>
</tr>
</f:else>
......@@ -63,10 +63,10 @@
<f:link.action controller="FeElection" action="show" arguments="{election:election}">{election.title}</f:link.action>
</td>
<td>
{election.title}
<f:format.date format="{f:translate(key: 'LLL:EXT:election/Resources/Private/Language/locallang.xlf:model.election.date_format')}">{election.startDate}</f:format.date>
</td>
<td>
{election.title}
<f:format.date format="{f:translate(key: 'LLL:EXT:election/Resources/Private/Language/locallang.xlf:model.election.date_format')}">{election.endDate}</f:format.date>
</td>
</tr>
</f:then>
......
......@@ -4,12 +4,41 @@
<h1>
{election.title}
</h1>
<f:if condition="{election.ElectionFinished}">
<f:then>
<h2>Result</h2>
</f:then>
<f:else>
active
</f:else>
</f:if>
<div>
{election.description}
</div>
<h2><f:translate key="view.fe.election.show.result"/></h2>
<table class="table table-hover">
<thead>
<tr>
<th>
<f:translate key="view.fe.election.show.nominee"/>
</th>
<th>
<f:translate key="view.fe.election.show.votes"/>
</th>
</tr>
</thead>
<tbody>
<f:for each="{results}" as="result">
<tr>
<td>
{result.nominee.lastName}, {result.nominee.firstName} {result.nominee.MiddleName}
</td>
<td>
<f:if condition="{election.ElectionFinished}">
<f:then>
<f:if condition="{result.relativevotes}">
{result.relativevotes}% ({result.votes} <f:translate key="view.fe.election.show.votes"/>)
</f:if>
</f:then>
<f:else>
<f:translate key="view.fe.election.show.active"/>
</f:else>
</f:if>
</td>
</tr>
</f:for>
</tbody>
</table>
</f:section>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="#AD131B" d="M0 0h64v64H0z"/><path fill="#FFF" d="M19 14h26a1 1 0 0 1 1 1v34a1 1 0 0 1-1 1H19a1 1 0 0 1-1-1V15a1 1 0 0 1 1-1zM40 14H24l2.667-2h10.666z"/><path opacity=".5" fill="#D04139" d="M40 14H24l2.667 2h10.666z"/><path transform="scale(2)" fill="#AD131B" d="M21.3 12.8l-.7-.7c-.2-.2-.5-.2-.7 0l-5.4 5.4-2.5-2.6c-.2-.2-.5-.2-.7 0l-.6.7c-.2.2-.2.5 0 .7l3.6 3.6c.2.2.5.2.7 0l6.4-6.4c.1-.2.1-.5-.1-.7z"/></svg>
\ No newline at end of file
......@@ -3,6 +3,20 @@
"type": "typo3-cms-extension",
"description": "TYPO3 Association voting/polling tool",
"license": "GPL-2.0+",
"authors": [
{
"name": "Oliver Eglseder",
"email": "php@vxvr.de"
},
{
"name": "Stefan Busemann",
"email": "stefan.busemann@in2code.de"
},
{
"name": "Christoph Pascher",
"email": "c.pascher@browserwerk.de"
}
],
"autoload": {
"psr-4": {
"TYPO3\\Election\\": "Classes/"
......
......@@ -15,8 +15,8 @@ $EM_CONF[$_EXTKEY] = array(
'uploadfolder' => false,
'createDirs' => '',
'clearcacheonload' => true,
'author' => 'Oliver Eglseder, Stefan Busemann',
'author_email' => 'php@vxvr.de, stefan.busemann@in2code.de',
'author' => 'Oliver Eglseder, Stefan Busemann, Christoph Pascher',
'author_email' => 'php@vxvr.de, stefan.busemann@in2code.de, c.pascher@browserwerk.de',
'author_company' => 'TYPO3 Association',
'version' => '0.0.2',
);
......@@ -33,7 +33,7 @@ call_user_func(
),
array(
'access' => 'user,group',
'icon' => '',
'icon' => 'EXT:election/Resources/Public/Icons/module-election.svg',
'labels' => 'LLL:EXT:election/Resources/Private/Language/locallang.xlf',
)
);
......
......@@ -223,3 +223,11 @@ config.tx_extbase.persistence.classes {
}
}
}
plugin {
tx_election {
features {
requireCHashArgumentForActionArguments = 0
}
}
}
Markdown is supported
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