diff --git a/googleanalytics.admin.inc b/googleanalytics.admin.inc index 91087e90f895cb58e9f73754518224a19880cef5..cd2d9dd3a4bc67f11b5e55576fa8122c8c10901d 100644 --- a/googleanalytics.admin.inc +++ b/googleanalytics.admin.inc @@ -390,6 +390,8 @@ function googleanalytics_admin_settings_form(&$form_state) { } // Advanced feature configurations. + $user_access_add_js_snippets = !user_access('add JS snippets for google analytics'); + $user_access_add_js_snippets_permission_warning = $user_access_add_js_snippets ? ' ' . t('This field has been disabled because you do not have sufficient permissions to edit it.') . '' : ''; $form['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced settings'), @@ -436,17 +438,19 @@ function googleanalytics_admin_settings_form(&$form_state) { '#type' => 'textarea', '#title' => t('Code snippet (before)'), '#default_value' => variable_get('googleanalytics_codesnippet_before', ''), + '#disabled' => $user_access_add_js_snippets, '#rows' => 5, '#wysiwyg' => FALSE, - '#description' => t('Code in this textarea will be added before ga("send", "pageview");.'), + '#description' => t('Code in this textarea will be added before ga("send", "pageview");.') . $user_access_add_js_snippets_permission_warning, ); $form['advanced']['codesnippet']['googleanalytics_codesnippet_after'] = array( '#type' => 'textarea', '#title' => t('Code snippet (after)'), '#default_value' => variable_get('googleanalytics_codesnippet_after', ''), + '#disabled' => $user_access_add_js_snippets, '#rows' => 5, '#wysiwyg' => FALSE, - '#description' => t('Code in this textarea will be added after ga("send", "pageview");. This is useful if you\'d like to track a site in two accounts.'), + '#description' => t('Code in this textarea will be added after ga("send", "pageview");. This is useful if you\'d like to track a site in two accounts.') . $user_access_add_js_snippets_permission_warning, ); $form['advanced']['googleanalytics_debug'] = array( '#type' => 'checkbox', diff --git a/googleanalytics.module b/googleanalytics.module index 8cca9f13f6d848ea6ccdeb9397b00091ed0d9ba1..94d24cca9bdb5b9fd7e8a0a4eeabf6fe05574ac8 100644 --- a/googleanalytics.module +++ b/googleanalytics.module @@ -64,7 +64,7 @@ function googleanalytics_theme_registry_alter(&$registry) { * Implementation of hook_perm(). */ function googleanalytics_perm() { - return array('administer google analytics', 'opt-in or out of tracking', 'use PHP for tracking visibility'); + return array('administer google analytics', 'opt-in or out of tracking', 'use PHP for tracking visibility', 'add JS snippets for google analytics'); } /**