function realname_token_values in Real Name 6
Same name and namespace in other branches
- 5 token_realname.inc \realname_token_values()
File
- ./
realname_token.inc, line 28 - Token module support for the realname module.
Code
function realname_token_values($type, $object = NULL, $options = array()) {
global $user;
$tokens = array();
if (!$object) {
$object = $user;
}
switch ($type) {
case 'user':
case 'node':
// If there's a nid, then create a token with the realname of
// author of the node.
if (!empty($object->nid) && $object->uid) {
$name = db_result(db_query("SELECT realname FROM {realname} WHERE uid = %d", $object->uid));
$tokens['realname-node-author'] = check_plain($name);
$tokens['realname-node-author-raw'] = $name;
}
// case 'all':
case 'global':
case 'comment':
// If there's a cid, then create a token with the realname of
// author of the comment
if (!empty($object->cid) && $object->uid) {
$name = db_result(db_query("SELECT realname FROM {realname} WHERE uid = %d", $object->uid));
$tokens['realname-comment-author'] = check_plain($name);
$tokens['realname-comment-author-raw'] = $name;
}
if (!isset($object->uid)) {
return;
}
$realname = realname_make_name($object);
$tokens['realname'] = check_plain($realname);
$tokens['realname-raw'] = $realname;
$tokens['realname-link'] = theme('username', $object);
$tokens['homepage'] = isset($object->homepage) ? check_url($object->homepage) : NULL;
return $tokens;
}
}