You are here

function uc_order_actions in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_order/uc_order.module \uc_order_actions()
  2. 5 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.

2 calls to uc_order_actions()
uc_order_admin in uc_order/uc_order.admin.inc
Displays the main order admin screen, an overview of all received orders.
uc_order_history in uc_order/uc_order.admin.inc
Returns the sortable table listing of a customer's orders.

File

uc_order/uc_order.module, line 1885

Code

function uc_order_actions($order, $icon_html = FALSE) {
  global $user;
  $state = uc_order_status_data($order->order_status, 'state');
  $order_id = array(
    '@order_id' => $order->order_id,
  );
  $actions = array();
  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,
    );
    $alt = t('Print order @order_id.', $order_id);
    $actions[] = array(
      'name' => t('Print'),
      'url' => 'admin/store/orders/' . $order->order_id . '/invoice/print',
      'icon' => '<img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/print.gif" alt="' . $alt . '" />',
      'title' => $alt,
    );
  }
  elseif (user_access('view own orders') && $order->uid == $user->uid) {
    $alt = t('View order @order_id.', $order_id);
    $actions[] = array(
      'name' => t('View'),
      'url' => 'user/' . $user->uid . '/orders/' . $order->order_id,
      'icon' => '<img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/order_view.gif" alt="' . $alt . '" />',
      'title' => $alt,
    );
    if (variable_get('uc_cust_view_order_invoices', TRUE)) {
      $alt = t('Print order @order_id.', $order_id);
      $actions[] = array(
        'name' => t('Print'),
        'url' => 'user/' . $user->uid . '/orders/' . $order->order_id . '/print',
        'icon' => '<img src="' . base_path() . drupal_get_path('module', 'uc_store') . '/images/print.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 (uc_order_can_delete($order)) {
    $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) {
    $output = '';
    foreach ($actions as $action) {
      $output .= l($action['icon'], $action['url'], array(
        'attributes' => array(
          'class' => 'uc-order-action',
          'title' => $action['title'],
        ),
        'html' => TRUE,
      ));
    }
    return $output;
  }
  else {
    return $actions;
  }
}