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>
Copied!
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>
Copied!
Modifying permissions
Every permission can get changed programmatically, by using Signal/Slots.
First register your slot in ext_:
/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$signalSlotDispatcher->connect(
\FGTCLB\T3oodle\Domain\Permission\PollPermission::class,
'isNewSimplePollAllowed',
\Vendor\MyExt\Slots\PollPermissionSlots::class,
'isNewSimplePollAllowed'
);
Copied!
The Poll class looks like this:
final class PollPermissionSlots
{
public function isNewSimplePollAllowed(bool $currentStatus, array $arguments, PollPermission $caller): array
{
$newStatus = false; // TODO: implement me
return [
'currentStatus' => $newStatus,
'arguments' => $arguments,
'caller' => $caller,
];
}
}
Copied!