/
board.php
42 lines (36 loc) · 1.26 KB
/
board.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Concrete\Controller\Permissions\Categories\TaskHandlers;
use Concrete\Core\Entity\Board\Board as BoardEntity;
use Concrete\Core\Error\UserMessageException;
use Concrete\Core\Permission\Category\ObjectTaskHandler;
use Concrete\Core\Permission\Checker;
use Concrete\Core\Permission\ObjectInterface;
use Doctrine\ORM\EntityManagerInterface;
defined('C5_EXECUTE') or die('Access Denied.');
class Board extends ObjectTaskHandler
{
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Permission\Category\ObjectTaskHandler::$hasWorkflows
*/
protected $hasWorkflows = true;
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Permission\Category\ObjectTaskHandler::getPermissionObject()
*/
protected function getPermissionObject(array $options): ObjectInterface
{
$boardID = $options['boardID'] ?? null;
$board = $boardID ? $this->app->make(EntityManagerInterface::class)->find(BoardEntity::class, $boardID) : null;
if ($board === null) {
throw new UserMessageException(t('Board not received'));
}
$cp = new Checker($board);
if (!$cp->canEditBoardPermissions()) {
throw new UserMessageException(t('Access Denied.'));
}
return $board;
}
}