- Updated the form handling to use form_set_error(). All core modules have

been updated (almost none have error checking for forms) except the node
  forms ...
4.5.x
Dries Buytaert 2004-05-31 11:51:21 +00:00
parent 7f08110a5e
commit 45fdcf8af8
2 changed files with 18 additions and 18 deletions

View File

@ -272,23 +272,22 @@ function path_save($edit) {
$pid = $edit['pid'];
if (!valid_url($src)) {
$error = t('the normal path "%src" is invalid.', array('%src' => $src));
form_set_error('src', t('the normal path "%src" is invalid.', array('%src' => $src)));
}
if (db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE pid != %d AND src = '%s'", $pid, $src))) {
$error = t('the normal path "%src" is already aliased.', array('%src' => $src));
form_set_error('src', t('the normal path "%src" is already aliased.', array('%src' => $src)));
}
if (!valid_url($dst)) {
$error = t('the alias "%dst" is invalid.', array('%dst' => $dst));
form_set_error('dst', t('the alias "%dst" is invalid.', array('%dst' => $dst)));
}
if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s'", $pid, $dst))) {
$error = t('the alias "%dst" is already in use.', array('%dst' => $dst));
form_set_error('dst', t('the alias "%dst" is already in use.', array('%dst' => $dst)));
}
if ($error) {
drupal_set_message($error, 'error');
if (form_has_errors()) {
return path_form($edit, $error);
}
else {
@ -302,10 +301,11 @@ function path_save($edit) {
else {
path_set_alias($src, $dst);
}
}
drupal_set_message(t('the alias has been saved.'));
return path_overview();
drupal_set_message(t('the alias has been saved.'));
return path_overview();
}
}
?>

View File

@ -272,23 +272,22 @@ function path_save($edit) {
$pid = $edit['pid'];
if (!valid_url($src)) {
$error = t('the normal path "%src" is invalid.', array('%src' => $src));
form_set_error('src', t('the normal path "%src" is invalid.', array('%src' => $src)));
}
if (db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE pid != %d AND src = '%s'", $pid, $src))) {
$error = t('the normal path "%src" is already aliased.', array('%src' => $src));
form_set_error('src', t('the normal path "%src" is already aliased.', array('%src' => $src)));
}
if (!valid_url($dst)) {
$error = t('the alias "%dst" is invalid.', array('%dst' => $dst));
form_set_error('dst', t('the alias "%dst" is invalid.', array('%dst' => $dst)));
}
if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s'", $pid, $dst))) {
$error = t('the alias "%dst" is already in use.', array('%dst' => $dst));
form_set_error('dst', t('the alias "%dst" is already in use.', array('%dst' => $dst)));
}
if ($error) {
drupal_set_message($error, 'error');
if (form_has_errors()) {
return path_form($edit, $error);
}
else {
@ -302,10 +301,11 @@ function path_save($edit) {
else {
path_set_alias($src, $dst);
}
}
drupal_set_message(t('the alias has been saved.'));
return path_overview();
drupal_set_message(t('the alias has been saved.'));
return path_overview();
}
}
?>