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
de837511
Commit
de837511
authored
Dec 24, 2015
by
Oliver Eglseder
Browse files
[WIP][TASK] begin voting
parent
b6345dbd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/FeElectionController.php
View file @
de837511
...
...
@@ -17,6 +17,7 @@ namespace TYPO3\Election\Controller;
use
TYPO3\CMS\Core\Messaging\AbstractMessage
;
use
TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
use
TYPO3\CMS\Extbase\Utility\LocalizationUtility
;
use
TYPO3\Election\Domain\Model\Dto\ElectionVoting
;
use
TYPO3\Election\Domain\Model\ElectionInvitation
;
/**
...
...
@@ -26,6 +27,7 @@ class FeElectionController extends ActionController
{
const
CONTROLLER_NAME
=
'FeElection'
;
const
ACTION_VOTE
=
'vote'
;
const
ACTION_SUBMIT_VOTE
=
'submitVote'
;
/**
* @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService
...
...
@@ -60,6 +62,7 @@ class FeElectionController extends ActionController
$saltedEmail
=
$electionInvitation
->
getSecret
()
.
$electionInvitation
->
getElector
()
->
getEmail
();
if
(
$this
->
hashService
->
validateHmac
(
$saltedEmail
,
$hmac
))
{
$this
->
view
->
assign
(
'electionInvitation'
,
$electionInvitation
);
$this
->
view
->
assign
(
'electionVoting'
,
new
ElectionVoting
());
}
else
{
$this
->
addFlashMessage
(
LocalizationUtility
::
translate
(
'controller.fe.election.vote.hmac_invalid'
,
'election'
),
...
...
@@ -78,12 +81,21 @@ class FeElectionController extends ActionController
}
}
/**
* @param ElectionVoting $electionVoting
*/
public
function
submitVoteAction
(
ElectionVoting
$electionVoting
)
{
\
TYPO3\CMS\Extbase\Utility\DebuggerUtility
::
var_dump
(
$electionVoting
,
__CLASS__
.
'@'
.
__LINE__
,
20
);
die
;
}
/**
* @return string
*/
public
static
function
getActionsForPluginConfiguration
()
{
return
implode
(
','
,
[
self
::
ACTION_VOTE
]);
return
implode
(
','
,
[
self
::
ACTION_VOTE
,
self
::
ACTION_SUBMIT_VOTE
]);
}
/**
...
...
Classes/Domain/Model/Dto/ElectionVoting.php
0 → 100644
View file @
de837511
<?php
namespace
TYPO3\Election\Domain\Model\Dto
;
/**
* Class ElectionVoting
*/
class
ElectionVoting
{
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\Election\Domain\Model\Nominee>
*/
protected
$nominees
=
null
;
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public
function
getNominees
()
{
return
$this
->
nominees
;
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $nominees
*/
public
function
setNominees
(
$nominees
)
{
$this
->
nominees
=
$nominees
;
}
}
Resources/Private/Language/locallang.xlf
View file @
de837511
...
...
@@ -385,7 +385,7 @@
<source>
Election
</source>
</trans-unit>
<!-- FE ELECTION -->
<!-- FE ELECTION
CONTROLLER
-->
<trans-unit
id=
"controller.fe.election.vote.hmac_invalid"
>
<source>
HMAC invalid. You are not allowed to request this page.
</source>
...
...
@@ -397,6 +397,21 @@
<source>
The link you clicked is not valid anymore.
</source>
</trans-unit>
<!-- FE ELECTION -->
<trans-unit
id=
"view.fe.election.vote.election"
>
<source>
Election
</source>
</trans-unit>
<trans-unit
id=
"view.fe.election.vote.nominees"
>
<source>
Nominees
</source>
</trans-unit>
<trans-unit
id=
"view.fe.election.vote.votes"
>
<source>
You can vote for up to %d nominees in this election. You can only vote once, remaining votes will be discarded.
</source>
</trans-unit>
<trans-unit
id=
"view.fe.election.vote.vote"
>
<source>
Vote
</source>
</trans-unit>
</body>
</file>
</xliff>
Resources/Private/Partials/Model/Nominee/VoteList.html
View file @
de837511
...
...
@@ -10,36 +10,31 @@
<f:translate
key=
"model.abstract_person.field.full_name"
>
Name
</f:translate>
</th>
<th>
<f:translate
key=
"model.abstract_person.field.
email"
>
Email
</f:translate>
<f:translate
key=
"model.abstract_person.field.
url"
>
URL
</f:translate>
</th>
<th>
<f:translate
key=
"view.
b
e.
anything.options
"
>
Vote
</f:translate>
<f:translate
key=
"view.
f
e.
election.vote.vote
"
>
Vote
</f:translate>
</th>
</tr>
</thead>
<tbody>
<f:for
each=
"{nominees}"
as=
"nominee"
>
<
tr
>
<t
d
>
<
f:image
image=
"{nominee.image}"
width=
"50c"
height=
"50c"
/
>
</td
>
<
td>
<
f:link.action
action=
"edit"
controller=
"BeNominee"
arguments=
"{nominee:nominee}"
>
<
f:if
condition=
"{nominee.public}"
>
<t
r
>
<
td
>
<f:image
image=
"{nominee.image}"
width=
"50c"
height=
"50c"
/
>
</
td>
<
td
>
{nominee.fullName}
</f:link.action>
</td>
<td>
{nominee.email}
</td>
<td>
<div
class=
"btn-group"
>
<f:link.action
class=
"btn btn-default"
action=
"edit"
controller=
"BeNominee"
arguments=
"{nominee:nominee}"
>
<core:icon
identifier=
"actions-edit-rename"
/>
</f:link.action>
</div>
</td>
</tr>
</td>
<td>
<f:link.page
pageUid=
"{nominee.url}"
>
{nominee.url}
</f:link.page>
</td>
<td>
<f:form.checkbox
property=
"nominees.{nominee.uid}"
value=
"{nominee.uid}"
/>
</td>
</tr>
</f:if>
</f:for>
</tbody>
</table>
Resources/Private/Templates/FeElection/Vote.html
View file @
de837511
<f:layout
name=
"Frontend"
/>
<f:section
name=
"Main"
>
<f:debug>
{_all}
</f:debug>
<h2>
Election: {electionInvitation.electionCircular.election.title}
</h2>
<h3>
Nominees
</h3>
<f:render
partial=
"Model/Nominee/VoteList"
arguments=
"{nominees:electionInvitation.electionCircular.election.nominees}"
/>
<h2>
<f:translate
key=
"view.fe.election.vote.election"
>
Election
</f:translate>
: {electionInvitation.electionCircular.election.title}
</h2>
<h3>
<f:translate
key=
"view.fe.election.vote.nominees"
>
Nominees
</f:translate>
</h3>
<p>
<f:translate
key=
"view.fe.election.vote.votes"
arguments=
"{0:electionInvitation.electionCircular.election.numberOfVotes}"
>
You can vote up to
{electionInvitation.electionCircular.election.numberOfVotes} nominees
</f:translate>
</p>
<f:form
action=
"submitVote"
object=
"{electionVoting}"
objectName=
"electionVoting"
>
<f:render
partial=
"Model/Nominee/VoteList"
arguments=
"{nominees:electionInvitation.electionCircular.election.nominees}"
/>
<f:form.submit
value=
"vote"
/>
</f:form>
</f:section>
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