1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AddUsersConfig.php
См. документацию.
1<?php
2
4
5final class AddUsersConfig
6{
7 public readonly array $managerIds;
8 public readonly ?bool $hideHistory;
9 public readonly bool $withMessage;
10 public readonly bool $skipRecent;
11 public readonly bool $isFakeAdd;
12 public readonly Reason $reason;
13 public readonly array $hiddenUserIds;
14
15 public function __construct(
16 array $managerIds = [],
17 ?bool $hideHistory = null,
18 bool $withMessage = true,
19 bool $skipRecent = false,
20 bool $isFakeAdd = false,
21 Reason $reason = Reason::DEFAULT,
23 )
24 {
25 $this->managerIds = $this->normalizeIds($managerIds);
26 $this->hideHistory = $hideHistory;
27 $this->withMessage = $withMessage;
28 $this->skipRecent = $skipRecent;
29 $this->isFakeAdd = $isFakeAdd;
30 $this->reason = $reason;
31 $this->hiddenUserIds = $this->normalizeIds($hiddenUserIds);
32 }
33
34 public function isManager(int $userId): bool
35 {
36 return isset($this->managerIds[$userId]);
37 }
38
39 public function setManagerIds(array $managerIds): self
40 {
41 return $this->with(['managerIds' => $managerIds]);
42 }
43
44 public function setHideHistory(?bool $hideHistory): self
45 {
46 return $this->with(['hideHistory' => $hideHistory]);
47 }
48
49 public function isHidden(int $userId): bool
50 {
51 return isset($this->hiddenUserIds[$userId]);
52 }
53
54 private function normalizeIds(array $ids): array
55 {
56 $intIds = array_map('intval', $ids);
57
58 return array_combine($intIds, $intIds);
59 }
60
61 private function with(array $changes): self
62 {
63 $newFields = array_merge($this->toArray(), $changes);
64
65 return new self(...$newFields);
66 }
67
68 private function toArray(): array
69 {
70 $array = [];
71 foreach ($this as $fieldName => $field)
72 {
73 $array[$fieldName] = $field;
74 }
75
76 return $array;
77 }
78}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
readonly bool $withMessage
Определения AddUsersConfig.php:9
readonly array $hiddenUserIds
Определения AddUsersConfig.php:13
__construct(array $managerIds=[], ?bool $hideHistory=null, bool $withMessage=true, bool $skipRecent=false, bool $isFakeAdd=false, Reason $reason=Reason::DEFAULT, array $hiddenUserIds=[],)
Определения AddUsersConfig.php:15
setManagerIds(array $managerIds)
Определения AddUsersConfig.php:39
readonly bool $skipRecent
Определения AddUsersConfig.php:10
isHidden(int $userId)
Определения AddUsersConfig.php:49
readonly bool $isFakeAdd
Определения AddUsersConfig.php:11
readonly bool $hideHistory
Определения AddUsersConfig.php:8
readonly array $managerIds
Определения AddUsersConfig.php:7
readonly Reason $reason
Определения AddUsersConfig.php:12
isManager(int $userId)
Определения AddUsersConfig.php:34
setHideHistory(?bool $hideHistory)
Определения AddUsersConfig.php:44
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804