| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Catch the theme_username function and link to the usernode instead of linking to the userpage
|
| 5 |
*
|
| 6 |
* @param $object
|
| 7 |
* The user object to format, usually returned from user_load().
|
| 8 |
* @return
|
| 9 |
* A string containing an HTML link to the usernode if the passed object
|
| 10 |
* suggests that this is a site user. Otherwise, only the username is returned.
|
| 11 |
*/
|
| 12 |
|
| 13 |
function phptemplate_username($object) {
|
| 14 |
|
| 15 |
if ($object->uid && $object->name) {
|
| 16 |
// Shorten the name when it is too long or it will break many tables.
|
| 17 |
if (drupal_strlen($object->name) > 20) {
|
| 18 |
$name = drupal_substr($object->name, 0, 15) .'...';
|
| 19 |
}
|
| 20 |
else {
|
| 21 |
$name = $object->name;
|
| 22 |
}
|
| 23 |
|
| 24 |
if (user_access('access content') && module_exists('usernode')) {
|
| 25 |
$nid = usernode_get_node_id($object);
|
| 26 |
$output = l($name, 'node/'. $nid, array('title' => t('View user details.')));
|
| 27 |
}
|
| 28 |
else {
|
| 29 |
$output = check_plain($name);
|
| 30 |
}
|
| 31 |
}
|
| 32 |
else if ($object->name) {
|
| 33 |
// Sometimes modules display content composed by people who are
|
| 34 |
// not registered members of the site (e.g. mailing list or news
|
| 35 |
// aggregator modules). This clause enables modules to display
|
| 36 |
// the true author of the content.
|
| 37 |
if ($object->homepage) {
|
| 38 |
$output = l($object->name, $object->homepage);
|
| 39 |
}
|
| 40 |
else {
|
| 41 |
$output = check_plain($object->name);
|
| 42 |
}
|
| 43 |
|
| 44 |
$output .= ' ('. t('not verified') .')';
|
| 45 |
}
|
| 46 |
else {
|
| 47 |
$output = variable_get('anonymous', 'Anonymous');
|
| 48 |
}
|
| 49 |
|
| 50 |
return $output;
|
| 51 |
}
|
| 52 |
|
| 53 |
/**
|
| 54 |
* Catch the theme_user_picture function and link to the usernode instead of linking to the userpage
|
| 55 |
*/
|
| 56 |
|
| 57 |
function phptemplate_user_picture(&$account) {
|
| 58 |
if (variable_get('user_pictures', 0)) {
|
| 59 |
if ($account->picture && file_exists($account->picture)) {
|
| 60 |
$picture = file_create_url($account->picture);
|
| 61 |
}
|
| 62 |
else if (variable_get('user_picture_default', '')) {
|
| 63 |
$picture = variable_get('user_picture_default', '');
|
| 64 |
}
|
| 65 |
|
| 66 |
if (isset($picture)) {
|
| 67 |
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
|
| 68 |
$picture = theme('image', $picture, $alt, $alt, '', false);
|
| 69 |
if (!empty($account->uid) && user_access('access content') && module_exists('usernode')) {
|
| 70 |
$nid = usernode_get_node_id($account);
|
| 71 |
$picture = l($picture, "node/$nid", array('title' => t('View user details.')), NULL, NULL, FALSE, TRUE);
|
| 72 |
}
|
| 73 |
|
| 74 |
return "<div class=\"picture\">$picture</div>";
|
| 75 |
}
|
| 76 |
}
|
| 77 |
}
|