You are here

function uc_order_actions in Ubercart 5

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

Return the actions a user may perform on an order.

Parameters

$icon_html: Specify whether or not to return the result as an HTML string with the order action icon links.

Return value

Valid actions for an order; returned according to the $icon_html parameter.

3 calls to uc_order_actions()
uc_order_admin in uc_order/uc_order.module
Display the main order admin screen, an overview of all received orders.
uc_order_can_delete in uc_order/uc_order.module
Return TRUE if an order can be deleted by the current user.
uc_order_history in uc_order/uc_order.module
Returns the sortable table listing of a customer's orders.

File

uc_order/uc_order.module, line 3157

Code

function uc_order_actions($order, $icon_html = FALSE) {
  $state = uc_order_status_data($order->order_status, 'state');
  $order_id = array(
    '@order_id' => $order->order_id,
  );
  if (user_access('view all orders')) {
    $alt = t('View order @order_id.', $order_id);
    $actions[] = array(
      'name' => t('View'),
      'url' => 'admin/store/orders/' . $order->order_id,
      'icon' => '<img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/order_view.gif" alt="' . $alt . '" />',
      'title' => $alt,
    );
  }
  if (user_access('edit orders')) {
    $alt = t('Edit order @order_id.', $order_id);
    $actions[] = array(
      'name' => t('Edit'),
      'url' => 'admin/store/orders/' . $order->order_id . '/edit',
      'icon' => '<img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/order_edit.gif" alt="' . $alt . '" />',
      'title' => $alt,
    );
  }
  if (user_access('delete orders')) {
    $can_delete = TRUE;
    $return = module_invoke_all('order', 'can_delete', $order, NULL);
    if (!empty($return)) {
      foreach ($return as $response) {
        if ($response === FALSE) {
          $can_delete = FALSE;
        }
      }
    }
    if (user_access('delete any order') || $state != 'completed' && $can_delete) {
      $alt = t('Delete order @order_id.', $order_id);
      $actions[] = array(
        'name' => t('Delete'),
        'url' => 'admin/store/orders/' . $order->order_id . '/delete',
        'icon' => '<img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/order_delete.gif" alt="' . $alt . '" />',
        'title' => $alt,
      );
    }
  }
  $extra = module_invoke_all('order_actions', $order);
  if (count($extra)) {
    $actions = array_merge($actions, $extra);
  }
  if ($icon_html) {
    foreach ($actions as $action) {
      $output .= l($action['icon'], $action['url'], array(
        'title' => $action['title'],
      ), NULL, NULL, NULL, TRUE);
    }
    return $output;
  }
  else {
    return $actions;
  }
}