m170525_092723_create_crud_permission.php 2.82 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
<?php
/**
 * Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
 * OPEN 2.0
 *
 *
waltermazza's avatar
waltermazza committed
7
 * @package    arter\amos\report\migrations
Marcello Pivanti's avatar
Marcello Pivanti committed
8
9
10
11
 * @category   CategoryName
 * @author     Elite Division S.r.l.
 */

waltermazza's avatar
waltermazza committed
12
use arter\amos\core\migration\AmosMigrationPermissions;
Marcello Pivanti's avatar
Marcello Pivanti committed
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use yii\helpers\ArrayHelper;
use yii\rbac\Permission;

/**
 * Class m170524_102950_init_comments_permissions
 */
class m170525_092723_create_crud_permission extends AmosMigrationPermissions
{
    /**
     * @inheritdoc
     */
    protected function setRBACConfigurations()
    {
        return ArrayHelper::merge(
            $this->setPluginRoles(),
            $this->setModelPermissions()
        );
    }

    private function setPluginRoles()
    {
        return [
            [
                'name' => 'REPORT_ADMINISTRATOR',
                'type' => Permission::TYPE_ROLE,
                'description' => 'Administrator role for report plugin',
                'ruleName' => null,
                'parent' => ['ADMIN']
            ],
            [
                'name' => 'REPORT_MODERATOR',
                'type' => Permission::TYPE_ROLE,
                'description' => 'REPORT mode role for report plugin',
                'ruleName' => null,
                'parent' => ['REPORT_ADMINISTRATOR']
            ],
            [
                'name' => 'REPORT_CONTRIBUTOR',
                'type' => Permission::TYPE_ROLE,
                'description' => 'Reports validator role for report plugin',
                'ruleName' => null,
                'parent' => ['REPORT_ADMINISTRATOR']
            ],
        ];
    }

    private function setModelPermissions()
    {
        return [

            // Permissions for model Report
            [
                'name' => 'REPORT_CREATE',
                'type' => Permission::TYPE_PERMISSION,
                'description' => 'Create permission for model Report',
                'parent' => ['REPORT_ADMINISTRATOR', 'REPORT_CONTRIBUTOR']
            ],
            [
                'name' => 'REPORT_READ',
                'type' => Permission::TYPE_PERMISSION,
                'description' => 'Read permission for model Report',
                'parent' => ['REPORT_ADMINISTRATOR', 'REPORT_CONTRIBUTOR', 'REPORT_MODERATOR']
            ],
            [
                'name' => 'REPORT_UPDATE',
                'type' => Permission::TYPE_PERMISSION,
                'description' => 'Update permission for model Report',
                'parent' => ['REPORT_ADMINISTRATOR', 'REPORT_CONTRIBUTOR', 'REPORT_MODERATOR']
            ],
            [
                'name' => 'REPORT_DELETE',
                'type' => Permission::TYPE_PERMISSION,
                'description' => 'Delete permission for model Report',
                'parent' => ['REPORT_ADMINISTRATOR', 'REPORT_CONTRIBUTOR', 'REPORT_MODERATOR']
            ]
        ];
    }
}