function availability_calendars_get_states_inc in Availability Calendars 7.2
Implementation of availability_calendars_get_states (in .module)
Returns an array of records of all states. Optionally filtered by the is_available flag.
Parameters
boolean|NULL $is_available: Filter on is_available state (boolean) or do not filter at all (NULL (default)).
Return value
array Array of records keyed by the class.
1 call to availability_calendars_get_states_inc()
- availability_calendars_get_states in ./
availability_calendars.module - Returns an array of records of all states. Optionally filtered by the is_available flag.
File
- ./
availability_calendars.inc, line 194 - General helper methods for Availability Calendars, like database access and settings.
Code
function availability_calendars_get_states_inc($is_available) {
static $states = NULL;
if ($states === NULL) {
$states = db_select('availability_calendars_states')
->fields('availability_calendars_states')
->orderBy('weight')
->execute()
->fetchAllAssoc('class', PDO::FETCH_ASSOC);
array_walk($states, 'availability_calendars_convert_state');
}
if ($is_available === NULL) {
$result = $states;
}
else {
// Filter states by is_available flag.
$result = array();
foreach ($states as $class => $state) {
if ($state['is_available'] == $is_available) {
$result[$class] = $state;
}
}
}
return $result;
}