- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/uf/controller.php
- Класс: BitrixDiskUfController
- Вызов: Controller::getUserGroupWithStorage
protected function getUserGroupWithStorage()
{
if(!CBXFeatures::isFeatureEnabled('Workgroups'))
{
return array();
}
if(!Loader::includeModule('socialnetwork'))
{
return array();
}
$userId = $this->getUser()->getId();
$currentUserGroups = array();
$cache = Cache::createInstance();
$cacheTtl = defined('BX_COMP_MANAGED_CACHE') ? 3153600 : 3600*4;
$cachePath = "/disk/uf/{$userId}";
if($cache->initCache($cacheTtl, 'group_storage_list_' . SITE_ID . '_' . $userId, $cachePath))
{
[$currentUserGroups] = $cache->getVars();
}
else
{
$cache->startDataCache();
$taggedCache = Application::getInstance()->getTaggedCache();
$taggedCache->startTagCache($cachePath);
$conditionTree = BitrixMainORMQueryQuery::filter();
$conditionTree
->where('STORAGE.ENTITY_TYPE', ProxyTypeGroup::class)
->where('UG.USER_ID', $userId)
->where('UG.GROUP.ACTIVE', 'Y')
->where('UG.GROUP.CLOSED', 'N')
;
$diskSecurityContext = new DiskSecurityContext($userId);
$storages = Storage::getReadableList(
$diskSecurityContext,
array(
'filter' => $conditionTree,
'runtime' => array(
new ReferenceField('UG',
'BitrixSocialnetworkUserToGroupTable',
array('=this.STORAGE.ENTITY_ID' => 'ref.GROUP_ID'),
array('join_type' => 'INNER')
)
),
'extra' => array('UG_GROUP_NAME' => 'UG.GROUP.NAME'),
)
);
foreach($storages as $storage)
{
$currentUserGroups[$storage->getEntityId()] = array(
'STORAGE' => $storage,
'NAME' => $storage->getRootObject()->getExtra()->get('UG_GROUP_NAME'),
);
}
unset($storage);
$taggedCache->registerTag("sonet_user2group_U{$userId}");
$taggedCache->endTagCache();
$cache->endDataCache(array($currentUserGroups));
}
return $currentUserGroups;
}