function protected_node_tokens in Protected Node 7
Same name and namespace in other branches
- 1.0.x protected_node.module \protected_node_tokens()
Implements hook_tokens().
File
- ./
protected_node.module, line 1130 - Protected Node module.
Code
function protected_node_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
if ($type == 'node' && !empty($data['node'])) {
$node = $data['node'];
if (!empty($node->protected_node_is_protected)) {
foreach ($tokens as $name => $original) {
switch ($name) {
case 'is-protected':
$replacements[$original] = t('yes');
break;
case 'password':
$replacements[$original] = empty($node->protected_node_clear_passwd) ? '' : $node->protected_node_clear_passwd;
break;
case 'protected-title':
$replacements[$original] = empty($node->protected_node_show_title) ? t('yes') : t('no');
break;
case 'password-hint':
$replacements[$original] = $node->protected_node_hint;
break;
}
}
}
}
return $replacements;
}