You are here

function _privatemsg_list_thread in Privatemsg 6.2

Same name and namespace in other branches
  1. 6 privatemsg.module \_privatemsg_list_thread()
  2. 7.2 privatemsg.module \_privatemsg_list_thread()
  3. 7 privatemsg.module \_privatemsg_list_thread()

Formats a row in the message list.

Uses theme patterns to theme single fields.

Parameters

$thread: Array with the row data returned by the database.

Return value

Row definition for use with theme('table')

1 call to _privatemsg_list_thread()
theme_privatemsg_list in ./privatemsg.theme.inc
Theme to display the privatemsg list.

File

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

Code

function _privatemsg_list_thread($thread) {
  $row = array(
    'data' => array(),
  );
  if (!empty($thread['is_new'])) {

    // Set the css class in the tr tag.
    $row['class'] = 'privatemsg-unread';
  }
  $enabled_headers = privatemsg_get_enabled_headers();
  $headers = privatemsg_get_headers();
  foreach ($enabled_headers as $key) {

    // First, try to load a specific theme for that field, if not present, use the default.
    if ($return = theme($headers[$key]['#theme'], $thread)) {

      // The default theme returns nothing, only store the value if we have something.
      $row['data'][$key] = $return;
    }
  }
  if (empty($row['data'])) {
    $row['data'] = _privatemsg_list_thread_fallback($thread);
  }
  return $row;
}