function user_student_list_filter_form

6.x user.student.inc user_student_list_filter_form()

File

modules/user/user.student.inc, line 328
Keep track of functions dealing specifically with student user management

Code

function user_student_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 majors (which are also in FlightPath, and in the selected school, if any)
  $options = array();
  $test_school_id = @intval($_SESSION ['users_filter_school']);
  $test_school_options = array();
  if (module_enabled('schools')) {
    $test_school_options = schools_get_schools_for_fapi(TRUE, TRUE, 'user', TRUE);
  }

  $res = db_query("SELECT DISTINCT(b.major_code) FROM students a, student_degrees b, `degrees` c
                        WHERE a.cwid = b.student_id
                        AND b.major_code = c.major_code
                        AND school_id = ?
                        ORDER BY b.major_code ", array($test_school_id));
  while ($cur = db_fetch_array($res)) {
    if (trim($cur ["major_code"]) == "") 
     { // skip if blank
      continue;
    }


    if (count($test_school_options) <= 1) {
      $options [$cur ['major_code']] = trim(ucwords($cur ["major_code"]));
    }
    else {
      $options [$test_school_options [$test_school_id]][$cur ['major_code']] = trim(ucwords($cur ["major_code"]));
    }
  }

  $filter_major_value = @trim($_SESSION ['users_filter_major']);
  $form ['filter_major'] = array(
    'type' => 'select',
    'label' => t('Major:'),
    'options' => $options,
    'value' => $filter_major_value,
    'weight' => 20,
  );



  // Show list of active/inactive options
  $options = array();
  $options ['active'] = t('Show Active');
  $options ['inactive'] = t('Show Inactive');
  $options ['all'] = t('Show All');

  $filter_active_value = @$_SESSION ['users_filter_active'];
  $form ['filter_active'] = array(
    'type' => 'select',
    'label' => t('Active:'),
    'options' => $options,
    'hide_please_select' => TRUE,
    'value' => $filter_active_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;
}