|
|
@ -55,38 +55,34 @@ function AngelType_create($name, $restricted, $description, $requires_driver_lic
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Validates a name for angeltypes.
|
|
|
|
* Validates a name for angeltypes.
|
|
|
|
* Returns array containing validation success and validated name.
|
|
|
|
* Returns ValidationResult containing validation success and validated name.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param string $name
|
|
|
|
* @param AngelType $angeltype
|
|
|
|
* Wanted name for the angeltype
|
|
|
|
|
|
|
|
* @param AngelType $angeltype
|
|
|
|
|
|
|
|
* The angeltype the name is for
|
|
|
|
|
|
|
|
* @return ValidationResult result and validated name
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function AngelType_validate_name($name, $angeltype) {
|
|
|
|
function AngelType_validate_name($name, $angeltype) {
|
|
|
|
$name = strip_item($name);
|
|
|
|
$name = strip_item($name);
|
|
|
|
if ($name == "") {
|
|
|
|
if ($name == "") {
|
|
|
|
return [
|
|
|
|
return new ValidationResult(false, "");
|
|
|
|
false,
|
|
|
|
|
|
|
|
$name
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($angeltype) && isset($angeltype['id'])) {
|
|
|
|
if ($angeltype != null && isset($angeltype['id'])) {
|
|
|
|
return [
|
|
|
|
$valid = sql_num_query("
|
|
|
|
sql_num_query("
|
|
|
|
|
|
|
|
SELECT *
|
|
|
|
SELECT *
|
|
|
|
FROM `AngelTypes`
|
|
|
|
FROM `AngelTypes`
|
|
|
|
WHERE `name`='" . sql_escape($name) . "'
|
|
|
|
WHERE `name`='" . sql_escape($name) . "'
|
|
|
|
AND NOT `id`='" . sql_escape($angeltype['id']) . "'
|
|
|
|
AND NOT `id`='" . sql_escape($angeltype['id']) . "'
|
|
|
|
LIMIT 1") == 0,
|
|
|
|
LIMIT 1") == 0;
|
|
|
|
$name
|
|
|
|
return new ValidationResult($valid, $name);
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
$valid = sql_num_query("
|
|
|
|
sql_num_query("
|
|
|
|
|
|
|
|
SELECT `id`
|
|
|
|
SELECT `id`
|
|
|
|
FROM `AngelTypes`
|
|
|
|
FROM `AngelTypes`
|
|
|
|
WHERE `name`='" . sql_escape($name) . "'
|
|
|
|
WHERE `name`='" . sql_escape($name) . "'
|
|
|
|
LIMIT 1") == 0,
|
|
|
|
LIMIT 1") == 0;
|
|
|
|
$name
|
|
|
|
return new ValidationResult($valid, $name);
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|