Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
CheckChatManageUpdate.php
1<?php
2
4
11
13{
14 public function onBeforeAction(Event $event)
15 {
16 $arguments = $this->getAction()->getArguments();
17 $arguments['rightsLevel'] = (new Converter(Converter::TO_UPPER))->process($arguments['rightsLevel'] ?? '');
18 $this->getAction()->setArguments($arguments);
19 $rightsLevel = $arguments['rightsLevel'];
20 $actionName = $this->getAction()->getName();
21 if ($this->inArrayCaseInsensitive($actionName, ['setManageUsersAdd', 'setManageUsersDelete', 'setManageUI'], true))
22 {
23 if (in_array(
24 $rightsLevel,
26 true
27 ))
28 {
29 return null;
30 }
31 }
32
33 if ($actionName === 'setManageSettings' || $actionName === 'setmanagesettings')
34 {
35 if (in_array(
36 $rightsLevel,
38 true
39 ))
40 {
41 return null;
42 }
43 }
44
45 $this->addError(new ChatError(
47 ));
48 return new EventResult(EventResult::ERROR, null, null, $this);
49 }
50
57 private function inArrayCaseInsensitive(string $needle, array $haystack, bool $strict = true): bool
58 {
59 $needle = mb_strtolower($needle);
60 $haystack = array_map('mb_strtolower', $haystack);
61
62 return in_array($needle, $haystack, $strict);
63 }
64}
const MANAGE_RIGHTS_MEMBER
Definition Chat.php:133
const MANAGE_RIGHTS_MANAGERS
Definition Chat.php:135
const MANAGE_RIGHTS_OWNER
Definition Chat.php:134