function _gravatar_load_account in Gravatar integration 7
Same name and namespace in other branches
- 6 gravatar.module \_gravatar_load_account()
1 call to _gravatar_load_account()
- gravatar_preprocess_user_picture in ./
gravatar.module - Override template_preprocess_user_picture() to display user pictures with Gravatar integration.
File
- ./
gravatar.module, line 202 - Integrates gravatar service for user pictures.
Code
function _gravatar_load_account($account) {
// If this is a node or comment object, load the user object.
if (!empty($account->nid) || !empty($account->cid) || empty($account->roles)) {
$original_values = $account;
// If a comment is being edited and previewed, the $account->uid is NULL.
// @todo Remove when http://drupal.org/node/334826 is fixed in 6.x.
if (!isset($account->uid)) {
$account->uid = 0;
}
$account = $account->uid ? user_load($account->uid) : drupal_anonymous_user();
// Load mail/homepage variable from an anonymous comment.
if (!$account->uid) {
$values = array_fill_keys(array(
'name',
'mail',
'homepage',
'hostname',
), '');
foreach ($values as $value => $default_value) {
if (empty($account->{$value})) {
$account->{$value} = !empty($original_values->{$value}) ? $original_values->{$value} : $default_value;
}
}
}
}
if (isset($account->picture) && is_numeric($account->picture)) {
$account->picture = file_load($account->picture);
}
return $account;
}