• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/util/userfield/restriction.php
  • Класс: BitrixTasksUtilUserFieldRestriction
  • Вызов: Restriction::hadUserFieldsBefore
static function hadUserFieldsBefore($entityCode, $forceUpdate)
{
	$optionName = 'have_uf_' . ToLower($entityCode);
	$optionValue = Util::getOption($optionName);

	if ($optionValue === '' || $forceUpdate) // not checked before, check then
	{
		$userFieldsExists = static::checkUserFieldsExists($entityCode);

		if ($userFieldsExists)
		{
			$possibleEntityCodes = [
				'TASKS_TASK' => true,
				'TASKS_TASK_TEMPLATE' => true
			];
			unset($possibleEntityCodes[$entityCode]);

			$anotherOptionName = 'have_uf_' . ToLower(key($possibleEntityCodes));
			$anotherUserFieldExists = static::checkUserFieldsExists(key($possibleEntityCodes));

			Util::setOption($anotherOptionName, ($anotherUserFieldExists? '1' : '0'));
		}

		Util::setOption($optionName, ($userFieldsExists? '1' : '0'));

		return $userFieldsExists;
	}
	else
	{
		return $optionValue == '1';
	}
}