You are here

protected function PrivatemsgMessageController::attachLoad in Privatemsg 7

Same name and namespace in other branches
  1. 7.2 privatemsg.module \PrivatemsgMessageController::attachLoad()

Attaches data to entities upon loading.

This will attach fields, if the entity is fieldable. It calls hook_entity_load() for modules which need to add data to all entities. It also calls hook_TYPE_load() on the loaded entities. For example hook_node_load() or hook_user_load(). If your hook_TYPE_load() expects special parameters apart from the queried entities, you can set $this->hookLoadArguments prior to calling the method. See NodeController::attachLoad() for an example.

Parameters

$queried_entities: Associative array of query results, keyed on the entity ID.

$revision_id: ID of the revision that was loaded, or FALSE if the most current revision was loaded.

Overrides DrupalDefaultEntityController::attachLoad

File

./privatemsg.module, line 3099
Allows users to send private messages to other users.

Class

PrivatemsgMessageController
Private message controller, loads private messages.

Code

protected function attachLoad(&$messages, $revision_id = FALSE) {
  global $user;
  foreach ($messages as $message) {
    $message->user = $this->account ? $this->account : $user;

    // Load author of message.
    if (!($message->author = user_load($message->author))) {

      // If user does not exist, load anonymous user.
      $message->author = user_load(0);
    }
  }
  parent::attachLoad($messages, $revision_id);
}