function _google_tag_variable_info_role in GoogleTagManager 7.2
Same name and namespace in other branches
- 7 includes/variable.inc \_google_tag_variable_info_role()
Implements hook_variable_info().
File
- includes/
variable.inc, line 114 - Contains the variable definitions.
Code
function _google_tag_variable_info_role($options) {
global $language;
// 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';
$options = user_roles();
$language->language = $language_keep;
foreach ($options as $rid => $role) {
// Set display value to translated role name.
$options[$role] = t($role);
unset($options[$rid]);
}
$toggle = 'role_toggle';
$list = 'role_list';
$plural = 'roles';
$config = compact(array(
'toggle',
'list',
'plural',
'options',
));
return _google_tag_variable_info_generic($config, $options);
}