function _google_tag_variable_info_role in GoogleTagManager 7
Same name and namespace in other branches
- 7.2 includes/variable.inc \_google_tag_variable_info_role()
Implements hook_variable_info().
File
- includes/
variable.inc, line 115 - Contains the variable definitions.
Code
function _google_tag_variable_info_role($options) {
global $language;
// Gather data.
// Set language code to default to prevent role names from being translated.
// Use role name in default language as array key as this matches the values
// attached to global user object (used when evaluating role condition). Set
// display value to translated role name.
// @todo This points out core would benefit from a $translate parameter to
// user_roles() to indicate whether to translate the role names. This would be
// used on the role and permission listing pages to consistently translate all
// roles not just the anonymous and authenticated roles.
$language_keep = $language->language;
$language->language = 'en';
$roles = user_roles();
$language->language = $language_keep;
foreach ($roles as $rid => $role) {
// Set display value to translated role name.
$roles[$role] = t($role);
unset($roles[$rid]);
}
// Build variables.
$variables['google_tag_role_toggle'] = array(
'type' => 'select',
'title' => t('Add snippet for specific roles', array(), $options),
'options' => array(
GOOGLE_TAG_EXCLUDE_LISTED => t('All roles except the selected roles', array(), $options),
GOOGLE_TAG_INCLUDE_LISTED => t('Only the selected roles', array(), $options),
),
'default' => GOOGLE_TAG_EXCLUDE_LISTED,
);
$variables['google_tag_role_list'] = array(
'type' => 'options',
'title' => t('Selected roles', array(), $options),
'default' => array(),
'options' => $roles,
);
return $variables;
}