From 0e1eb6aa1b8a987ab5da253087978d4bab30a42a Mon Sep 17 00:00:00 2001
From: Pol Dell'Aiera <Pol@47194.no-reply.drupal.org>
Date: Fri, 2 Sep 2011 09:31:14 +0200
Subject: [PATCH] Fix issue #374222: template files do not work when using admin theme.

---
 simplenews.module |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/simplenews.module b/simplenews.module
index 53db457..3a89636 100644
--- a/simplenews.module
+++ b/simplenews.module
@@ -858,6 +858,23 @@ function simplenews_form_alter(&$form, $form_state, $form_id) {
  * Implementation of hook_cron().
  */
 function simplenews_cron() {
+
+  $disallow_paths = array('*run-cron', '*cron.php');
+  $disallow_paths_string = implode("\n", $disallow_paths);
+  $disallow_path = FALSE;
+
+  if (trim($disallow_paths_string) != '') {
+    $disallow_path = drupal_match_path($_GET['q'], $disallow_paths_string);
+    $alias = drupal_get_path_alias($_GET['q']);
+    if ($alias != $_GET['q']) {
+      $disallow_path = FALSE || drupal_match_path($alias, $disallow_paths_string);
+    }
+  }
+
+  if ($disallow_path == TRUE) {
+    $GLOBALS['custom_theme'] = variable_get('theme_default', 'garland');
+  }
+
   module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
   simplenews_mail_spool();
   simplenews_clear_spool();
-- 
1.7.4

