function schools_get_schools_for_fapi

7.x schools.module schools_get_schools_for_fapi($bool_include_default = TRUE, $bool_check_perm = FALSE, $check_perm_type = "degree", $bool_include_school_code = FALSE)
6.x schools.module schools_get_schools_for_fapi($bool_include_default = TRUE, $bool_check_perm = FALSE, $check_perm_type = "degree", $bool_include_school_code = FALSE)

Return a list of schools in an array, for use in the "options" of a select list in the Form API.

If $bool_check_perm is true, then we will check permissions before adding it to the array.

File

modules/schools/schools.module, line 540
Schools module.

Code

function schools_get_schools_for_fapi($bool_include_default = TRUE, $bool_check_perm = FALSE, $check_perm_type = "degree", $bool_include_school_code = FALSE) {

  $rtn = array();
  $defs = schools_get_school_definitions(TRUE);


  if ($bool_include_default) {
    $rtn [0] = t(' - Default -');
  }

  foreach ($defs as $school_id => $val) {

    $title = $val ['name'];
    if ($bool_include_school_code) {
      $title = $val ['school_code'] . ' - ' . $val ['name'];
    }

    if ($bool_check_perm) {
      if (user_has_permission('administer_' . $school_id . '_' . $check_perm_type . '_data') || user_has_permission('manage_' . $school_id . '_' . $check_perm_type . '_data')) {
        $rtn [$school_id] = $title;
      }
    }
    else {
      $rtn [$school_id] = $title;
    }

  }


  return $rtn;


}