1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
invite.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Internals\Counter\Processor;
4
5use Bitrix\Calendar\Internals\Counter\CounterDictionary;
6use Bitrix\Calendar\Internals\Counter\Event\Event;
7use Bitrix\Calendar\Internals\Counter\Event\EventCollection;
8use Bitrix\Calendar\Internals\Counter\Event\EventDictionary;
9
10class Invite implements Base
11{
12 private const SUPPORTED_EVENTS = [
13 EventDictionary::EVENT_ATTENDEES_UPDATED,
14 EventDictionary::COUNTERS_UPDATE,
15 ];
16
17 public function process(): void
18 {
19 $events = (EventCollection::getInstance())->list();
20 foreach ($events as $event)
21 {
22 /* @var $event Event */
23 $eventType = $event->getType();
24
25 if (in_array($eventType, self::SUPPORTED_EVENTS, true))
26 {
27 $affectedUsers = $event->getData()['user_ids'] ?? [];
28 $this->recountInvites($affectedUsers);
29 }
30 }
31 }
32
33 private function recountInvites(array $users): void
34 {
35 if (empty($users))
36 {
37 return;
38 }
39
40 $counters = [];
41 $events = $this->getEvents($users);
42
43 foreach($events as $event)
44 {
45 $counters[$event['OWNER_ID']] = isset($counters[$event['OWNER_ID']])
46 ? $counters[$event['OWNER_ID']] + 1
47 : 1
48 ;
49 }
50
51 foreach($users as $userId)
52 {
53 if($userId > 0)
54 {
55 $value = (isset($counters[$userId]) && $counters[$userId] > 0)
56 ? (int)$counters[$userId]
57 : 0
58 ;
59
60 \CUserCounter::Set($userId, CounterDictionary::COUNTER_INVITES, $value, '**', '', false);
61 }
62 }
63 }
64
65 private function getEvents(array $userIds): array
66 {
67 $events = \CCalendarEvent::GetList([
68 'arFilter' => [
69 'CAL_TYPE' => 'user',
70 'OWNER_ID' => $userIds,
71 'FROM_LIMIT' => \CCalendar::Date(time(), false),
72 'TO_LIMIT' => \CCalendar::Date(time() + \CCalendar::DAY_LENGTH * 90, false),
73 'IS_MEETING' => 1,
74 'MEETING_STATUS' => 'Q',
75 'DELETED' => 'N',
76 ],
77 'parseRecursion' => false,
78 'checkPermissions' => false
79 ]);
80
81 return $events ?? [];
82 }
83}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$event
Определения prolog_after.php:141
$counters
Определения options.php:100