PollPermission
t3oodle has got a central class controlling poll permission logic.
Existing permissions are:
isViewing In General Allowed ($poll) isViewing Allowed ($poll) isShow Allowed ($poll) isNew Allowed () isNew Simple Poll Allowed () isNew Schedule Poll Allowed () isEdit Allowed ($poll) isDelete Allowed ($poll) isPublish Allowed ($poll) isFinish Allowed ($poll) isFinish Suggestion Mode Allowed ($poll) isSuggest New Options Allowed ($poll) isVoting Allowed ($poll) isSee Participants During Voting Allowed ($poll) isSee Votes During Voting Allowed ($poll) isAdministration Allowed ($poll) isReset Votes Allowed ($poll) is!!!Delete Own Vote Allowed ($vote)
They are used in controller actions, as well as in Fluid templates.
Permission ViewHelper
<f:if condition="{t3oodle:permission(action:'newSimplePoll')}">
// show new button
</f:if>
The action is passed without trailing is and Allowed.
When a permission requires poll or vote argument, you can call it like this:
<f:if condition="{poll -> t3oodle:permission(action:'delete')}">
// show delete button, for this poll
</f:if>
Modifying permissions
Permissions can get changed programmatically by using PSR-14 events.
For most permissions an own event exists (see Permission events). The event carries the current status, which
you can overwrite with set.
For example, to modify the permission to create a new poll, listen to New:
<?php
declare(strict_types=1);
namespace Vendor\MyExt\EventListener;
use FGTCLB\T3oodle\Event\Permission\NewPollAllowedEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
final class NewPollPermissionListener
{
#[AsEventListener(identifier: 'my-ext/new-poll-permission')]
public function __invoke(NewPollAllowedEvent $event): void
{
if (!$event->isAllowed()) {
return;
}
// TODO: implement your own logic
$event->setAllowed(false);
}
}
Note
Not every permission method of Poll dispatches an event. Have a look in
Classes/ for the available events.