You are here

function uc_order_status_list in Ubercart 7.3

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

Returns 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 status arrays or a string containing an array of status ids for use in a SQL query.

16 calls to uc_order_status_list()
uc_file_feature_settings in uc_file/uc_file.module
Form builder for file settings.
uc_order_action_update_status_options in uc_order/uc_order.rules.inc
Order status update context options.
uc_order_handler_filter_order_status::get_value_options in uc_order/views/uc_order_handler_filter_order_status.inc
Overrides views_handler_filter_in_operator::get_value_options().
uc_order_handler_filter_order_status::query in uc_order/views/uc_order_handler_filter_order_status.inc
Overrides views_handler_field::query().
uc_order_history in uc_order/uc_order.admin.inc
Returns the sortable table listing of a customer's orders.

... See full list

1 string reference to 'uc_order_status_list'
ca_data_map in uc_store/includes/ca.inc
Maps obsolete conditions to correct settings for 'data_is'.

File

uc_order/uc_order.module, line 1992

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 (:states)", array(
          ':states' => uc_order_state_list($scope, TRUE),
        ));
        break;
      default:
        $result = db_query("SELECT * FROM {uc_order_statuses} WHERE state = :scope", array(
          ':scope' => $scope,
        ));
        break;
    }
    $statuses[$scope] = array();
    while ($status = $result
      ->fetchAssoc()) {
      $status['id'] = $status['order_status_id'];
      unset($status['order_status_id']);
      if (function_exists('i18n_string')) {
        $status['title'] = i18n_string('uc_order_status:status:' . $status['id'] . ':title', $status['title']);
      }
      $statuses[$scope][] = $status;
    }
    usort($statuses[$scope], 'uc_weight_sort');
  }
  if ($sql) {
    $ids = array();
    foreach ($statuses[$scope] as $status) {
      $ids[] = $status['id'];
    }
    return $ids;
  }
  return $statuses[$scope];
}