summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2016-08-09 21:26:17 (GMT)
committerhass2016-08-09 21:26:17 (GMT)
commita72bd54e78063777e28b164826512712ebea5a52 (patch)
tree147ae428d01d8b75b2ab0c23b0a410155febca4b
parentac8d267d8f35b71aab306743d682c30fb16f4b8e (diff)
Issue #159865 by hass, larowlan: add JS snippets for google analytics6.x-4.3
permission
-rw-r--r--googleanalytics.admin.inc8
-rw-r--r--googleanalytics.module2
2 files changed, 7 insertions, 3 deletions
diff --git a/googleanalytics.admin.inc b/googleanalytics.admin.inc
index 91087e9..cd2d9dd 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 ? ' <em>' . t('This field has been disabled because you do not have sufficient permissions to edit it.') . '</em>' : '';
$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 <strong>before</strong> <code>ga("send", "pageview");</code>.'),
+ '#description' => t('Code in this textarea will be added <strong>before</strong> <code>ga("send", "pageview");</code>.') . $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 <strong>after</strong> <code>ga("send", "pageview");</code>. This is useful if you\'d like to track a site in two accounts.'),
+ '#description' => t('Code in this textarea will be added <strong>after</strong> <code>ga("send", "pageview");</code>. 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 8cca9f1..94d24cc 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');
}
/**