You are here

public function Messaging_User_Object::get_user_name in Messaging 6.4

Get destination user name, either from user object or from a user_name property.

When loading a listing of objects, we can save some queries by setting the user_name property

File

includes/messaging_object.class.inc, line 68
Drupal Messaging Framework - Base classes

Class

Messaging_User_Object
Messaging user's object

Code

public function get_user_name() {
  if (!empty($this->_user)) {
    $user = $this->_user;
  }
  elseif (!empty($this->user_name)) {
    $user = new Stdclass();
    $user->uid = $this->uid;
    $user->name = $this->user_name;
  }
  else {

    // Last resource, we do user loading
    $user = $this
      ->get_user();
  }
  return $user ? theme('username', $user) : t('none');
}