UserRegistry::loadGroupInfo

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. UserRegistry
  4. loadGroupInfo
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/registry/userregistry.php
  • Класс: BitrixTasksInternalsRegistryUserRegistry
  • Вызов: UserRegistry::loadGroupInfo
private function loadGroupInfo(): void
{
	if (!Loader::includeModule('socialnetwork'))
	{
		return;
	}

	$cache = Cache::createInstance();

	if ($cache->initCache(self::CACHE_TTL, $this->getCacheId(), $this->getCacheDir()))
	{
		$res = $cache->getVars();
	}
	else
	{
		$res = UserToGroupTable::query()
			->addSelect('GROUP_ID')
			->addSelect('ROLE')
			->addSelect('WORKGROUP.PROJECT', 'PROJECT')
			->addSelect('WORKGROUP.SCRUM_MASTER_ID', 'SCRUM_MASTER')
			->registerRuntimeField(
				new Reference(
					'WORKGROUP',
					WorkgroupTable::class,
					Join::on('this.GROUP_ID', 'ref.ID'),
					['join_type' => 'LEFT']
				)
			)
			->setFilter([
				'=USER_ID' => $this->userId,
				'@ROLE' => [UserToGroupTable::ROLE_OWNER, UserToGroupTable::ROLE_MODERATOR, UserToGroupTable::ROLE_USER]
			])
			->fetchAll();

		$taggedCache = Application::getInstance()->getTaggedCache();
		$taggedCache->StartTagCache($this->getCacheDir());
		$taggedCache->RegisterTag($this->getCacheTag());

		$cache->startDataCache();
		$cache->endDataCache($res);
		$taggedCache->EndTagCache();
	}

	foreach ($res as $row)
	{
		$this->userGroups[$row['GROUP_ID']] = $row['ROLE'];
		if ((int)$row['SCRUM_MASTER'] > 0)
		{
			$this->userScrum[$row['GROUP_ID']] = $row['ROLE'];
		}
		elseif ($row['PROJECT'] === 'Y')
		{
			$this->userProjects[$row['GROUP_ID']] = $row['ROLE'];
		}
		else
		{
			$this->userWorkgroups[$row['GROUP_ID']] = $row['ROLE'];
		}
	}
}

Добавить комментарий