From cbf48c1d9be8dec41e9910fabe6fc18554dfaa86 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sun, 20 Aug 2006 07:00:14 +0000
Subject: [PATCH] - Patch #79559 by asimmonds: move path_form to FormAPI
 validate/submit model.

---
 modules/path/path.module | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/modules/path/path.module b/modules/path/path.module
index 5809c981d73e..23457f9402d5 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -184,6 +184,7 @@ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) {
  * Return a form for editing or creating an individual URL alias.
  */
 function path_form($edit = '') {
+  $form['#base'] = 'path_form';
 
   $form['src'] = array('#type' => 'textfield', '#title' => t('Existing system path'), '#default_value' => $edit['src'], '#maxlength' => 64, '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'));
   $form['dst'] = array('#type' => 'textfield', '#default_value' => $edit['dst'], '#maxlength' => 64, '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'));
@@ -323,10 +324,9 @@ function path_load($pid) {
 }
 
 /**
- * Verify that a new URL alias is valid, and save it to the database.
+ * Verify that a new URL alias is valid
  */
-function path_form_submit() {
-  $edit = $GLOBALS['form_values'];
+function path_form_validate($form_id, $edit) {
   $src = $edit['src'];
   $dst = $edit['dst'];
   $pid = $edit['pid'];
@@ -342,16 +342,14 @@ function path_form_submit() {
   if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s'", $pid, $dst))) {
     form_set_error('dst', t('The alias %alias is already in use.', array('%alias' => $dst)));
   }
-
-  if (form_get_errors()) {
-    return path_form($edit);
-  }
-  else {
-    path_set_alias($src, $dst, $pid);
-
-    drupal_set_message(t('The alias has been saved.'));
-    return 'admin/build/path';
-  }
 }
 
+/**
+ * Save a new URL alias to the database.
+ */
+function path_form_submit($form_id, $edit) {
+  path_set_alias($edit['src'], $edit['dst'], $edit['pid']);
 
+  drupal_set_message(t('The alias has been saved.'));
+  return 'admin/build/path';
+}
-- 
GitLab