CCrmInstantEditorHelper::PrepareUserInfo

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmInstantEditorHelper
  4. PrepareUserInfo
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
  • Класс: \CCrmInstantEditorHelper
  • Вызов: CCrmInstantEditorHelper::PrepareUserInfo
static function PrepareUserInfo($userID, &$userInfo, $options = array())
{
	$userID = intval($userID);
	if($userID <= 0)
	{
		return false;
	}

	// Check if extranet user request intranet user info
	if(IsModuleInstalled('extranet')
		&& CModule::IncludeModule('extranet')
		&& $userID != CCrmSecurityHelper::GetCurrentUserID()
		&& !CExtranet::IsProfileViewableByID($userID))
	{
		return false;
	}

	$dbUser = CUser::GetList(
		'ID',
		'ASC',
		array('ID' => $userID)
	);

	$arUser = $dbUser->Fetch();
	if(!is_array($arUser))
	{
		return false;
	}

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

	$photoW = isset($options['PHOTO_WIDTH']) ? intval($options['PHOTO_WIDTH']) : 0;
	$photoH = isset($options['PHOTO_HEIGHT']) ? intval($options['PHOTO_HEIGHT']) : 0;

	$photoInfo = CFile::ResizeImageGet(
		$arUser['PERSONAL_PHOTO'],
		array(
			'width' => $photoW > 0 ? $photoW : 100,
			'height'=> $photoH > 0 ? $photoH : 100
		),
		BX_RESIZE_IMAGE_EXACT
	);

	$nameTemplate = isset($options['NAME_TEMPLATE']) ? $options['NAME_TEMPLATE'] : '';

	$userInfo['ID'] = $userID;
	$userInfo['FULL_NAME'] = CUser::FormatName(
		$nameTemplate !== '' ? $nameTemplate : CSite::GetNameFormat(false),
		$arUser,
		true,
		false
	);

	$urlTemplate = isset($options['USER_PROFILE_URL_TEMPLATE']) ? $options['USER_PROFILE_URL_TEMPLATE'] : '';
	$userInfo['USER_PROFILE'] = $urlTemplate !== ''
		? CComponentEngine::MakePathFromTemplate(
			$urlTemplate,
			array('user_id' => $userID)
		)
		: '';

	$userInfo['WORK_POSITION'] = isset($arUser['WORK_POSITION']) ? $arUser['WORK_POSITION'] : '';
	$userInfo['PERSONAL_PHOTO'] = isset($photoInfo['src']) ? $photoInfo['src'] : '';

	return true;
}

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