You are here

function privatemsg_cur_folder_form in Privatemsg 5.3

Same name and namespace in other branches
  1. 5 privatemsg.module \privatemsg_cur_folder_form()
1 string reference to 'privatemsg_cur_folder_form'
privatemsg_list in ./privatemsg.module

File

./privatemsg.module, line 774

Code

function privatemsg_cur_folder_form($folders, $current_folder) {
  global $user;
  foreach ($folders as $folder) {
    $options[$folder['fid']] = $folder['name'];
  }
  $form['header'] = array(
    '#type' => 'fieldset',
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $form['header']['folder_select'] = array(
    '#type' => 'select',
    '#title' => t('Current folder'),
    '#options' => $options,
    '#default_value' => $current_folder,
    '#attributes' => array(
      'class' => 'pm-add-folder-select',
    ),
  );
  $form['header']['go_folder'] = array(
    '#type' => 'submit',
    '#value' => t('Go'),
    '#attributes' => array(
      'class' => 'js-hide',
    ),
  );
  $actor = $current_folder == 1 ? 'author' : 'recipient';
  $result = db_query("SELECT DISTINCT type FROM {privatemsg} WHERE folder = %d AND {$actor}_del = 0 AND {$actor} = %d", $current_folder, $user->uid);
  $types = array(
    '_all' => t('All'),
    '_read' => t('Read'),
    '_unread' => t('Unread'),
    '_none' => t('None'),
    '_invert' => t('Invert'),
    '_privatemsg_delimiter' => '----------------',
    'all types' => t('All types'),
  );
  $filter_types = array(
    'all types' => t('All types'),
  );
  while ($t = db_fetch_object($result)) {
    $type = check_plain($t->type);
    $types[$type] = $type;
    $filter_types[$type] = $type;
  }
  $form['header']['type'] = array(
    '#type' => 'select',
    '#title' => t('Select'),
    '#options' => $types,
    '#attributes' => array(
      'class' => 'pm-filter-select',
    ),
    '#default_value' => '_privatemsg_delimiter',
  );
  $form['header']['filter_type'] = array(
    '#type' => 'select',
    '#title' => t('Filter'),
    '#options' => $filter_types,
    '#default_value' => isset($_SESSION['privatemsg_type']) ? $_SESSION['privatemsg_type'] : 'all types',
  );
  if (isset($_SESSION['privatemsg_type'])) {
    $form['header']['type']['#default_value'] = $_SESSION['privatemsg_type'];
  }
  $form['header']['type_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Filter'),
    '#attributes' => array(
      'class' => 'js-hide',
    ),
  );
  return $form;
}