- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/counterstate.php
- Класс: BitrixTasksInternalsCounterCounterState
- Вызов: CounterState::updateRawCounters
private function updateRawCounters(): void
{
$this->counters = [
CounterDictionary::META_PROP_ALL => [],
CounterDictionary::META_PROP_PROJECT => [],
CounterDictionary::META_PROP_GROUP => [],
CounterDictionary::META_PROP_SONET => [],
CounterDictionary::META_PROP_SCRUM => [],
CounterDictionary::META_PROP_NONE => [],
];
$user = UserRegistry::getInstance($this->userId);
$groups = $user->getUserGroups(UserRegistry::MODE_GROUP);
$projects = $user->getUserGroups(UserRegistry::MODE_PROJECT);
$scrum = $user->getUserGroups(UserRegistry::MODE_SCRUM);
$tmpHeap[] = [];
foreach ($this->state as $item)
{
if (
$item['TYPE'] === CounterDictionary::COUNTER_FLAG_COUNTED
|| $item['TYPE'] === CounterDictionary::COUNTER_FLAG_CLEARED
)
{
continue;
}
$taskId = $item['TASK_ID'];
$groupId = $item['GROUP_ID'];
$value = $item['VALUE'];
$type = $item['TYPE'];
$meta = $this->getMetaProp($item, $groups, $projects, $scrum);
$subType = $this->getItemSubType($type);
if (!isset($this->counters[$meta][$type][$groupId]))
{
$this->counters[$meta][$type][$groupId] = 0;
}
if (!isset($this->counters[$meta][$subType][$groupId]))
{
$this->counters[$meta][$subType][$groupId] = 0;
}
if (!isset($tmpHeap[$meta][$subType][$groupId]))
{
$tmpHeap[$meta][$subType][$groupId] = [];
}
if (!isset($this->counters[CounterDictionary::META_PROP_SONET][$type][$groupId]))
{
$this->counters[CounterDictionary::META_PROP_SONET][$type][$groupId] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_SONET][$subType][$groupId]))
{
$this->counters[CounterDictionary::META_PROP_SONET][$subType][$groupId] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_ALL][$type][$groupId]))
{
$this->counters[CounterDictionary::META_PROP_ALL][$type][$groupId] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_ALL][$subType][$groupId]))
{
$this->counters[CounterDictionary::META_PROP_ALL][$subType][$groupId] = 0;
}
if (!isset($tmpHeap[$meta][$type][$groupId][$taskId]))
{
$tmpHeap[$meta][$type][$groupId][$taskId] = $value;
$this->counters[$meta][$type][$groupId] += $value;
if (in_array($meta, [CounterDictionary::META_PROP_GROUP, CounterDictionary::META_PROP_PROJECT]))
{
$this->counters[CounterDictionary::META_PROP_SONET][$type][$groupId] += $value;
}
}
if (
$type !== $subType
&& !isset($tmpHeap[$meta][$subType][$groupId][$taskId])
)
{
$tmpHeap[$meta][$subType][$groupId][$taskId] = $value;
$this->counters[$meta][$subType][$groupId] += $value;
if (in_array($meta, [CounterDictionary::META_PROP_GROUP, CounterDictionary::META_PROP_PROJECT]))
{
$this->counters[CounterDictionary::META_PROP_SONET][$subType][$groupId] += $value;
}
}
if (!isset($tmpHeap[CounterDictionary::META_PROP_ALL][$type][$groupId][$taskId]))
{
$tmpHeap[CounterDictionary::META_PROP_ALL][$type][$groupId][$taskId] = $value;
$this->counters[CounterDictionary::META_PROP_ALL][$type][$groupId] += $value;
}
if (
$type !== $subType
&& !isset($tmpHeap[CounterDictionary::META_PROP_ALL][$subType][$groupId][$taskId])
)
{
$tmpHeap[CounterDictionary::META_PROP_ALL][$subType][$groupId][$taskId] = $value;
$this->counters[CounterDictionary::META_PROP_ALL][$subType][$groupId] += $value;
}
if ($meta === CounterDictionary::META_PROP_NONE)
{
continue;
}
// Total sum for the all groups/projects
if (!isset($this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0]))
{
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0]))
{
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0]))
{
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] = 0;
}
if (!isset($this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0]))
{
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] = 0;
}
if (!isset($this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0]))
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] = 0;
}
if (!isset($this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0]))
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] = 0;
}
if (!isset($this->counters[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0]))
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0] = 0;
}
if (
$subType === CounterDictionary::COUNTER_EXPIRED
&& !isset($tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0][$taskId])
)
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0] += $value;
if (in_array($meta, [CounterDictionary::META_PROP_PROJECT, CounterDictionary::META_PROP_GROUP]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0] += $value;
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0] += $value;
}
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] -= $value;
if (in_array($meta, [CounterDictionary::META_PROP_PROJECT, CounterDictionary::META_PROP_GROUP]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] -= $value;
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] -= $value;
}
$tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_EXPIRED][0][$taskId] = $value;
}
if (
$subType === CounterDictionary::COUNTER_NEW_COMMENTS
&& !isset($tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0][$taskId])
)
{
if (!isset($this->counters[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0]))
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0] = 0;
}
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0] += $value;
if (in_array($meta, [CounterDictionary::META_PROP_PROJECT, CounterDictionary::META_PROP_GROUP]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0] += $value;
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0] += $value;
}
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] -= $value;
if (in_array($meta, [CounterDictionary::META_PROP_PROJECT, CounterDictionary::META_PROP_GROUP]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] -= $value;
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] -= $value;
}
$tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_TOTAL_COMMENTS][0][$taskId] = $value;
}
if (
in_array($subType, [CounterDictionary::COUNTER_GROUP_EXPIRED, CounterDictionary::COUNTER_MUTED_EXPIRED])
&& !isset($tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0][$taskId])
)
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] += $value;
if (in_array($meta, [CounterDictionary::META_PROP_PROJECT, CounterDictionary::META_PROP_GROUP]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] += $value;
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0] += $value;
}
$tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_EXPIRED][0][$taskId] = $value;
}
if (
in_array($subType, [CounterDictionary::COUNTER_GROUP_COMMENTS, CounterDictionary::COUNTER_MUTED_NEW_COMMENTS])
&& !isset($tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0][$taskId])
)
{
$this->counters[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] += $value;
if (in_array($meta, [CounterDictionary::META_PROP_PROJECT, CounterDictionary::META_PROP_GROUP]))
{
$this->counters[CounterDictionary::META_PROP_ALL][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] += $value;
$this->counters[CounterDictionary::META_PROP_SONET][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0] += $value;
}
$tmpHeap[$meta][CounterDictionary::COUNTER_GROUPS_FOREIGN_COMMENTS][0][$taskId] = $value;
}
}
unset($tmpHeap);
}