• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/ui/destination.php
  • Класс: BitrixDiskUiDestination
  • Вызов: Destination::getRightsDestination
static function getRightsDestination($userId, $selected = array())
{
	if(!Loader::includeModule('socialnetwork'))
	{
		return array();
	}

	global $CACHE_MANAGER;

	if (!is_array($selected))
	{
		$selected = array();
	}

	if (method_exists('CSocNetLogDestination','getDestinationSort'))
	{
		$destination = array(
			'LAST' => array()
		);

		$lastDestination = CSocNetLogDestination::getDestinationSort(array(
			"DEST_CONTEXT" => "DISK_SHARE"
		));

		CSocNetLogDestination::fillLastDestination($lastDestination, $destination['LAST']);
	}
	else
	{
		$destination = array(
			'LAST' => array(
				'SONETGROUPS' => CSocNetLogDestination::getLastSocnetGroup(),
				'DEPARTMENT' => CSocNetLogDestination::getLastDepartment(),
				'USERS' => CSocNetLogDestination::getLastUser()
			)
		);
	}
	
	$cacheTtl = defined("BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
	$cacheId = 'dest_group_'.$userId;
	$cacheDir = '/disk/dest_rights/'.$userId;

	$cache = new CPHPCache;
	if($cache->initCache($cacheTtl, $cacheId, $cacheDir))
	{
		$destination['SONETGROUPS'] = $cache->getVars();
	}
	else
	{
		$cache->startDataCache();
		$destination['SONETGROUPS'] = CSocNetLogDestination::getSocnetGroup(array('features' => array("blog", array("premoderate_post", "moderate_post", "write_post", "full_post"))));
		if(defined("BX_COMP_MANAGED_CACHE"))
		{
			$CACHE_MANAGER->startTagCache($cacheDir);
			foreach($destination['SONETGROUPS'] as $val)
			{
				$CACHE_MANAGER->registerTag("sonet_features_G_".$val["entityId"]);
				$CACHE_MANAGER->registerTag("sonet_group_".$val["entityId"]);
			}
			$CACHE_MANAGER->registerTag("sonet_user2group_U".$userId);
			$CACHE_MANAGER->endTagCache();
		}
		$cache->endDataCache($destination['SONETGROUPS']);
	}

	$destUser = array();
	$destination['SELECTED'] = array();
	foreach ($selected as $ind => $code)
	{
		if (mb_substr($code, 0, 2) == 'DR')
		{
			$destination['SELECTED'][$code] = "department";
		}
		elseif (mb_substr($code, 0, 2) == 'UA')
		{
			$destination['SELECTED'][$code] = "groups";
		}
		elseif (mb_substr($code, 0, 2) == 'AU')
		{
			$destination['SELECTED'][$code] = "groups";
			$destination['SELECTED']['UA'] = "groups";
		}
		elseif (mb_substr($code, 0, 2) == 'SG')
		{
			$destination['SELECTED'][$code] = "sonetgroups";
		}
		elseif (mb_substr($code, 0, 1) == 'U')
		{
			$destination['SELECTED'][$code] = "users";
			$destUser[] = str_replace('U', '', $code);
		}
	}

	// intranet structure
	$structure = CSocNetLogDestination::getStucture();
	//$arStructure = CSocNetLogDestination::GetStucture(array("LAZY_LOAD" => true));
	$destination['DEPARTMENT'] = $structure['department'];
	$destination['DEPARTMENT_RELATION'] = $structure['department_relation'];
	$destination['DEPARTMENT_RELATION_HEAD'] = $structure['department_relation_head'];

	if (Loader::includeModule('extranet') && !CExtranet::isIntranetUser())
	{
		$destination['EXTRANET_USER'] = 'Y';
		$destination['USERS'] = CSocNetLogDestination::getExtranetUser();
	}
	else
	{
		foreach ($destination['LAST']['USERS'] as $value)
			$destUser[] = str_replace('U', '', $value);

		$destination['EXTRANET_USER'] = 'N';
		$destination['USERS'] = CSocNetLogDestination::getUsers(array('id' => $destUser));
	}

	return $destination;
}