function piwik_tokens in Piwik Web Analytics 7.2
Same name and namespace in other branches
- 8 piwik.tokens.inc \piwik_tokens()
Implements hook_tokens().
File
- ./
piwik.tokens.inc, line 31 - Builds placeholder replacement tokens for user-related data.
Code
function piwik_tokens($type, $tokens, array $data = array(), array $options = array()) {
$sanitize = !empty($options['sanitize']);
$replacements = array();
if ($type == 'user' && !empty($data['user']->roles)) {
$account = $data['user'];
foreach ($tokens as $name => $original) {
switch ($name) {
// Basic user account information.
case 'piwik-role-names':
$names = implode(',', $account->roles);
$replacements[$original] = $sanitize ? check_plain($names) : $names;
break;
case 'piwik-role-ids':
$ids = implode(',', array_keys($account->roles));
$replacements[$original] = $sanitize ? check_plain($ids) : $ids;
break;
}
}
}
return $replacements;
}