diff -ru google_analytics-6.x-4.2-unpatched/googleanalytics.admin.inc google_analytics-6.x-4.2/googleanalytics.admin.inc --- google_analytics-6.x-4.2-unpatched/googleanalytics.admin.inc 2016-04-16 13:58:42.000000000 +0200 +++ google_analytics-6.x-4.2/googleanalytics.admin.inc 2016-08-02 22:12:55.706019447 +0200 @@ -390,6 +390,8 @@ } // Advanced feature configurations. + $user_access_add_js_snippets = user_access('add JS snippets for google analytics') ? FALSE : TRUE; + $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 @@ '#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 -ru google_analytics-6.x-4.2-unpatched/googleanalytics.module google_analytics-6.x-4.2/googleanalytics.module --- google_analytics-6.x-4.2-unpatched/googleanalytics.module 2016-04-16 13:58:42.000000000 +0200 +++ google_analytics-6.x-4.2/googleanalytics.module 2016-08-02 22:11:31.412323533 +0200 @@ -64,7 +64,7 @@ * 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'); } /**