Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/CHANGELOG.txt,v
retrieving revision 1.40
diff -u -p -r1.40 CHANGELOG.txt
--- CHANGELOG.txt	9 Mar 2009 02:24:33 -0000	1.40
+++ CHANGELOG.txt	9 Mar 2009 02:56:56 -0000
@@ -6,6 +6,7 @@ Image x.x-x.x, xxxx-xx-xx
 
 Image 6.x-1.x, xxxx-xx-xx
 -------------------------
+#362818 by sun: Fixed validation/submission of Image Import settings form.
 #298702 by sp3boy, smk-ka, sun: Fixed image uploads are not properly validated.
 #225024 by sun: Fixed filepaths not always prefixed with file_directory_path().
 #185081 by sun: Fixed image_file_download tries to transfer non-existing files.
Index: contrib/image_import/image_import.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_import/image_import.admin.inc,v
retrieving revision 1.2
diff -u -p -r1.2 image_import.admin.inc
--- contrib/image_import/image_import.admin.inc	22 Dec 2008 21:37:28 -0000	1.2
+++ contrib/image_import/image_import.admin.inc	9 Mar 2009 02:53:49 -0000
@@ -1,36 +1,49 @@
 <?php
 // $Id: image_import.admin.inc,v 1.2 2008/12/22 21:37:28 drewish Exp $
 
+/**
+ * Form builder function for Image Import settings form.
+ */
 function image_import_admin_settings() {
   $form['image_import_path'] = array(
     '#type' => 'textfield',
     '#title' => t('Import path'),
-    '#default_value' => variable_get('image_import_path', file_directory_temp() .'/image/'),
-    '#after_build' => array('_image_import_settings_check_directory'),
+    '#default_value' => variable_get('image_import_path', file_directory_temp() .'/image'),
     '#description' => t("The directory to import image nodes from. Drupal will need to have write access to this directory so we can move the file.") .'<br />'
       . t("<strong>Note:</strong> a path begining with a <kbd>/</kbd> indicates the path is relative to the server's root, one starting without specifies a path relative to Drupal's root. I.e. <kbd>/tmp/image</kbd> would be the temp directory off the root while <kbd>tmp/image</kbd> would be inside Drupal's directory."),
     '#required' => TRUE,
   );
-  return system_settings_form($form);
+  $form = system_settings_form($form);
+  // Apply our validation and submit handlers to the submit button.
+  $form['buttons']['submit']['#validate'][] = 'image_import_admin_settings_submit_validate';
+  $form['buttons']['submit']['#submit'][] = 'image_import_admin_settings_submit_submit';
+  $form['buttons']['submit']['#submit'][] = 'system_settings_form_submit';
+  return $form;
 }
 
 /**
+ * Form validation handler for Image Import settings form.
+ *
  * Checks the existence of the directory specified in $form_element.
  *
- * @param $form_element
- *   The form element containing the name of the directory to check.
  * @see system_check_directory()
  */
-function _image_import_settings_check_directory($form_element) {
-  $import_dir = $form_element['#value'];
-  file_check_directory($import_dir, 0, $form_element['#parents'][0]);
+function image_import_admin_settings_submit_validate($form, &$form_state) {
+  $import_dir = $form_state['values']['image_import_path'];
+  file_check_directory($import_dir, 0, 'image_import_path');
   $image_dir = variable_get('image_file_path', file_directory_path() .'/image');
   if (realpath($import_dir) == realpath($image_dir)) {
-    form_set_error($form_element['#parents'][0], t("You can't import from the image module's directory. The import deletes the original files so you would just be asking for trouble."));
-  }
-  else {
-    drupal_set_message(t("Your settings are configured correctly, you can import images <a href='!image_import_page'>here</a>.", array('!image_import_page' => url('admin/content/image_import'))));
+    form_set_error('image_import_path', t("You can't import from the image module's directory. The import deletes the original files so you would just be asking for trouble."));
   }
+}
 
-  return $form_element;
+/**
+ * Form submit handler for Image Import settings form.
+ */
+function image_import_admin_settings_submit_submit($form, &$form_state) {
+  // Ensure that 'image_import_path' variable contains no trailing slash.
+  $form_state['values']['image_import_path'] = rtrim($form_state['values']['image_import_path'], '/');
+
+  drupal_set_message(t("Your settings are configured correctly, you can import images <a href='!image_import_page'>here</a>.", array('!image_import_page' => url('admin/content/image_import'))));
 }
+
Index: contrib/image_import/image_import.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/image/contrib/image_import/image_import.module,v
retrieving revision 1.20
diff -u -p -r1.20 image_import.module
--- contrib/image_import/image_import.module	5 Mar 2009 23:48:13 -0000	1.20
+++ contrib/image_import/image_import.module	9 Mar 2009 02:50:13 -0000
@@ -8,12 +8,6 @@ function image_import_help($path, $arg) 
   switch ($path) {
     case 'admin/content/image_import':
       return '<p>'. t("Import multiple image files and save them as image nodes. The files will be moved from their location into the image module's files directory. Searching for image files in %dirpath.", array('%dirpath' => realpath(variable_get('image_import_path', '')))) .'</p>';
-
-    case 'admin/settings/image/image_import':
-      return t("Configure the image import module's settings.");
-
-    default:
-      return null;
   }
 }
 
@@ -28,8 +22,6 @@ function image_import_perm() {
  * Implementation of hook_menu().
  */
 function image_import_menu() {
-  $items = array();
-
   $items['admin/content/image_import'] = array(
     'title' => 'Image import',
     'description' => 'Import image from the filesystem.',
@@ -48,12 +40,11 @@ function image_import_menu() {
     'access arguments' => array('administer site configuration'),
     'type' => MENU_LOCAL_TASK,
   );
-
   return $items;
 }
 
 /**
- * Implementation of hook_theme
+ * Implementation of hook_theme().
  */
 function image_import_theme() {
   return array(
@@ -63,3 +54,4 @@ function image_import_theme() {
     ),
   );
 }
+
