From 3e2763f2b8a7ac9dd7de386c48ce3e8e62363e91 Mon Sep 17 00:00:00 2001
From: Michael Stenta <mike@mstenta.net>
Date: Sun, 27 Nov 2011 15:04:40 -0500
Subject: Added hook_exclude_ssl_switch_paths() to allow certain paths to be excluded from any kind of HTTP/HTTPS switching at all.

---
 uc_ssl.module |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/uc_ssl.module b/uc_ssl.module
index 588a04e..f8f55cd 100644
--- a/uc_ssl.module
+++ b/uc_ssl.module
@@ -82,6 +82,14 @@ function uc_ssl_exclude_ssl_paths()
    return $paths;
 }
 
+//Implementation of hook_exclude_switch_paths()
+function uc_ssl_exclude_ssl_switch_paths()
+{
+   $paths = array(
+   );
+   return $paths;
+}
+
 function uc_ssl_menu()
 {
    $items = array();
@@ -229,10 +237,26 @@ function uc_ssl_run()
                }
             }
          }
+         
+         // Get a list of all the URL links that should not switch between HTTP/HTTPS at all.
+         $exclude_switch_urls = array();
+         $exclude_switch_urls = module_invoke('uc_ssl', 'exclude_ssl_switch_paths', $exclude_switch_urls);
+         foreach (module_implements('exclude_ssl_switch_paths') as $module)
+         {
+           $new = module_invoke($module, 'exclude_ssl_switch_paths', $exclude_switch_urls);
+           if ($module != 'uc_ssl') //Skip uc_ssl since we already processed it above.  Allow external modules to change uc_ssl defaults.
+           {
+              if (is_array($new))
+              {
+                 $exclude_switch_urls = array_merge($exclude_switch_urls, $new);
+              }
+           }
+         }
 
          // make sure we return an array
          if (! is_array($include_secured_urls)) { $include_secured_urls = array(); }
          if (! is_array($exclude_secured_urls)) { $exclude_secured_urls = array(); }
+         if (! is_array($exclude_switch_urls)) { $exclude_switch_urls = array(); }
 
          //Switch to SSL no matter what the link is if Switch isnt on.
          if (!uc_ssl_switch_to_non_ssl())
@@ -244,6 +268,12 @@ function uc_ssl_run()
          }
          else
          {
+            
+            // If the URL is excluded from switching, don't do anything.
+            if (uc_ssl_path_match($current_path, $exclude_switch_urls)) {
+              return;
+            }
+            
             //If uc_ssl_switch_to_non_ssl() is enabled then we switch back to non-ssl link for non-cart links.
             if (uc_ssl_page_is_in_https_mode())
             {
-- 
1.6.6

