• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_user.php
  • Класс: CVoxImplantUser
  • Вызов: CVoxImplantUser::SetPhoneActive
public function SetPhoneActive($userId, $active = false)
{
	$userId = intval($userId);
	if(!$userId)
		return false;

	CUserOptions::SetOption('voximplant', 'phone_device_active', ($active? true: false), false, $userId);

	global $USER, $CACHE_MANAGER;
	$USER->Update($userId, Array('UF_VI_PHONE' => $active? 'Y': 'N'));

	if ($active)
	{
		$arUserInfo = $this->GetUserInfo($userId);
		if (!$arUserInfo['phone_enable'])
		{
			$USER->Update($userId, Array('UF_VI_PHONE' => 'N'));
			$CACHE_MANAGER->ClearByTag("USER_NAME_".$userId);
			CUserOptions::SetOption('voximplant', 'phone_device_active', false, false, $userId);
			return false;
		}
	}

	$CACHE_MANAGER->ClearByTag("USER_NAME_".$userId);

	if (CModule::IncludeModule('pull') && CPullOptions::GetQueueServerStatus())
	{
		BitrixPullEvent::add($userId,
			Array(
				'module_id' => 'voximplant',
				'command' => 'phoneDeviceActive',
				'params' => Array('active' => $active? 'Y': 'N')
			)
		);
	}

	return true;
}