• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/checklist/internals/checklistfields.php
  • Класс: BitrixTasksCheckListInternalsCheckListFields
  • Вызов: CheckListFields::getSetCheckFunctions
private function getSetCheckFunctions()
{
	$checkInt = static function($value)
	{
		return (in_array($value, ['null', null], true)? null : (int)$value);
	};

	$checkString = static function($value)
	{
		if (is_string($value) && trim($value) !== '')
		{
			return trim($value);
		}

		return null;
	};

	$checkTitle = static function($value)
	{
		if (is_string($value) && trim($value) !== '')
		{
			return trim($value);
		}

		return null;
	};

	$checkBoolean = static function($value)
	{
		return in_array($value, ['Y', 'true', true, 1], true);
	};

	$checkMembers = static function($value)
	{
		$result = $value;

		if (!is_array($result) && !$result)
		{
			$result = [];
		}

		if (is_array($result))
		{
			foreach ($result as $id => $data)
			{
				$type = static::getCorrectType($data['TYPE']);

				if ($type)
				{
					$data['TYPE'] = $type;
					$result[$id] = $data;
				}
				else
				{
					return null;
				}
			}

			return $result;
		}

		return null;
	};

	$checkAttachments = static function($value)
	{
		$result = $value;

		if (is_array($result))
		{
			foreach ($result as $id => $fileId)
			{
				if (is_array($fileId) && isset($fileId['FILE_ID']))
				{
					$fileId = $fileId['FILE_ID'];
				}

				$fileId = (string)($fileId[0] === 'n' ? $fileId : 'n'.$fileId);
				$result[$id] = $fileId;

				if (!preg_match('/(^nd+$)/', $fileId))
				{
					unset($result[$id]);
				}
			}

			return $result;
		}

		return null;
	};

	return [
		'INT' => $checkInt,
		'STRING' => $checkString,
		'BOOLEAN' => $checkBoolean,
		'TITLE' => $checkTitle,
		'MEMBERS' => $checkMembers,
		'ATTACHMENTS' => $checkAttachments,
	];
}