You are here

function privatemsg_get_headers in Privatemsg 6.2

Same name and namespace in other branches
  1. 7.2 privatemsg.module \privatemsg_get_headers()

Returns an array of defined column headers for message listings.

Parameters

$visible_only: Disabled and denied headers and properties starting with # are removed.

Return value

Array of headers.

See also

hook_privatemsg_header_info()

Related topics

5 calls to privatemsg_get_headers()
privatemsg_admin_settings in ./privatemsg.admin.inc
@file Administration menu callbacks for Privatemsg.
privatemsg_get_enabled_headers in ./privatemsg.module
Returns an array of enabled header keys.
privatemsg_sql_list in ./privatemsg.module
Query definition to load a list of threads.
theme_privatemsg_list in ./privatemsg.theme.inc
Theme to display the privatemsg list.
_privatemsg_list_thread in ./privatemsg.module
Formats a row in the message list.

File

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

Code

function privatemsg_get_headers($visible_only = FALSE) {
  static $headers = NULL;
  if ($headers === NULL) {
    $headers = module_invoke_all('privatemsg_header_info');
    if (!is_array($headers)) {
      $headers = array();
    }
    $weights = variable_get('privatemsg_display_fields_weights', array());
    $enabled = variable_get('privatemsg_display_fields', array(
      'subject',
      'participants',
      'last_updated',
    ));

    // Apply defaults and configurations.
    foreach ($headers as $key => &$header) {

      // Apply defaults.
      $header += array(
        '#enabled' => FALSE,
        '#weight' => 0,
        '#title' => $header['data'],
        '#access' => TRUE,
        '#locked' => FALSE,
        '#theme' => 'privatemsg_list_field__' . $key,
      );
      if (empty($header['#locked']) && isset($enabled[$key])) {
        $header['#enabled'] = (bool) $enabled[$key];
      }
      if (isset($weights[$key])) {
        $header['#weight'] = $weights[$key];
      }
    }
    drupal_alter('privatemsg_header_info', $headers);
    uasort($headers, 'element_sort');
  }
  if ($visible_only) {

    // Remove all attributes prefixed with a # and disabled headers.
    $headers_visible = $headers;
    foreach ($headers_visible as $header_key => &$header) {
      if (!$header['#enabled'] || !$header['#access']) {
        unset($headers_visible[$header_key]);
      }
      else {
        foreach ($header as $key => $value) {
          if ($key[0] == '#') {
            unset($header[$key]);
          }
        }
      }
    }
    return $headers_visible;
  }
  else {
    return $headers;
  }
}