Index: securelogin.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/securelogin/securelogin.module,v
retrieving revision 1.2
diff -u -p -r1.2 securelogin.module
--- securelogin.module	6 Jun 2007 08:48:33 -0000	1.2
+++ securelogin.module	14 Mar 2008 02:04:30 -0000
@@ -57,6 +57,12 @@ function securelogin_admin() {
     '#maxlength' => 300,
     '#description' => t("The base URL at which the site can be accessed securely (no trailing slash), e.g. <em>" . $defurl . "</em>.  The hostname must match the hostname of the insecure URL, and in most cases, you will want the directory to match also (particularly if you have <code>RewriteBase</code> set).")
   );
+  $form['securelogin_redirect'] = array(
+    '#type' => 'checkbox',
+    '#title' => t("Redirect secure pages to HTTPS base url"),
+    '#default_value' => variable_get('securelogin_redirect', FALSE),
+    '#description' => t("Whether or not to redirect forms to HTTPS so that the form is presented as secure.")
+  );
   $form['securelogin_loginform'] = array(
     '#type' => 'checkbox',
     '#title' => t("Secure login form"),
@@ -91,7 +97,13 @@ function securelogin_form_alter($form_id
     ) {
       // Strip trailing slash from base_path
       $base = substr(base_path(), 0, -1);
-      $form['#action'] = preg_replace('@^' . $base . '@', variable_get('securelogin_baseurl', $base), $form['#action']);
+      if (variable_get('securelogin_redirect', FALSE) == TRUE && ! $_SERVER['HTTPS']) {
+        $redirect = preg_replace('@^' . $base . '@', variable_get('securelogin_baseurl', $base), $form['#action']);
+        drupal_set_header('Location: ' . $redirect);
+      }
+      else {
+        $form['#action'] = preg_replace('@^' . $base . '@', variable_get('securelogin_baseurl', $base), $form['#action']);
+      }
   }
 } // function securelogin_form_alter
 
