1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
processor.php
См. документацию.
1<?php
2
4
7use Bitrix\Main\Entity\ExpressionField;
13use Bitrix\Tasks\Internals\Task\Status;
14
16{
17 protected $component;
18 protected $request;
19
20 protected $filter = [];
21 protected $order = [ 'LOG_DATE' => 'DESC' ];
22 protected $listParams = [];
23 protected $navParams = false;
24 protected $firstPage = false;
25 protected string $context = '';
26 protected int $userId = 0;
27 protected int $groupId = 0;
28
29 public function __construct($params)
30 {
31 $this->init($params);
32 }
33
34 public function setUserId(?int $userId): static
35 {
36 $this->userId = (int)$userId;
37 return $this;
38 }
39
40 public function setGroupId(?int $groupId): static
41 {
42 $this->groupId = (int)$groupId;
43 return $this;
44 }
45
46 protected function getComponent()
47 {
48 return $this->component;
49 }
50
51 public function getRequest()
52 {
53 return $this->request;
54 }
55
56 public function setFilter(array $value = []): void
57 {
58 $this->filter = $value;
59 }
60
61 public function getFilter(): array
62 {
63 return $this->filter;
64 }
65
66 public function setFilterKey($key = '', $value = false): void
67 {
68 if ($key == '')
69 {
70 return;
71 }
72 $this->filter[$key] = $value;
73 }
74
75 public function addFilter($key = '', $value = false): void
76 {
77 if (!isset($this->filter[$key]))
78 {
79 $this->setFilterKey($key, $value);
80 }
81 else
82 {
83 $value = is_array($value) ? $value : [$value];
84 $this->filter[$key] = array_merge($this->filter[$key], $value);
85 }
86 }
87
88 public function unsetFilterKey($key = ''): void
89 {
90 if ($key == '')
91 {
92 return;
93 }
94 unset($this->filter[$key]);
95 }
96
97 public function getFilterKey($key = '')
98 {
99 if ($key == '')
100 {
101 return false;
102 }
103 return ($this->filter[$key] ?? false);
104 }
105
106 public function setOrder(array $value = []): void
107 {
108 $this->order = $value;
109 }
110
111 public function setOrderKey($key = '', $value = false): void
112 {
113 if ($key == '')
114 {
115 return;
116 }
117 $this->order[$key] = $value;
118 }
119
120 public function getOrder(): array
121 {
122 return $this->order;
123 }
124
125 public function getOrderKey($key = '')
126 {
127 if ($key == '')
128 {
129 return false;
130 }
131 return ($this->order[$key] ?? false);
132 }
133
134 public function setListParams(array $value = []): void
135 {
136 $this->listParams = $value;
137 }
138
139 public function setListParamsKey($key = '', $value = false): void
140 {
141 if ($key == '')
142 {
143 return;
144 }
145 $this->listParams[$key] = $value;
146 }
147
148 public function getListParams(): array
149 {
150 return $this->listParams;
151 }
152
153 public function getListParamsKey($key = '')
154 {
155 if ($key == '')
156 {
157 return false;
158 }
159 return ($this->listParams[$key] ?? false);
160 }
161
162 public function setNavParams($value = false): void
163 {
164 $this->navParams = $value;
165 }
166
167 public function getNavParams()
168 {
169 return $this->navParams;
170 }
171
172 public function setFirstPage($value = false): void
173 {
174 $this->firstPage = $value;
175 }
176
177 public function getFirstPage(): bool
178 {
179 return $this->firstPage;
180 }
181
182 public function getUnreadTaskCommentsIdList(&$result): void
183 {
184 $result['UNREAD_COMMENTS_ID_LIST'] = [];
185
186 if ((int) ($result['LOG_COUNTER'] ?? null) <= 0)
187 {
188 return;
189 }
190
191 $tasks2LogList = $this->getComponent()->getTask2LogListValue();
192 if (empty($tasks2LogList))
193 {
194 return;
195 }
196
197 $result['UNREAD_COMMENTS_ID_LIST'] = self::getUnreadCommentsIdList([
198 'userId' => $result['currentUserId'],
199 'logIdList' => array_values($tasks2LogList),
200 ]);
201 }
202
203 protected static function getUnreadCommentsIdList($params): array
204 {
205 $helper = Application::getConnection()->getSqlHelper();
206 $result = [];
207
208 $userId = (int)($params['userId'] ?? 0);
209 $logIdList = (is_set($params['logIdList']) && is_array($params['logIdList']) ? $params['logIdList'] : []);
210
211 if (
212 $userId <= 0
213 || empty($logIdList)
214 )
215 {
216 return $result;
217 }
218
219 foreach($logIdList as $logId)
220 {
221 $result[(int)$logId] = [];
222 }
223
224 $query = UserCounterTable::query();
225 $query->addFilter('=USER_ID', $userId);
226 $query->addFilter('=SITE_ID', SITE_ID);
227
228 $expression = $helper->getConcatFunction(
229 $helper->convertToDbString('**LC'),
230 $helper->convertToDbString('%s')
231 );
232
233 $field = new ExpressionField('COMMENT_CODE', $expression, ['ID']);
234
235 $subQuery =
237 ->whereIn('LOG_ID', $logIdList)
238 ->addSelect($field);
239
240 $query->addFilter('@CODE', new SqlExpression($subQuery->getQuery()));
241 $query->addSelect('CODE');
242 $res = $query->exec();
243
244 $unreadCommentIdList = [];
245
246 while ($counterFields = $res->fetch())
247 {
248 if (preg_match('/\*\*LC(\d+)/i', $counterFields['CODE'], $matches))
249 {
250 $unreadCommentIdList[] = (int)$matches[1];
251 }
252 }
253
254 if (!empty($unreadCommentIdList))
255 {
257 'filter' => [
258 '@ID' => $unreadCommentIdList,
259 ],
260 'select' => [ 'ID', 'LOG_ID' ],
261 ]);
262 while ($logCommentFields = $res->fetch())
263 {
264 $result[(int)$logCommentFields['LOG_ID']][] = (int)$logCommentFields['ID'];
265 }
266 }
267
268 return $result;
269 }
270
271 public function getResultTaskCommentsIdList(&$result): void
272 {
273 $result['RESULT_TASKS_DATA'] = [];
274 $result['RESULT_FIELD_TASKS_ID'] = [];
275 $result['RESULT_COMMENTS_DATA'] = [];
276
277 $tasks2LogList = $this->getComponent()->getTask2LogListValue();
278 if (
279 empty($tasks2LogList)
280 || !Loader::includeModule('tasks')
281 || !class_exists("Bitrix\\Tasks\\Internals\\Task\\Result\\ResultManager")
282 )
283 {
284 return;
285 }
286
287 foreach ($tasks2LogList as $taskId => $logId)
288 {
289 $result['RESULT_TASKS_DATA'][(int)$logId] = (int)$taskId;
290 }
291
292 $taskIdList = [];
293
294 $res = \Bitrix\Tasks\Internals\TaskTable::getList([
295 'filter' => [
296 '@ID' => array_keys($tasks2LogList),
297 '!=STATUS' => Status::COMPLETED,
298 ],
299 'select' => [ 'ID' ],
300 ]);
301 while ($taskFields = $res->fetch())
302 {
303 $taskIdList[] = (int)$taskFields['ID'];
304 }
305
306 if (empty($taskIdList))
307 {
308 return;
309 }
310
311 $result['RESULT_FIELD_TASKS_ID'] = $taskIdList;
312
313 $resultCommentIdList = \Bitrix\Tasks\Internals\Task\Result\ResultManager::findResultComments($taskIdList);
314 foreach ($tasks2LogList as $taskId => $logId)
315 {
316 if (isset($resultCommentIdList[$taskId]))
317 {
318 $res = [];
319 foreach ($resultCommentIdList[$taskId] as $value)
320 {
321 $res[$value] = [
322 'taskId' => $taskId,
323 'logId' => $logId,
324 'commentId' => $value,
325 ];
326 }
327 $result['RESULT_COMMENTS_DATA'][$taskId] = $res;
328 }
329 }
330 }
331
332 public function getMicroblogUserId(&$result): void
333 {
334 $params = $this->getComponent()->arParams;
335
336 $result['MICROBLOG_USER_ID'] = (
337 $result['currentUserId'] > 0
338 && (
339 ($params['ENTITY_TYPE'] ?? null) !== SONET_ENTITY_GROUP
340 || (
341 \CSocNetFeaturesPerms::canPerformOperation($result['currentUserId'], SONET_ENTITY_GROUP, $params['GROUP_ID'], 'blog', 'full_post', $this->getComponent()->getCurrentUserAdmin())
342 || \CSocNetFeaturesPerms::canPerformOperation($result['currentUserId'], SONET_ENTITY_GROUP, $params['GROUP_ID'], 'blog', 'write_post')
343 || \CSocNetFeaturesPerms::canPerformOperation($result['currentUserId'], SONET_ENTITY_GROUP, $params['GROUP_ID'], 'blog', 'moderate_post')
344 || \CSocNetFeaturesPerms::canPerformOperation($result['currentUserId'], SONET_ENTITY_GROUP, $params['GROUP_ID'], 'blog', 'premoderate_post')
345 )
346 )
347 ? $result['currentUserId']
348 : 0
349 );
350 }
351
352 public function setContext(): void
353 {
354 $parameters = $this->getComponent()->arParams;
355 $this->context = $parameters['CONTEXT'] ?? '';
356 }
357
358 public function isSpace(): bool
359 {
360 return mb_strtolower($this->context) === Context::SPACES;
361 }
362
363 private function init(array $params): void
364 {
365 if(!empty($params['component']))
366 {
367 $this->component = $params['component'];
368 }
369
370 if(!empty($params['request']))
371 {
372 $this->request = $params['request'];
373 }
374 else
375 {
376 $this->request = Util::getRequest();
377 }
378 $this->setContext();
379 }
380}
Определения loader.php:13
static getList(array $parameters=array())
Определения datamanager.php:431
setOrderKey($key='', $value=false)
Определения processor.php:111
addFilter($key='', $value=false)
Определения processor.php:75
setListParamsKey($key='', $value=false)
Определения processor.php:139
setFilterKey($key='', $value=false)
Определения processor.php:66
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$query
Определения get_search.php:11
is_set($a, $k=false)
Определения tools.php:2133
if(empty($signedUserToken)) $key
Определения quickway.php:257
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$matches
Определения index.php:22
const SONET_ENTITY_GROUP
Определения include.php:117
const SITE_ID
Определения sonet_set_content_view.php:12