function privatemsg_get_headers

7-2 privatemsg.module privatemsg_get_headers($visible_only = FALSE)
6-2 privatemsg.module privatemsg_get_headers($visible_only = FALSE)

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
privatemsg_get_enabled_headers in ./privatemsg.module
Returns an array of enabled header keys.
privatemsg_list in ./privatemsg.pages.inc
privatemsg_sql_list in ./privatemsg.module
Query definition to load a list of threads.
_privatemsg_list_thread in ./privatemsg.module
Formats all rows (#options) in the privatemsg tableselect thread list.

File

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

Code

function privatemsg_get_headers($visible_only = FALSE) {
  $headers = drupal_static(__FUNCTION__, 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;
  }
}