function realname_load_multiple in Real Name 7
Same name and namespace in other branches
- 8 realname.module \realname_load_multiple()
- 2.x realname.module \realname_load_multiple()
Loads multiple real names.
Parameters
array $accounts: An array of user account objects keyed by user ID.
Return value
array An array of real names keyed by user ID.
Related topics
2 calls to realname_load_multiple()
- realname_load in ./
realname.module - Loads a real name.
- realname_user_load in ./
realname.module - Implements hook_user_load().
3 string references to 'realname_load_multiple'
- realname_delete_all in ./
realname.module - Delete all real names.
- realname_delete_multiple in ./
realname.module - Delete multiple real names.
- realname_user_update in ./
realname.module - Implements hook_user_update().
File
- ./
realname.module, line 288 - Provides token-based name displays for users.
Code
function realname_load_multiple(array $accounts) {
$realnames =& drupal_static(__FUNCTION__, array());
if ($new_accounts = array_diff_key($accounts, $realnames)) {
// Attempt to fetch realnames from the database first.
$realnames += db_query("SELECT uid, realname FROM {realname} WHERE uid IN (:uids)", array(
':uids' => array_keys($new_accounts),
))
->fetchAllKeyed();
// For each account that was not present in the database, generate its
// real name.
foreach ($new_accounts as $uid => $account) {
if (!isset($realnames[$uid])) {
$realnames[$uid] = realname_update($account);
}
}
}
return array_intersect_key($realnames, $accounts);
}