Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
roleutil.php
1<?php
10
16
17Loc::loadMessages(__FILE__);
18
20{
21
22 protected static function getRoleTableClass(): string
23 {
24 return RoleTable::class;
25 }
26
27 protected static function getRoleRelationTableClass(): string
28 {
29 return RoleRelationTable::class;
30 }
31
32 protected static function getPermissionTableClass(): string
33 {
34 return PermissionTable::class;
35 }
36
37 protected static function getRoleDictionaryClass(): ?string
38 {
39 return RoleDictionary::class;
40 }
41
46 public static function preparedRoleMap()
47 {
48 return [
49 'ADMIN' => [
50 PermissionDictionary::MAILING_VIEW,
51 PermissionDictionary::MAILING_PAUSE_START_STOP,
52 PermissionDictionary::MAILING_MESSENGER_EDIT,
53 PermissionDictionary::MAILING_EMAIL_EDIT,
54 PermissionDictionary::MAILING_CLIENT_VIEW,
55 PermissionDictionary::MAILING_AUDIO_CALL_EDIT,
56 PermissionDictionary::MAILING_INFO_CALL_EDIT,
57 PermissionDictionary::MAILING_SMS_EDIT,
58 PermissionDictionary::ADS_VIEW,
59 PermissionDictionary::ADS_PAUSE_START_STOP,
60 PermissionDictionary::ADS_YANDEX_EDIT,
61 PermissionDictionary::ADS_FB_INSTAGRAM_EDIT,
62 PermissionDictionary::ADS_MARKETING_INSTAGRAM_EDIT,
63 PermissionDictionary::ADS_MARKETING_FB_EDIT,
64 PermissionDictionary::ADS_GOOGLE_EDIT_MSGVER_1,
65 PermissionDictionary::ADS_LOOK_ALIKE_FB_EDIT,
66 PermissionDictionary::ADS_LOOK_ALIKE_VK_EDIT,
67 PermissionDictionary::ADS_MASTER_YANDEX_EDIT,
68 PermissionDictionary::ADS_VK_EDIT,
69 PermissionDictionary::ADS_CLIENT_VIEW,
70 PermissionDictionary::RC_EDIT,
71 PermissionDictionary::RC_VIEW,
72 PermissionDictionary::RC_PAUSE_START_STOP,
73 PermissionDictionary::SEGMENT_CLIENT_OWN_CATEGORY,
74 PermissionDictionary::SEGMENT_EDIT,
75 PermissionDictionary::SEGMENT_VIEW,
76 PermissionDictionary::SEGMENT_LEAD_EDIT,
77 PermissionDictionary::SEGMENT_CLIENT_EDIT,
78 PermissionDictionary::SEGMENT_CLIENT_PERSONAL_EDIT,
79 PermissionDictionary::SEGMENT_CLIENT_VIEW,
80 PermissionDictionary::SETTINGS_EDIT,
81// PermissionDictionary::SETTINGS_VIEW,
82 PermissionDictionary::BLACKLIST_EDIT,
83 PermissionDictionary::BLACKLIST_VIEW,
84 PermissionDictionary::START_VIEW,
85 PermissionDictionary::TEMPLATE_EDIT,
86 PermissionDictionary::TEMPLATE_VIEW,
87 ],
88 'CHIEF' => [
89 PermissionDictionary::MAILING_VIEW,
90 PermissionDictionary::MAILING_PAUSE_START_STOP,
91 PermissionDictionary::MAILING_MESSENGER_EDIT,
92 PermissionDictionary::MAILING_EMAIL_EDIT,
93 PermissionDictionary::MAILING_CLIENT_VIEW,
94 PermissionDictionary::MAILING_AUDIO_CALL_EDIT,
95 PermissionDictionary::MAILING_INFO_CALL_EDIT,
96 PermissionDictionary::MAILING_SMS_EDIT,
97 PermissionDictionary::ADS_VIEW,
98 PermissionDictionary::ADS_PAUSE_START_STOP,
99 PermissionDictionary::ADS_YANDEX_EDIT,
100 PermissionDictionary::ADS_FB_INSTAGRAM_EDIT,
101 PermissionDictionary::ADS_MARKETING_INSTAGRAM_EDIT,
102 PermissionDictionary::ADS_MARKETING_FB_EDIT,
103 PermissionDictionary::ADS_GOOGLE_EDIT_MSGVER_1,
104 PermissionDictionary::ADS_LOOK_ALIKE_FB_EDIT,
105 PermissionDictionary::ADS_LOOK_ALIKE_VK_EDIT,
106 PermissionDictionary::ADS_MASTER_YANDEX_EDIT,
107 PermissionDictionary::ADS_VK_EDIT,
108 PermissionDictionary::ADS_CLIENT_VIEW,
109 PermissionDictionary::RC_EDIT,
110 PermissionDictionary::RC_PAUSE_START_STOP,
111 PermissionDictionary::RC_VIEW,
112 PermissionDictionary::SEGMENT_CLIENT_OWN_CATEGORY,
113 PermissionDictionary::SEGMENT_EDIT,
114 PermissionDictionary::SEGMENT_VIEW,
115 PermissionDictionary::SEGMENT_LEAD_EDIT,
116 PermissionDictionary::SEGMENT_CLIENT_EDIT,
117 PermissionDictionary::SEGMENT_CLIENT_PERSONAL_EDIT,
118 PermissionDictionary::START_VIEW,
119 PermissionDictionary::SEGMENT_CLIENT_VIEW
120 ],
121 'MANAGER' => [
122 PermissionDictionary::MAILING_VIEW,
123 PermissionDictionary::MAILING_PAUSE_START_STOP,
124 PermissionDictionary::MAILING_MESSENGER_EDIT,
125 PermissionDictionary::MAILING_EMAIL_EDIT,
126 PermissionDictionary::MAILING_AUDIO_CALL_EDIT,
127 PermissionDictionary::MAILING_INFO_CALL_EDIT,
128 PermissionDictionary::MAILING_SMS_EDIT,
129 PermissionDictionary::ADS_VIEW,
130 PermissionDictionary::ADS_PAUSE_START_STOP,
131 PermissionDictionary::ADS_YANDEX_EDIT,
132 PermissionDictionary::ADS_FB_INSTAGRAM_EDIT,
133 PermissionDictionary::ADS_MARKETING_INSTAGRAM_EDIT,
134 PermissionDictionary::ADS_MARKETING_FB_EDIT,
135 PermissionDictionary::ADS_GOOGLE_EDIT_MSGVER_1,
136 PermissionDictionary::ADS_LOOK_ALIKE_FB_EDIT,
137 PermissionDictionary::ADS_LOOK_ALIKE_VK_EDIT,
138 PermissionDictionary::ADS_MASTER_YANDEX_EDIT,
139 PermissionDictionary::ADS_VK_EDIT,
140 PermissionDictionary::RC_EDIT,
141 PermissionDictionary::RC_PAUSE_START_STOP,
142 PermissionDictionary::RC_VIEW,
143 PermissionDictionary::SEGMENT_CLIENT_OWN_CATEGORY,
144 PermissionDictionary::SEGMENT_EDIT,
145 PermissionDictionary::SEGMENT_VIEW,
146 PermissionDictionary::SEGMENT_LEAD_EDIT,
147 PermissionDictionary::SEGMENT_CLIENT_EDIT,
148 PermissionDictionary::START_VIEW,
149 PermissionDictionary::SEGMENT_CLIENT_PERSONAL_EDIT
150 ]
151 ];
152 }
153
161 public static function buildInsertPermissionQuery(array $permissions, int $roleId): array
162 {
163 $query = [];
164
165 foreach ($permissions as $permission)
166 {
167 $query[] = [
168 'ROLE_ID' => $roleId,
169 'PERMISSION_ID' => $permission,
170 'VALUE' => PermissionDictionary::VALUE_YES,
171 ];
172 }
173
174 return $query;
175 }
176
183 public static function insertPermissions(array $valuesData)
184 {
185 $connection = \Bitrix\Main\Application::getConnection();
186 $helper = $connection->getSqlHelper();
187 foreach ($helper->prepareMergeMultiple('b_sender_permission', ['ROLE_ID', 'PERMISSION_ID'], $valuesData) as $sql)
188 {
189 $connection->query($sql);
190 }
191 }
192
198 public static function getLocalizedName(string $key)
199 {
200 return Loc::getMessage('SENDER_ROLE_' . $key);
201 }
202}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getLocalizedName(string $key)
Definition roleutil.php:198
static buildInsertPermissionQuery(array $permissions, int $roleId)
Definition roleutil.php:161
static insertPermissions(array $valuesData)
Definition roleutil.php:183