You are here

function _privatemsg_list_thread in Privatemsg 7.2

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

Formats all rows (#options) in the privatemsg tableselect thread 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 string reference to '_privatemsg_list_thread'
privatemsg_list in ./privatemsg.pages.inc

File

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

Code

function _privatemsg_list_thread($tableselect) {
  $enabled_headers = privatemsg_get_enabled_headers();
  $headers = privatemsg_get_headers();

  // theme() doesn't include the theme file for patterns, we need to do it
  // manually.
  include_once drupal_get_path('module', 'privatemsg') . '/privatemsg.theme.inc';
  foreach ($tableselect['#options'] as $id => $thread) {
    $row = array();
    if (!empty($thread['is_new'])) {

      // Set the css class in the tr tag.
      $row['#attributes']['class'][] = 'privatemsg-unread';
    }
    if (!empty($thread['is_replied'])) {

      // Set the css class in the tr tag.
      $row['#attributes']['class'][] = 'privatemsg-replied';
    }
    foreach ($enabled_headers as $key) {

      // Theme each enabled field.
      $row[$key] = theme($headers[$key]['#theme'], array(
        'thread' => $thread,
      ));
    }
    $tableselect['#options'][$id] = $row;
  }
  return $tableselect;
}