Commit a72bd54e authored by hass's avatar hass

Issue #159865 by hass, larowlan: add JS snippets for google analytics

permission
parent ac8d267d
......@@ -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',
......
......@@ -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');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment