function realname_make_name in Real Name 6
Same name and namespace in other branches
- 5 realname.module \realname_make_name()
Retreive calculated user name. Try static cache first, DB next and on failure call helper function to calculate realname and populate DB.
Parameters
$account - the user object to update.:
Return value
The retreived "real name" string.
11 calls to realname_make_name()
- realname_form_alter in ./
realname.module - Implements hook_form_alter(). Intercepts the contact forms to show the realname.
- realname_get_user in ./
realname.module - Helper to replace user_load() and be much faster.
- realname_handler_field_user_name_override::render_link in ./
realname_handler_field_user_name_override.inc - realname_plugin_argument_validate_user::validate_argument in ./
realname_plugin_argument_validate_user.inc - realname_preprocess_user_picture in ./
realname.module - Override template_preprocess_user_picture() to display a user's realname.
File
- ./
realname.module, line 765
Code
function realname_make_name(&$account) {
$users =& realname_static('users', array());
$links =& realname_static('links', array());
// Return anonymous user right away.
if ($account->uid == 0) {
return isset($account->name) ? $account->name : variable_get('anonymous', t('Anonymous'));
}
// Check static cache first.
if (isset($users[$account->uid])) {
$account->homepage = isset($links[$account->uid]) ? $links[$account->uid] : NULL;
return $users[$account->uid];
}
if ($module = variable_get('realname_profile_module', NULL)) {
$module_info = realname_supported_modules($module);
}
$result = _realname_make_name($account);
if (isset($module_info['cache']) && !$module_info['cache']) {
return $result;
}
if (empty($result)) {
return $account->name;
}
if (!db_result(db_query("SELECT uid FROM {realname} WHERE uid = %d", $account->uid))) {
db_query("INSERT INTO {realname} (uid, realname) VALUES (%d, '%s')", $account->uid, $result);
}
else {
db_query("UPDATE {realname} SET realname = '%s' WHERE uid = %d", $result, $account->uid);
}
return $result;
}