• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/user.php
  • Класс: BitrixTasksInternalsCounterUser
  • Вызов: User::calcOpened
private function calcOpened($reCache = false)
{
	static $count = null;

	if ($count == null || $reCache)
	{
		$statusSupposedlyCompleted = CTasks::STATE_SUPPOSEDLY_COMPLETED;
		$statusCompleted = CTasks::STATE_COMPLETED;
		$statusDeferred = CTasks::STATE_DEFERRED;

		$sql = "
			SELECT 
				COUNT(t.ID) as COUNT,
				t.GROUP_ID
			FROM 
				b_tasks AS t
				JOIN b_tasks_member as tm ON 
					tm.TASK_ID = t.ID AND 
					tm.USER_ID = {$this->userId} AND
					tm.TYPE IN('A', 'R') 
			WHERE
				t.CREATED_BY != {$this->userId}
				AND t.ZOMBIE = 'N'
				".($this->groupId > 0 ? " AND t.GROUP_ID = {$this->groupId}" : "")."
				AND (
					t.STATUS != {$statusSupposedlyCompleted}
					AND t.STATUS != {$statusCompleted}
					AND	t.STATUS != {$statusDeferred}
				)
			GROUP BY 
				t.GROUP_ID
		";

		$this->changeCounter(
			CounterName::OPENED,
			Application::getConnection()->query($sql)->fetchAll()
		);
	}
}