function commerce_file_license_statuses in Commerce File 7
Returns an array of some or all of the statuses keyed by name.
Statuses can only be defined by modules but may have settings overridden that are stored in the database (weight and status). When this function is first called, it will load all the statuses as defined by hook_commerce_file_license_status_info() and update them based on the data in the database. The final array will be cached for subsequent calls.
Parameters
$conditions: An array of conditions to filter the returned list by; for example, if you specify 'state' => 'allowed' in the array, then only statuses in the allowed state would be included.
Return value
The array of status objects, keyed by status name.
6 calls to commerce_file_license_statuses()
- CommerceFileLicenseEntity::set_status in includes/
commerce_file_license.entity.inc - Status
- commerce_file_license_issue_by_host_form in includes/
commerce_file_license.forms.inc - Returns the base form array for issuing licenses on a host entity
- commerce_file_license_status_default in includes/
commerce_file.entities.inc - Return default status with highest weight
- commerce_file_license_status_get_title in includes/
commerce_file.entities.inc - Returns the human readable title of any or all statuses.
- commerce_file_license_status_load in includes/
commerce_file.entities.inc - Returns an status object.
File
- includes/
commerce_file.entities.inc, line 471 - Handles file licenses and file license logs
Code
function commerce_file_license_statuses($conditions = array()) {
// First check the static cache for an statuses array.
$statuses =& drupal_static(__FUNCTION__);
// If it did not exist, fetch the statuses now.
if (!isset($statuses)) {
$statuses = module_invoke_all('commerce_file_license_status_info');
// Merge in defaults.
foreach ($statuses as $name => &$status) {
$defaults = array(
'weight' => 0,
'enabled' => TRUE,
);
$status += $defaults;
}
unset($status);
// Give other modules a chance to alter the statuses.
drupal_alter('commerce_file_license_status_info', $statuses);
uasort($statuses, 'drupal_sort_weight');
}
// Apply conditions to the returned statuses if specified.
if (!empty($conditions)) {
$matching_statuses = array();
foreach ($statuses as $name => $status) {
// Check the status against the conditions array to determine whether to
// add it to the return array or not.
$valid = TRUE;
foreach ($conditions as $property => $value) {
// If the current value for the specified property on the pane does not
// match the filter value...
if (!isset($status[$property]) || $status[$property] != $value) {
// Do not add it to the temporary array.
$valid = FALSE;
}
}
if ($valid) {
$matching_statuses[$name] = $status;
}
}
return $matching_statuses;
}
return $statuses;
}