From e0cf609738279d1b726d6366ed770806d98794d1 Mon Sep 17 00:00:00 2001 From: Pol Dell'Aiera Date: Thu, 22 Sep 2011 23:16:59 +0200 Subject: [PATCH 152/152] Fix for #374222: Template files do not work when using admin theme --- simplenews.module | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/simplenews.module b/simplenews.module index 53db457..fa2cf57 100644 --- a/simplenews.module +++ b/simplenews.module @@ -93,6 +93,11 @@ function simplenews_init() { '@settings' => url('admin/settings/simplenews/general') )), 'error'); } + + if (_simplenews_is_run_from_cron()) { + variable_set('simplenews_theme_backup', $GLOBALS['custom_theme']); + $GLOBALS['custom_theme'] = variable_get('theme_default', 'garland'); + } } /** @@ -863,6 +868,14 @@ function simplenews_cron() { simplenews_clear_spool(); // Update sent status for newsletter admin panel. simplenews_send_status_update(); + + if (_simplenews_is_run_from_cron()) { + $GLOBALS['custom_theme'] = variable_get('simplenews_theme_backup', $GLOBALS['custom_theme']); + variable_del('simplenews_theme_backup'); + } + + + } /** @@ -2353,6 +2366,23 @@ function _simplenews_get_node_defaults() { return $defaults; } +/* + * Check if called from cron. + */ +function _simplenews_is_run_from_cron() { + $paths = implode("\r\n", array('*run-cron', '*cron.php')); + $run_from_cron = FALSE; + + $run_from_cron = drupal_match_path($_GET['q'], $paths); + $alias = drupal_get_path_alias($_GET['q']); + if ($alias != $_GET['q']) { + $run_from_cron = FALSE || drupal_match_path($alias, $paths); + } + + return $run_from_cron; +} + + /** * Implementation of hook_content_build_modes(). */ -- 1.7.3.4