- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/push/pushsender.php
- Класс: BitrixTasksInternalsCounterPushPushSender
- Вызов: PushSender::sendUserCounters
public function sendUserCounters(array $userIds): void
{
if (!ModuleManager::isModuleInstalled('pull') || !Loader::includeModule('pull'))
{
return;
}
foreach ($userIds as $userId)
{
$pushData = [];
$pushData['userId'] = $userId;
$counter = Counter::getInstance($userId);
$counters = $counter->getRawCounters();
$pushData[CounterDictionary::COUNTER_TOTAL] = $counter->get(CounterDictionary::COUNTER_TOTAL);
$pushData[CounterDictionary::COUNTER_PROJECTS_MAJOR] =
$counter->get(CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS)
+ $counter->get(CounterDictionary::COUNTER_PROJECTS_TOTAL_COMMENTS)
+ $counter->get(CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED)
+ $counter->get(CounterDictionary::COUNTER_PROJECTS_TOTAL_EXPIRED);
$pushData[CounterDictionary::COUNTER_SCRUM_TOTAL_COMMENTS] = $counter->get(CounterDictionary::COUNTER_SCRUM_TOTAL_COMMENTS);
/**
* for menu's counters group 0 is a total counters (tasks with any groups or without groups)
*/
$groupIds = [0];
foreach ($counters as $data)
{
$groupIds = array_merge($groupIds, array_keys($data));
}
$groupIds = array_unique($groupIds);
foreach ($groupIds as $groupId)
{
$pushData[$groupId][Role::ALL][CounterDictionary::COUNTER_TOTAL] = $counter->get(CounterDictionary::COUNTER_MEMBER_TOTAL, $groupId);
$pushData[$groupId][Role::ALL][CounterDictionary::COUNTER_EXPIRED] = $counter->get(CounterDictionary::COUNTER_EXPIRED, $groupId);
$pushData[$groupId][Role::ALL][CounterDictionary::COUNTER_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::ALL][CounterDictionary::COUNTER_MUTED_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_MUTED_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::RESPONSIBLE][CounterDictionary::COUNTER_TOTAL] = $counter->get(CounterDictionary::COUNTER_MY, $groupId);
$pushData[$groupId][Role::RESPONSIBLE][CounterDictionary::COUNTER_EXPIRED] = $counter->get(CounterDictionary::COUNTER_MY_EXPIRED, $groupId);
$pushData[$groupId][Role::RESPONSIBLE][CounterDictionary::COUNTER_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_MY_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::RESPONSIBLE][CounterDictionary::COUNTER_MUTED_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_MY_MUTED_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::ORIGINATOR][CounterDictionary::COUNTER_TOTAL] = $counter->get(CounterDictionary::COUNTER_ORIGINATOR, $groupId);
$pushData[$groupId][Role::ORIGINATOR][CounterDictionary::COUNTER_EXPIRED] = $counter->get(CounterDictionary::COUNTER_ORIGINATOR_EXPIRED, $groupId);
$pushData[$groupId][Role::ORIGINATOR][CounterDictionary::COUNTER_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_ORIGINATOR_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::ORIGINATOR][CounterDictionary::COUNTER_MUTED_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_ORIGINATOR_MUTED_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::ACCOMPLICE][CounterDictionary::COUNTER_TOTAL] = $counter->get(CounterDictionary::COUNTER_ACCOMPLICES, $groupId);
$pushData[$groupId][Role::ACCOMPLICE][CounterDictionary::COUNTER_EXPIRED] = $counter->get(CounterDictionary::COUNTER_ACCOMPLICES_EXPIRED, $groupId);
$pushData[$groupId][Role::ACCOMPLICE][CounterDictionary::COUNTER_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_ACCOMPLICES_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::ACCOMPLICE][CounterDictionary::COUNTER_MUTED_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_ACCOMPLICES_MUTED_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::AUDITOR][CounterDictionary::COUNTER_TOTAL] = $counter->get(CounterDictionary::COUNTER_AUDITOR, $groupId);
$pushData[$groupId][Role::AUDITOR][CounterDictionary::COUNTER_EXPIRED] = $counter->get(CounterDictionary::COUNTER_AUDITOR_EXPIRED, $groupId);
$pushData[$groupId][Role::AUDITOR][CounterDictionary::COUNTER_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_AUDITOR_NEW_COMMENTS, $groupId);
$pushData[$groupId][Role::AUDITOR][CounterDictionary::COUNTER_MUTED_NEW_COMMENTS] = $counter->get(CounterDictionary::COUNTER_AUDITOR_MUTED_NEW_COMMENTS, $groupId);
}
$this->createPush([$userId], self::COMMAND_USER, $pushData);
}
}