From 87c3e6d10b60e47f31ac932a7d05d084c983cdf9 Mon Sep 17 00:00:00 2001 From: Richard Eriksson Date: Fri, 13 Feb 2015 10:22:04 -0800 Subject: [PATCH 1/3] Implement hook_update_last_removed(), which is the second part of creating an upgrade path from Drupal to Backdrop. https://api.backdropcms.org/node/28621##Create%20an%20upgrade%20path --- googleanalytics.install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/googleanalytics.install b/googleanalytics.install index 78a63eb..44b3ffc 100644 --- a/googleanalytics.install +++ b/googleanalytics.install @@ -111,3 +111,10 @@ function googleanalytics_update_1001() { update_variable_del('googleanalytics_codesnippet_after'); update_variable_del('googleanalytics_debug'); } + +/** + * Implements hook_update_last_removed(). + */ +function googleanalytics_update_last_removed() { + return 7205; +} From 4bfb014dfd44409df88f5598214f0de2ca503ef4 Mon Sep 17 00:00:00 2001 From: Richard Eriksson Date: Tue, 17 Feb 2015 21:03:45 -0500 Subject: [PATCH 2/3] There's no more hook_page_alter() in Backdrop, so use hook_init() instead. see backdrop/backdrop@6490d6bfd7bf813e71266d128a66cbaf71284a1a which does this replacement too. --- googleanalytics.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googleanalytics.module b/googleanalytics.module index 7dc340d..0ff1093 100644 --- a/googleanalytics.module +++ b/googleanalytics.module @@ -81,9 +81,9 @@ function googleanalytics_menu() { } /** - * Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page. + * Implements hook_init() to insert JavaScript to the appropriate scope/region of the page. */ -function googleanalytics_page_alter(&$page) { +function googleanalytics_init() { global $user; $config = config('googleanalytics.settings'); From 6410cdf51ccec115094da381fd00a1e73c2704ec Mon Sep 17 00:00:00 2001 From: Richard Eriksson Date: Tue, 17 Feb 2015 21:04:05 -0500 Subject: [PATCH 3/3] Fix a few instances of broken configuration. --- googleanalytics.module | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googleanalytics.module b/googleanalytics.module index 0ff1093..c93fd49 100644 --- a/googleanalytics.module +++ b/googleanalytics.module @@ -428,6 +428,7 @@ function googleanalytics_user_presave(&$edit, $account, $category) { * Implements hook_cron(). */ function googleanalytics_cron() { + $config = config('googleanalytics.settings'); // Regenerate the tracking code file every day. if (REQUEST_TIME - $config->get('last_cache') >= 86400 && $config->get('cache')) { _googleanalytics_cache('http://www.google-analytics.com/analytics.js', TRUE); @@ -547,6 +548,7 @@ function googleanalytics_clear_js_cache() { function _googleanalytics_visibility_user($account) { $enabled = FALSE; + $config = config('googleanalytics.settings'); // Is current user a member of a role that should be tracked? if (_googleanalytics_visibility_header($account) && _googleanalytics_visibility_roles($account)) { @@ -575,6 +577,7 @@ function _googleanalytics_visibility_user($account) { */ function _googleanalytics_visibility_roles($account) { + $config = config('googleanalytics.settings'); $visibility = $config->get('visibility_roles'); $enabled = $visibility; $roles = $config->get('roles');