function casetracker_case_state_load in Case Tracker 7
Same name and namespace in other branches
- 5 casetracker.module \casetracker_case_state_load()
- 6 casetracker.module \casetracker_case_state_load()
Returns information about the various case states and their options. The number of parameters passed will determine the return value.
Parameters
$csid: Optional; the state ID to return from the passed $realm.
$realm: Optional; the name of the realm ('status', 'priority', or 'type').
$reset: Optional; set to TRUE to reset the static cache.
Return value
$values If only $realm is passed, you'll receive an array with the keys being the state ID and the values being their names. If a $csid is also passed, you'll receive just a string of the state name. If ONLY a $csid is passed, we'll return a list of 'name', 'realm'.
9 calls to casetracker_case_state_load()
- CasetrackerAdminTest::testCasetrackerAdminCreation in tests/
casetracker_admin.test - Main test routine.
- casetracker_realm_load in ./
casetracker.module - Load states for a particular realm. Wrapper around casetracker_case_state_load()
- casetracker_views_handler_field_priority_name::render in includes/
casetracker_views_handler_field_priority_name.inc - Render the field.
- casetracker_views_handler_field_status_name::render in includes/
casetracker_views_handler_field_status_name.inc - Render the field.
- casetracker_views_handler_field_type_name::render in includes/
casetracker_views_handler_field_type_name.inc - Render the field.
File
- ./
casetracker.module, line 774 - Enables the handling of projects and their cases.
Code
function casetracker_case_state_load($csid = NULL, $realm = NULL, $reset = FALSE) {
static $states_lookup;
if (!$states_lookup || $reset) {
$results = db_select('casetracker_case_states', 'c');
$results
->addField('c', 'csid');
$results
->addField('c', 'case_state_name', 'name');
$results
->addField('c', 'case_state_realm', 'realm');
$results
->addField('c', 'weight');
$results
->orderBy('c.weight');
$results = $results
->execute();
$types = node_type_get_types();
$states_lookup = array();
foreach ($results as $row) {
$row->display = casetracker_tt("case_states:{$row->csid}:name", $row->name);
$states_lookup[$row->realm][$row->csid] = $states_lookup['all'][$row->csid] = $row;
}
}
if ($csid && $realm) {
return isset($states_lookup['all'][$csid]->display) ? $states_lookup['all'][$csid]->display : '';
}
elseif ($csid && !$realm) {
return isset($states_lookup['all'][$csid]) ? $states_lookup['all'][$csid] : new stdClass(array(
'name' => '',
'realm' => '',
));
}
elseif (!$csid && $realm) {
$options = array();
// suitable for form api.
if (!empty($states_lookup[$realm])) {
foreach ($states_lookup[$realm] as $state) {
$options[$state->csid] = $state->display;
}
}
return $options;
}
}