Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
IBlockElementFilter.php
1<?php
2
4
6
8{
9 public const ALLOWABLE_FIELDS = [
10 'ID',
11 // ACTIVE - Y
12 // 'NAME',
13 'CHECK_PERMISSIONS',
14 // PERMISSIONS_BY
15 'MIN_PERMISSION',
16 'CREATED_BY',
17 'IBLOCK_ID',
18 // SITE_ID,
19 'IBLOCK_TYPE',
20 'SECTION_ID',
21 // SHOW_HISTORY
22 'SHOW_NEW'
23 ];
24
25 public function setField(string $fieldId, $value, string $operator = ''): static
26 {
27 if ($fieldId === 'CHECK_PERMISSIONS')
28 {
29 return $this->setCheckPermission(is_bool($value) ? $value : ($value === 'Y'));
30 }
31
32 return parent::setField($fieldId, $value, $operator);
33 }
34
35 public function setIBlockType(string $iBlockType): static
36 {
37 if (!empty($iBlockType))
38 {
39 $this->setField('IBLOCK_TYPE', $iBlockType, '=');
40 }
41
42 return $this;
43 }
44
45 public function setCreatedBy(int $userId): static
46 {
47 if ($userId >= 0)
48 {
49 $this->setField('CREATED_BY', (string)$userId, '=');
50 }
51
52 return $this;
53 }
54
55 public function setCheckPermission(bool $value): static
56 {
57 $this->filter['CHECK_PERMISSIONS'] = $value ? 'Y': 'N';
58 $this->keyMatching['CHECK_PERMISSIONS'] = 'CHECK_PERMISSIONS';
59
60 return $this;
61 }
62
63 public function setId(int $id): static
64 {
65 if ($id >= 0)
66 {
67 $this->setField('ID', $id, '=');
68 }
69
70 return $this;
71 }
72
73 public function setIBlockId(int $iBlockId): static
74 {
75 if ($iBlockId > 0)
76 {
77 $this->setField('IBLOCK_ID', $iBlockId, '=');
78 }
79
80 return $this;
81 }
82
83 public function setShowNew(bool $flag): static
84 {
85 $this->setField('SHOW_NEW', $flag ? 'Y' : 'N');
86
87 return $this;
88 }
89
90 public function setMinPermission(string $permission): static
91 {
92 if (in_array($permission, ['E', 'S', 'T', 'R', 'U', 'W', 'X'], true))
93 {
94 $this->setField('MIN_PERMISSION', $permission);
95 }
96
97 return $this;
98 }
99}
setField(string $fieldId, $value, string $operator='')