You are here

function _spaces_contacts_users in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces_contacts/spaces_contacts.module \_spaces_contacts_users()

Wrapper around spaces_get_users() that provides additional support for vcard name fields

2 calls to _spaces_contacts_users()
spaces_contacts_block in spaces_contacts/spaces_contacts.module
Implementation of hook_block()
spaces_contacts_pageview in spaces_contacts/spaces_contacts.module
Page callback that displays a user contact listing

File

spaces_contacts/spaces_contacts.module, line 127

Code

function _spaces_contacts_users() {
  $users = spaces_get_users();
  if (module_exists('profile')) {
    foreach ($users as $key => $account) {
      $account = user_load($account);
      profile_load_profile($account);

      // Replace username listing with real name if possible
      if ($account->profile_givenname && $account->profile_familyname) {
        $account->name = $account->profile_givenname . ' ' . $account->profile_familyname;
      }
      else {
        if ($account->profile_givenname) {
          $account->name = $account->profile_givenname;
        }
      }
      $users[$key] = $account;
    }
  }
  return $users;
}