function user_list_filter_form

6.x user.module user_list_filter_form()

File

modules/user/user.module, line 2660

Code

function user_list_filter_form() {

  $form = array();


  $form ['mark_top'] = array(
    'type' => 'markup',
    'value' => "<strong>" . t('Filter by...') . "</strong>",
    'weight' => 0,
  );


  $form ['de_catalog_year'] = array(
    'type' => 'hidden',
    'value' => @$_REQUEST ['de_catalog_year'],
  );



  $filter_name_value = @trim($_SESSION ['users_filter_name']);
  $form ['filter_name'] = array(
    'type' => 'textfield',
    'label' => '',
    'attributes' => array("placeholder" => t("Name or CWID")),
    'value' => $filter_name_value,
    'size' => 20,
    'weight' => 10,
  );



  // Show list of departments
  if (module_enabled('schools')) {
    $dept_options = fp_get_departments(0, TRUE);
  }
  else {
    $dept_options = fp_get_departments();
  }

  $filter_dept_value = @trim($_SESSION ['users_filter_dept']);
  $form ['filter_dept'] = array(
    'type' => 'select',
    'label' => t('Department:'),
    'options' => $dept_options,
    'value' => $filter_dept_value,
    'weight' => 20,
  );



  // Show list of roles
  $role_options = array();
  $res = db_query("SELECT * FROM roles ORDER BY rid");
  while ($cur = db_fetch_array($res)) {
    $key = $cur ["rid"];
    $value = $cur ["name"];
    $dispval = $value;

    // Skip anonymous and authenticated
    if ($key == 1 || $key == 2) {
      continue;
    }

    if (strlen($dispval) > 25) {
      $dispval = trim(substr($dispval, 0, 22)) . "...";
    }
    $role_options [$key] = $dispval;
  }

  $filter_role_value = @intval($_SESSION ['users_filter_role']);
  $form ['filter_role'] = array(
    'type' => 'select',
    'label' => t('Role:'),
    'options' => $role_options,
    'value' => $filter_role_value,
    'weight' => 30,
  );



  // If we have enabled the schools module, then have a selector for that as well
  if (module_enabled('schools')) {

    $filter_school_value = @intval($_SESSION ['users_filter_school']);
    $options = schools_get_schools_for_fapi(TRUE, TRUE, 'user', TRUE);
    $options [0] = t('- Default -');
    $form ['filter_school'] = array(
      'type' => 'select',
      'label' => t('School:'),
      'options' => $options,
      'value' => $filter_school_value,
      'weight' => 40,
      'hide_please_select' => TRUE,
    );

  } // if schools enabled  



  $form ['submit_btn'] = array(
    'type' => 'submit',
    'value' => t('Apply'),
    'weight' => 100,
  );

  $form ['reset_btn'] = array(
    'type' => 'submit',
    'value' => t('Reset'),
    'weight' => 110,
  );


  return $form;
}