• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/user.php
  • Класс: BitrixTasksInternalsCounterUser
  • Вызов: User::calcMyNotViewed
private function calcMyNotViewed($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
				LEFT JOIN b_tasks_viewed as tv
					ON tv.TASK_ID = t.ID AND tv.USER_ID = {$this->userId}
			WHERE
				(tv.TASK_ID IS NULL OR tv.TASK_ID = 0) AND
				t.CREATED_BY != {$this->userId} AND 
				t.ZOMBIE = 'N' AND
				".($this->groupId > 0 ? " 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::MY_NOT_VIEWED,
			Application::getConnection()->query($sql)->fetchAll()
		);
	}
}