You are here

function uc_order_status_list in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_order/uc_order.module \uc_order_status_list()
  2. 7.3 uc_order/uc_order.module \uc_order_status_list()

Return a sorted list of order statuses, sortable by order state/scope.

Parameters

$scope: Specify the scope for the order statuses you want listed - all, general, specific, or any order state id. Defaults to all.

$sql: Pass this parameter as TRUE to alter the return value for a SQL query.

@action: Empty by default. Set to rebuild to load the order statuses from scratch, disregarding the current cached value for the specified $scope.

Return value

Either an array of state arrays or a string containing an array of state ids for use in a SQL query.

25 calls to uc_order_status_list()
uc_file_feature_settings in uc_file/uc_file.module
Form builder for file settings
uc_get_addresses in uc_store/uc_store.module
uc_notify_order in uc_notify/uc_notify.module
Implementation of hook_order().
uc_order_action_update_status_form in uc_order/uc_order_workflow.inc
uc_order_admin in uc_order/uc_order.module
Display the main order admin screen, an overview of all received orders.

... See full list

File

uc_order/uc_order.module, line 3088

Code

function uc_order_status_list($scope = 'all', $sql = FALSE, $action = '') {
  static $statuses;
  if (!isset($statuses[$scope]) || $action == 'rebuild') {
    switch ($scope) {
      case 'all':
        $result = db_query("SELECT * FROM {uc_order_statuses}");
        break;
      case 'general':
      case 'specific':
        $result = db_query("SELECT * FROM {uc_order_statuses} WHERE state IN " . uc_order_state_list($scope, TRUE));
        break;
      default:
        $result = db_query("SELECT * FROM {uc_order_statuses} WHERE state = '%s'", $scope);
        break;
    }
    $statuses[$scope] = array();
    while ($status = db_fetch_array($result)) {
      $status['id'] = $status['order_status_id'];
      unset($status['order_status_id']);
      $statuses[$scope][] = $status;
    }
    usort($statuses[$scope], 'uc_weight_sort');
  }
  if ($sql) {
    foreach ($statuses[$scope] as $status) {
      $ids[] = $status['id'];
    }
    return "('" . implode("', '", $ids) . "')";
  }
  return $statuses[$scope];
}