- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
- Класс: CCalendar
- Вызов: CCalendar::GetSocNetDestination
static function GetSocNetDestination($user_id = false, $selected = [], $userList = [])
{
if (!Loader::includeModule("socialnetwork"))
{
return false;
}
global $CACHE_MANAGER;
if (!is_array($selected))
{
$selected = [];
}
if (method_exists('CSocNetLogDestination','GetDestinationSort'))
{
$DESTINATION = array(
'LAST' => [],
'DEST_SORT' => CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => BitrixCalendarUtil::getUserSelectorContext())),
);
CSocNetLogDestination::fillLastDestination($DESTINATION['DEST_SORT'], $DESTINATION['LAST']);
}
else
{
$DESTINATION = array(
'LAST' => array(
'SONETGROUPS' => CSocNetLogDestination::GetLastSocnetGroup(),
'DEPARTMENT' => CSocNetLogDestination::GetLastDepartment(),
'USERS' => CSocNetLogDestination::GetLastUser(),
),
);
}
if (!$user_id)
{
$user_id = self::GetCurUserId();
}
$cacheTtl = defined("BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
$cacheId = 'calendar_dest_'.$user_id;
$cacheDir = '/calendar/socnet_destination/'.SITE_ID.'/'.$user_id;
$obCache = new CPHPCache;
if($obCache->InitCache($cacheTtl, $cacheId, $cacheDir))
{
$DESTINATION['SONETGROUPS'] = $obCache->GetVars();
}
else
{
$obCache->StartDataCache();
$DESTINATION['SONETGROUPS'] = CSocNetLogDestination::GetSocnetGroup(Array('features' => array("calendar", array("view"))));
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".$user_id);
$CACHE_MANAGER->EndTagCache();
}
$obCache->EndDataCache($DESTINATION['SONETGROUPS']);
}
$destinationUserList = [];
$DESTINATION['SELECTED'] = [];
if (!empty($userList))
{
foreach ($userList as $userId)
{
$DESTINATION['SELECTED']['U'.$userId] = "users";
$DESTINATION['LAST']['USERS']['U'.$userId] = 'U'.$userId;
}
}
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) === 'SG')
{
$DESTINATION['SELECTED'][$code] = "sonetgroups";
}
elseif (mb_substr($code, 0, 1) === 'U')
{
$DESTINATION['SELECTED'][$code] = "users";
$destinationUserList[] = (int)str_replace('U', '', $code);
}
}
// intranet structure
$arStructure = CSocNetLogDestination::GetStucture();
$DESTINATION['DEPARTMENT'] = $arStructure['department'];
$DESTINATION['DEPARTMENT_RELATION'] = $arStructure['department_relation'];
$DESTINATION['DEPARTMENT_RELATION_HEAD'] = $arStructure['department_relation_head'];
if (Loader::includeModule('extranet') && !CExtranet::IsIntranetUser(SITE_ID, $user_id))
{
$DESTINATION['EXTRANET_USER'] = 'Y';
$DESTINATION['USERS'] = CSocNetLogDestination::GetExtranetUser();
$DESTINATION['USERS'] = array_merge($DESTINATION['USERS'], CSocNetLogDestination::GetUsers(['id' => [$user_id]]));
}
else
{
if (is_array($DESTINATION['LAST']['USERS']))
{
foreach ($DESTINATION['LAST']['USERS'] as $value)
{
$destinationUserList[] = (int)str_replace('U', '', $value);
}
}
if (!empty($userList))
{
$destinationUserList = array_unique(array_merge($destinationUserList, $userList));
}
$DESTINATION['EXTRANET_USER'] = 'N';
$DESTINATION['USERS'] = CSocNetLogDestination::GetUsers(Array('id' => $destinationUserList));
}
$users = [];
foreach ($DESTINATION['USERS'] as $key => $entry)
{
if ($entry['isExtranet'] === 'N')
{
$users[$key] = $entry;
}
}
$DESTINATION['USERS'] = $users;
return $DESTINATION;
}