• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/Configuration/General.php
  • Класс: BitrixImConfigurationGeneral
  • Вызов: General::checkingValues
static function checkingValues(array $settings): array
{
	$verifiedSettings = [];

	$defaultSettings = self::getDefaultSettings();
	foreach($settings as $name => $value)
	{
		if (!array_key_exists($name , $defaultSettings))
		{
			continue;
		}

		switch ($name)
		{
			case 'status':
				$verifiedSettings[$name] =
					in_array($value, ['online', 'dnd', 'away'])
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'panelPositionHorizontal':
				$verifiedSettings[$name] =
					in_array($value, ['left', 'center', 'right'])
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'panelPositionVertical':
				$verifiedSettings[$name] =
					in_array($value, ['top', 'bottom'])
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'notifyScheme':
				$verifiedSettings[$name] =
					in_array($value, ['simple', 'expert'])
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'enableDarkTheme':
				$verifiedSettings[$name] =
					in_array($value, ['auto', 'light', 'dark'])
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'privacyMessage':
			case 'privacyChat':
			case 'privacyCall':
			case 'privacySearch':
				$verifiedSettings[$name] =
					in_array($value, [self::PRIVACY_RESULT_ALL, self::PRIVACY_RESULT_CONTACT], true)
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'privacyProfile':
				$verifiedSettings[$name] =
					in_array(
						$value,
						[
							self::PRIVACY_RESULT_ALL,
							self::PRIVACY_RESULT_CONTACT,
							self::PRIVACY_RESULT_NOBODY
						],
						true
					)
						? $value
						: $defaultSettings[$name];

				break;
			case 'backgroundImage':
				$verifiedSettings[$name] = $value;

				break;
			case 'notifySchemeLevel':
				$verifiedSettings[$name] =
					in_array($value, ['normal', 'important'])
						? $value
						: $defaultSettings[$name];

				break;
			case 'trackStatus':
				$status = explode(',', $value);
				foreach ($status as $key => $val)
				{
					if ($val !== 'all')
					{
						$status[$key] = (int)$val;
						if ($status[$key] === 0)
						{
							unset($status[$key]);
						}
					}
				}
				$verifiedSettings[$name] = implode(',', $status);

				break;
			case 'callAcceptIncomingVideo':
				$verifiedSettings[$name] =
					in_array($value, VideoStrategyType::getList())
						? $value
						: $defaultSettings[$name]
				;

				break;
			case 'sendByEnter': // for legacy
				if ($value === 'Y' || $value === true)
				{
					$verifiedSettings[$name] = true;

					break;
				}
				//'break' is missing  specially
			case 'enableSound': // for legacy
				if ($value === 'N' || $value === false)
				{
					$verifiedSettings[$name] = false;

					break;
				}
			case 'backgroundImageId':
				$verifiedSettings[$name] = (int)$value > 0 ? (int)$value : 1;
				break;
				//'break' is missing  specially
			case 'chatAlignment':
				$verifiedSettings[$name] =
					in_array($value, ['left', 'center'])
						? $value
						: $defaultSettings[$name]
				;
				break;
			default:
				if (array_key_exists($name, $defaultSettings))
				{
					$verifiedSettings[$name] = is_bool($value) ? $value : $defaultSettings[$name];
				}

				break;
		}
	}

	return $verifiedSettings;
}