function fp_get_departments
Search API
7.x misc.inc | fp_get_departments($school_id = 0, $bool_get_all_by_schools = FALSE) |
6.x misc.inc | fp_get_departments($school_id = 0, $bool_get_all_by_schools = FALSE) |
Returns an array (suitable for form api) of departments on campus which faculty/staff can be members of.
6 calls to fp_get_departments()
- calendar_appointment_settings_form in modules/
calendar/ calendar.module - Lets an admin user configure global settings regarding appointments in FlightPath
- calendar_display_schedule_staff_page in modules/
calendar/ calendar.module - This page (primarily meant for students) is for quickly finding your advisor or professor or whomever, and finding their link to schedule an appointment with them.
- stats_report_advisor_use in modules/
stats/ stats.module - This report shows which advisors are using FlightPath most often.
- user_display_users in modules/
user/ user.module - Display our list of faculty/staff users in the system.
- user_edit_user_form in modules/
user/ user.module - Let the user edit a user's roles and other information.
File
- includes/
misc.inc, line 150 - This file contains misc functions for FlightPath
Code
function fp_get_departments($school_id = 0, $bool_get_all_by_schools = FALSE) {
$rtn = array();
$cache_key = md5(serialize(func_get_args()));
// Get from cache if already loaded once this page load
if (isset($GLOBALS ['fp_cache_departments'][$cache_key])) {
return $GLOBALS ['fp_cache_departments'][$cache_key];
}
if (!$bool_get_all_by_schools) {
$val = variable_get_for_school('departments', '', $school_id);
$lines = explode("\n", $val);
foreach ($lines as $line) {
$line = trim($line);
if (!$line) {
continue;
}
$temp = explode("~", $line);
$rtn [trim($temp [0])] = trim($temp [1]);
}
}
else if (module_enabled('schools') && $bool_get_all_by_schools == TRUE) {
// We should return a multi-dimensional array where the school name is first, followed by dept_code.
// Ex: $rtn['SCHOOL_ABC']['ENGL'] = "English";
// We would need to go through all of our schools in a for loop first.
$schools = schools_get_school_definitions();
foreach ($schools as $school_id => $throw_away) {
$school_code = schools_get_school_code_for_id($school_id);
if ($school_id == 0) {
$school_code = "- Default -";
}
$val = variable_get_for_school('departments', '', $school_id);
$lines = explode("\n", $val);
foreach ($lines as $line) {
$line = trim($line);
if (!$line) {
continue;
}
$temp = explode("~", $line);
$rtn [$school_code][trim($temp [0])] = trim($temp [1]);
}
}
}
$GLOBALS ['fp_cache_departments'][$cache_key] = $rtn; // store in cache
return $rtn;
}