? contact_redirect-20081003.patch
Index: contact_redirect.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/contact_redirect/contact_redirect.info,v
retrieving revision 1.1
diff -u -p -r1.1 contact_redirect.info
--- contact_redirect.info	29 Sep 2008 19:18:48 -0000	1.1
+++ contact_redirect.info	3 Oct 2008 08:32:03 -0000
@@ -2,5 +2,6 @@
 name = Contact Redirect
 description = Adds the ability to redirect users to another page after submitting site-wide contact forms.
 package = Other
-dependencies = contact
+core = 6.x
+dependencies[] = contact
 
Index: contact_redirect.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/contact_redirect/contact_redirect.install,v
retrieving revision 1.1
diff -u -p -r1.1 contact_redirect.install
--- contact_redirect.install	29 Sep 2008 19:18:48 -0000	1.1
+++ contact_redirect.install	3 Oct 2008 08:32:03 -0000
@@ -13,15 +13,7 @@
  * Implementation of hook_install().
  */
 function contact_redirect_install() {
-  
-  switch ($GLOBALS['db_type']) {
-    case 'pgsql':
-      db_query("ALTER TABLE {contact} ADD COLUMN redirect varchar(255) NOT NULL default ''");
-      break;
-      
-    case 'mysql':
-    case 'mysqli':
-      db_query("ALTER TABLE {contact} ADD COLUMN redirect varchar(255) NOT NULL default ''");
-      break;
-  }
+  $ret = NULL;
+  db_add_field($ret, 'contact', 'redirect', array('type' => 'varchar', 'length' => 255));
+  return $ret;
 }
\ No newline at end of file
Index: contact_redirect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/contact_redirect/contact_redirect.module,v
retrieving revision 1.1
diff -u -p -r1.1 contact_redirect.module
--- contact_redirect.module	29 Sep 2008 19:18:48 -0000	1.1
+++ contact_redirect.module	3 Oct 2008 08:32:03 -0000
@@ -14,8 +14,7 @@
  * Implementation of hook_form_alter().
  * Add the redirect functionality
  */
-function contact_redirect_form_alter($form_id, &$form) {
-  
+function contact_redirect_form_alter(&$form, &$form_state, $form_id) {
   switch ($form_id) {
     case 'contact_admin_edit':
             
@@ -32,21 +31,13 @@ function contact_redirect_form_alter($fo
       
       //switch submit function to our own custom version that adds redirect
       //not sure if there is a better way to do this.
-      unset($form['#submit']['contact_admin_edit_submit']);
-      $form['#submit']['contact_redirect_contact_admin_edit_submit'] = array();
+      unset($form['#submit']);
+      $form['#submit'][] = 'contact_redirect_contact_admin_edit_submit';
     break;
     
     case 'contact_mail_page':
-      //is this a multiple or single contact form?
-      if ($form['#post']['cid']) {
-        //this is a multiple contact form, so we get the value from $form['#post']['cid']
-        $form['#redirect'] = check_plain(contact_redirect_get($form['#post']['cid']));
-      }
-      else{
-        //a single contact form (no choices given) so we get values from $form['cid']['#value'] 
-        $form['#redirect'] = check_plain(contact_redirect_get($form['cid']['#value']));
-      }
-    break;
+      $form['#submit'][] = 'contact_redirect'; // Add a submit function that alters the redirect value
+      break;
   }
   
 }
@@ -55,31 +46,31 @@ function contact_redirect_form_alter($fo
  * Process the contact category edit page form submission.
  * Custom version of contact_admin_edit_submit that adds redirect.
  */
-function contact_redirect_contact_admin_edit_submit($form_id, $form_values) {
+function contact_redirect_contact_admin_edit_submit($form, &$form_state) {
   
-  if ($form_values['selected']) {
+  if ($form_state['values']['selected']) {
     // Unselect all other contact categories.
     db_query('UPDATE {contact} SET selected = 0');
   }
-  $recipients = explode(',', $form_values['recipients']);
+  $recipients = explode(',', $form_state['values']['recipients']);
   foreach ($recipients as $key => $recipient) {
     // E-mail address validation has already been done in _validate.
     $recipients[$key] = trim($recipient);
   }
-  $form_values['recipients'] = implode(',', $recipients);
+  $form_state['values']['recipients'] = implode(',', $recipients);
   if (arg(3) == 'add') {
-    db_query("INSERT INTO {contact} (category, recipients, reply, redirect, weight, selected) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['redirect'], $form_values['weight'], $form_values['selected']);
-    drupal_set_message(t('Category %category has been added.', array('%category' => $form_values['category'])));
-    watchdog('mail', t('Contact form: category %category added.', array('%category' => $form_values['category'])), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
+    db_query("INSERT INTO {contact} (category, recipients, reply, redirect, weight, selected) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $form_state['values']['category'], $form_state['values']['recipients'], $form_state['values']['reply'], $form_state['values']['redirect'], $form_state['values']['weight'], $form_state['values']['selected']);
+    drupal_set_message(t('Category %category has been added.', array('%category' => $form_state['values']['category'])));
+    watchdog('mail', 'Contact form: category %category added.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
 
   }
   else {
-    db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', redirect = '%s', weight = %d, selected = %d WHERE cid = %d", $form_values['category'], $form_values['recipients'], $form_values['reply'], $form_values['redirect'], $form_values['weight'], $form_values['selected'], $form_values['cid']);
-    drupal_set_message(t('Category %category has been updated.', array('%category' => $form_values['category'])));
-    watchdog('mail', t('Contact form: category %category updated.', array('%category' => $form_values['category'])), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
+    db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', redirect = '%s', weight = %d, selected = %d WHERE cid = %d", $form_state['values']['category'], $form_state['values']['recipients'], $form_state['values']['reply'], $form_state['values']['redirect'], $form_state['values']['weight'], $form_state['values']['selected'], $form_state['values']['cid']);
+    drupal_set_message(t('Category %category has been updated.', array('%category' => $form_state['values']['category'])));
+    watchdog('mail', 'Contact form: category %category updated.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
   }
 
-  return 'admin/build/contact';
+  $form_state['redirect'] = 'admin/build/contact';
 }
 
 /**
@@ -93,4 +84,13 @@ function contact_redirect_get($cid = FAL
     $redirect = '';
   }
   return $redirect;
+}
+
+/**
+ * Redirect the form
+ */
+function contact_redirect($form, &$form_state) {
+  if (isset($form_state['values']['cid']) && !empty($form_state['values']['cid'])) {
+    $form_state['redirect'] = contact_redirect_get($form_state['values']['cid']);
+  }
 }
\ No newline at end of file
