You are here

function privatemsg_list in Privatemsg 6.2

Same name and namespace in other branches
  1. 5.3 privatemsg.module \privatemsg_list()
  2. 5 privatemsg.module \privatemsg_list()
  3. 6 privatemsg.module \privatemsg_list()
  4. 7.2 privatemsg.pages.inc \privatemsg_list()
  5. 7 privatemsg.pages.inc \privatemsg_list()
1 string reference to 'privatemsg_list'
privatemsg_list_page in ./privatemsg.pages.inc
List messages.

File

./privatemsg.pages.inc, line 33
User menu callbacks for Privatemsg.

Code

function privatemsg_list(&$form_state, $argument, $account) {
  $query = _privatemsg_assemble_query('list', $account, $argument);
  $result = pager_query($query['query'], variable_get('privatemsg_per_page', 25), 0, $query['count']);
  $threads = array();
  $form = array(
    '#list_argument' => $argument,
  );
  $form['#data'] = array();
  while ($row = db_fetch_array($result)) {

    // Store the raw row data.
    $form['#data'][$row['thread_id']] = $row;

    // store thread id for the checkboxes array
    $threads[$row['thread_id']] = '';
  }
  if (!empty($form['#data'])) {
    $form['actions'] = _privatemsg_action_form($argument);
  }

  // Save the currently active account, used for actions.
  $form['account'] = array(
    '#type' => 'value',
    '#value' => $account,
  );

  // Define checkboxes, pager and theme
  $form['threads'] = array(
    '#type' => 'checkboxes',
    '#options' => $threads,
  );
  $form['pager'] = array(
    '#value' => theme('pager'),
    '#weight' => 20,
  );
  $form['#theme'] = 'privatemsg_list';

  // Store the account for which the threads are displayed.
  $form['#account'] = $account;
  return $form;
}