|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Application\Acl; |
|
6
|
|
|
|
|
7
|
|
|
use Application\Acl\Assertion\BookableAvailable; |
|
8
|
|
|
use Application\Acl\Assertion\BookableIsAdminApproved; |
|
9
|
|
|
use Application\Acl\Assertion\BookingIsPendingApplication; |
|
10
|
|
|
use Application\Acl\Assertion\BookingIsSelfApproved; |
|
11
|
|
|
use Application\Acl\Assertion\ExpenseClaimStatusIsNew; |
|
12
|
|
|
use Application\Acl\Assertion\IsFamily; |
|
13
|
|
|
use Application\Acl\Assertion\StatusIsNew; |
|
14
|
|
|
use Application\Model\Account; |
|
15
|
|
|
use Application\Model\AccountingDocument; |
|
16
|
|
|
use Application\Model\Bookable; |
|
17
|
|
|
use Application\Model\BookableMetadata; |
|
18
|
|
|
use Application\Model\BookableTag; |
|
19
|
|
|
use Application\Model\Booking; |
|
20
|
|
|
use Application\Model\Configuration; |
|
21
|
|
|
use Application\Model\Country; |
|
22
|
|
|
use Application\Model\ExpenseClaim; |
|
23
|
|
|
use Application\Model\Image; |
|
24
|
|
|
use Application\Model\License; |
|
25
|
|
|
use Application\Model\Message; |
|
26
|
|
|
use Application\Model\Transaction; |
|
27
|
|
|
use Application\Model\TransactionTag; |
|
28
|
|
|
use Application\Model\User; |
|
29
|
|
|
use Application\Model\UserTag; |
|
30
|
|
|
use Ecodev\Felix\Acl\Assertion\All; |
|
31
|
|
|
use Ecodev\Felix\Acl\Assertion\IsMyself; |
|
32
|
|
|
use Ecodev\Felix\Acl\Assertion\IsOwner; |
|
33
|
|
|
use Ecodev\Felix\Acl\Assertion\One; |
|
34
|
|
|
|
|
35
|
|
|
class Acl extends \Ecodev\Felix\Acl\Acl |
|
36
|
|
|
{ |
|
37
|
33 |
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
// Each role is NOT strictly "stronger" than the last one |
|
40
|
33 |
|
$this->addRole(User::ROLE_ANONYMOUS); |
|
41
|
33 |
|
$this->addRole(User::ROLE_BOOKING_ONLY, User::ROLE_ANONYMOUS); |
|
42
|
33 |
|
$this->addRole(User::ROLE_ACCOUNTING_VERIFICATOR, User::ROLE_BOOKING_ONLY); |
|
43
|
33 |
|
$this->addRole(User::ROLE_INDIVIDUAL, User::ROLE_BOOKING_ONLY); |
|
44
|
33 |
|
$this->addRole(User::ROLE_MEMBER, User::ROLE_INDIVIDUAL); |
|
45
|
33 |
|
$this->addRole(User::ROLE_TRAINER, User::ROLE_MEMBER); |
|
46
|
33 |
|
$this->addRole(User::ROLE_FORMATION_RESPONSIBLE, User::ROLE_TRAINER); |
|
47
|
33 |
|
$this->addRole(User::ROLE_RESPONSIBLE, User::ROLE_FORMATION_RESPONSIBLE); |
|
48
|
33 |
|
$this->addRole(User::ROLE_ADMINISTRATOR, User::ROLE_RESPONSIBLE); |
|
49
|
|
|
|
|
50
|
33 |
|
$bookable = $this->createModelResource(Bookable::class); |
|
51
|
33 |
|
$bookableMetadata = $this->createModelResource(BookableMetadata::class); |
|
52
|
33 |
|
$bookableTag = $this->createModelResource(BookableTag::class); |
|
53
|
33 |
|
$booking = $this->createModelResource(Booking::class); |
|
54
|
33 |
|
$image = $this->createModelResource(Image::class); |
|
55
|
33 |
|
$license = $this->createModelResource(License::class); |
|
56
|
33 |
|
$user = $this->createModelResource(User::class); |
|
57
|
33 |
|
$userTag = $this->createModelResource(UserTag::class); |
|
58
|
33 |
|
$country = $this->createModelResource(Country::class); |
|
59
|
33 |
|
$account = $this->createModelResource(Account::class); |
|
60
|
33 |
|
$accountingDocument = $this->createModelResource(AccountingDocument::class); |
|
61
|
33 |
|
$transactionTag = $this->createModelResource(TransactionTag::class); |
|
62
|
33 |
|
$expenseClaim = $this->createModelResource(ExpenseClaim::class); |
|
63
|
33 |
|
$message = $this->createModelResource(Message::class); |
|
64
|
33 |
|
$transaction = $this->createModelResource(Transaction::class); |
|
65
|
33 |
|
$configuration = $this->createModelResource(Configuration::class); |
|
66
|
|
|
|
|
67
|
33 |
|
$this->allow(User::ROLE_ANONYMOUS, [$country, $bookable, $bookableMetadata, $bookableTag, $image, $license, $transactionTag, $configuration], ['read']); |
|
68
|
33 |
|
$this->allow(User::ROLE_BOOKING_ONLY, [$booking], ['create'], new BookableAvailable()); |
|
69
|
33 |
|
$this->allow(User::ROLE_BOOKING_ONLY, [$booking], ['read']); |
|
70
|
33 |
|
$this->allow(User::ROLE_BOOKING_ONLY, [$booking], ['update'], new One(new BookingIsSelfApproved(), new isOwner())); |
|
71
|
33 |
|
$this->allow(User::ROLE_BOOKING_ONLY, [$booking], ['delete'], new All(new isOwner(), new BookingIsPendingApplication())); |
|
72
|
|
|
|
|
73
|
33 |
|
$this->allow(User::ROLE_ACCOUNTING_VERIFICATOR, [$user, $account, $transaction, $transactionTag, $accountingDocument], ['read']); |
|
74
|
|
|
|
|
75
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$user], ['read']); |
|
76
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$user], ['update'], new IsMyself()); |
|
77
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$expenseClaim], ['create']); |
|
78
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$expenseClaim], ['read']); |
|
79
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$expenseClaim], ['update', 'delete'], new All(new IsFamily(), new StatusIsNew())); |
|
80
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$accountingDocument], ['create'], new ExpenseClaimStatusIsNew()); |
|
81
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$accountingDocument], ['read']); |
|
82
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$accountingDocument], ['update', 'delete'], new All(new IsFamily(), new ExpenseClaimStatusIsNew())); |
|
83
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$account], ['read']); |
|
84
|
33 |
|
$this->allow(User::ROLE_INDIVIDUAL, [$message], ['read']); |
|
85
|
|
|
|
|
86
|
33 |
|
$this->allow(User::ROLE_MEMBER, [$account], ['update']); |
|
87
|
33 |
|
$this->allow(User::ROLE_MEMBER, [$user], ['create']); |
|
88
|
33 |
|
$this->allow(User::ROLE_MEMBER, [$user], ['update'], new One(new IsOwner(), new IsMyself())); |
|
89
|
|
|
|
|
90
|
33 |
|
$this->allow(User::ROLE_TRAINER, [$userTag], ['read']); |
|
91
|
33 |
|
$this->allow(User::ROLE_TRAINER, [$bookable], ['update'], new BookableIsAdminApproved()); |
|
92
|
|
|
|
|
93
|
33 |
|
$this->allow(User::ROLE_FORMATION_RESPONSIBLE, [$user, $userTag], ['update']); |
|
94
|
33 |
|
$this->allow(User::ROLE_FORMATION_RESPONSIBLE, [$booking], ['create', 'update']); |
|
95
|
|
|
|
|
96
|
33 |
|
$this->allow(User::ROLE_RESPONSIBLE, [$transaction, $account, $transactionTag], ['read']); |
|
97
|
33 |
|
$this->allow(User::ROLE_RESPONSIBLE, [$expenseClaim, $accountingDocument], ['read', 'update']); |
|
98
|
33 |
|
$this->allow(User::ROLE_RESPONSIBLE, [$bookableMetadata, $bookableTag, $image, $license, $userTag], ['create', 'update', 'delete']); |
|
99
|
33 |
|
$this->allow(User::ROLE_RESPONSIBLE, [$bookable], ['create', 'update']); |
|
100
|
33 |
|
$this->allow(User::ROLE_RESPONSIBLE, [$booking], ['update', 'delete']); |
|
101
|
|
|
|
|
102
|
33 |
|
$this->allow(User::ROLE_ADMINISTRATOR, [$bookable, $transaction, $account, $transactionTag, $accountingDocument, $expenseClaim], ['create', 'update', 'delete']); |
|
103
|
33 |
|
$this->allow(User::ROLE_ADMINISTRATOR, [$configuration], ['create']); |
|
104
|
33 |
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|