You are here

function _advuser_filter_ui_1 in Advanced User 7.3

Same name and namespace in other branches
  1. 6.3 forms/advuser_filter_ui.inc \_advuser_filter_ui_1()

The operator and data value entry

File

forms/advuser_filter_ui.inc, line 198
This provides a multipart form for the filtering options.

Code

function _advuser_filter_ui_1(&$form, &$form_state) {
  $advuser =& $_SESSION['advuser'];
  $phase =& $advuser['phase'];
  $field =& $phase['values']['field'];
  $conjunction =& $phase['values']['conjunction'];
  $filters =& $advuser['filters'];
  $form['filters']['conjunction'] = array(
    '#type' => 'select',
    '#title' => t('Filter conjunction'),
    '#options' => array(
      'AND' => t('and'),
      ') OR (' => t('or'),
    ),
    '#disabled' => TRUE,
    '#value' => $conjunction,
    '#default_value' => $conjunction,
  );
  if (!count($filters)) {
    $form['filters']['conjunction']['#type'] = 'hidden';
    $form['filters']['conjunction']['#default_value'] = 'AND';
    $form['filters']['conjunction']['#value'] = 'AND';
  }
  $form['filters']['field'] = array(
    '#type' => 'select',
    '#title' => t('Field'),
    '#description' => t('Select the field for this filter'),
    '#options' => _advuser_filter_ui_fields(),
    '#disabled' => TRUE,
    '#value' => $field,
    '#default_value' => $field,
  );
  $form['filters']['operations'] = array(
    '#type' => 'select',
    '#title' => t('Operator'),
    '#options' => _advuser_filter_ui_operations($field),
  );
  $form['filters']['data'] = array(
    '#type' => _advuser_filter_ui_type($field),
    '#title' => t('Data'),
    '#description' => _advuser_filter_ui_desc($field),
  );
  if ($form['filters']['data']['#type'] == 'select') {
    $form['filters']['data']['#options'] = _advuser_filter_ui_options($field);
  }
  if ($field == 'created' || $field == 'access') {
    $form['filters']['message'] = array(
      '#value' => t('Note, to select dates created today use an operator of "is greater than or equal to" with a data value of "today". Use a combination of "is greater than or equal to" "yesterday" AND "less than" "today" to select dates created yesterday.'),
      '#prefix' => '<div class="advuser_message">',
      '#suffix' => '</div><br/>',
    );
  }
  elseif ($field == 'user_roles') {
    $form['filters']['message'] = array(
      '#value' => t('Note, you will not be able to select is equal to ROLE1 and is equal to ROLE2.'),
      '#prefix' => '<div class="advuser_message">',
      '#suffix' => '</div><br/>',
    );
  }
  $form['filters']['submit'] = array(
    '#type' => 'submit',
    '#value' => count($filters) ? t('Refine') : t('Filter'),
    '#submit' => array(
      '_advuser_filter_ui_1_submit',
    ),
  );
  $form['filters']['back'] = array(
    '#type' => 'submit',
    '#value' => t('Back'),
    '#submit' => array(
      '_advuser_filter_ui_1_back',
    ),
  );
}