Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Notify.php
1<?php
2
4
10
12{
13 public const ALLOWED_SCHEME = ['simple', 'expert'];
14
15 protected function getDefaultPreFilters()
16 {
17 return array_merge(
18 parent::getDefaultPreFilters(),
19 [
21 ]
22 );
23 }
24
25 public function listAction(int $userId)
26 {
27 $userConfiguration = new UserConfiguration($userId);
28
29 return $userConfiguration->getNotifySettings();
30 }
31
32 public function updateAction(int $userId, string $moduleId, string $name, string $type, string $value)
33 {
34 $userConfiguration = new UserConfiguration($userId);
35 $userConfiguration->updateNotifySetting([
36 'name' => $name,
37 'value' => $this->convertCharToBool($value),
38 'moduleId' => $moduleId,
39 'type' => $type
40 ]);
41
42 return true;
43 }
44
48 public function switchSchemeAction(string $scheme, CurrentUser $currentUser, ?int $userId = null): ?array
49 {
50 if (!in_array($scheme, self::ALLOWED_SCHEME, true))
51 {
52 $this->addError(new SettingsError(SettingsError::WRONG_SCHEME));
53
54 return null;
55 }
56
57 $userId ??= (int)$currentUser->getId();
58 $userConfiguration = new UserConfiguration($userId);
59 $userConfiguration->updateGeneralSetting([
60 'name' => \Bitrix\Im\V2\Settings\Entity\General::SCHEME,
61 'value' => $scheme,
62 ]);
63
64 return $userConfiguration->getNotifySettings();
65 }
66}
convertCharToBool(string $char, bool $default=false)
switchSchemeAction(string $scheme, CurrentUser $currentUser, ?int $userId=null)
Definition Notify.php:48
updateAction(int $userId, string $moduleId, string $name, string $type, string $value)
Definition Notify.php:32