| 1 |
<?php
|
| 2 |
// $Id: realname_theme.inc,v 1.1 2008/06/04 01:18:38 nancyw Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* This include file intercepts the theme('username'... function
|
| 7 |
* and uses the RealName instead of the username.
|
| 8 |
*
|
| 9 |
* @copyright Copyright (c) 2007-2008 Nancy Wichmann. All rights reserved.
|
| 10 |
*/
|
| 11 |
/**
|
| 12 |
* Format a username. (copied from theme.inc)
|
| 13 |
*
|
| 14 |
* @param $object
|
| 15 |
* The user object to format, usually returned from user_load().
|
| 16 |
* @return
|
| 17 |
* A string containing an HTML link to the user's page if the passed object
|
| 18 |
* suggests that this is a site user. Otherwise, only the username is returned.
|
| 19 |
*/
|
| 20 |
function phptemplate_username($object) {
|
| 21 |
// If we have a user id but no realname, then make one.
|
| 22 |
if ($object->uid && !$object->realname) {
|
| 23 |
$account = user_load(array('uid' => $object->uid));
|
| 24 |
$object->realname = realname_make_name($object);
|
| 25 |
}
|
| 26 |
// else {
|
| 27 |
// }
|
| 28 |
|
| 29 |
if ($object->uid && $object->realname) {
|
| 30 |
// Shorten the name when it is too long or it will break many tables.
|
| 31 |
if (drupal_strlen($object->realname) > 20) {
|
| 32 |
$name = drupal_substr($object->realname, 0, 15) .'...';
|
| 33 |
}
|
| 34 |
else {
|
| 35 |
$name = $object->realname;
|
| 36 |
}
|
| 37 |
|
| 38 |
if (user_access('access user profiles')) {
|
| 39 |
$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
|
| 40 |
}
|
| 41 |
else {
|
| 42 |
$output = check_plain($name);
|
| 43 |
}
|
| 44 |
}
|
| 45 |
else if ($object->name) {
|
| 46 |
// Sometimes modules display content composed by people who are
|
| 47 |
// not registered members of the site (e.g. mailing list or news
|
| 48 |
// aggregator modules). This clause enables modules to display
|
| 49 |
// the true author of the content.
|
| 50 |
if ($object->homepage) {
|
| 51 |
$output = l($object->name, $object->homepage);
|
| 52 |
}
|
| 53 |
else {
|
| 54 |
$output = check_plain($object->name);
|
| 55 |
}
|
| 56 |
|
| 57 |
$output .= ' ('. t('not verified') .')';
|
| 58 |
}
|
| 59 |
else {
|
| 60 |
$output = variable_get('anonymous', t('Anonymous'));
|
| 61 |
}
|
| 62 |
|
| 63 |
return $output;
|
| 64 |
}
|