function uc_order_actions in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_order/uc_order.module \uc_order_actions()
- 5 uc_order/uc_order.module \uc_order_actions()
- 6.2 uc_order/uc_order.module \uc_order_actions()
Returns 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_handler_field_order_actions::render in uc_order/
views/ uc_order_handler_field_order_actions.inc - Overrides views_handler_field::render().
- 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 2081
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' => theme('image', array(
'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' => theme('image', array(
'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' => theme('image', array(
'path' => drupal_get_path('module', 'uc_store') . '/images/order_view.gif',
'alt' => $alt,
)),
'title' => $alt,
);
if (user_access('view own invoices')) {
$alt = t('Print order @order_id.', $order_id);
$actions[] = array(
'name' => t('Print'),
'url' => 'user/' . $user->uid . '/orders/' . $order->order_id . '/print',
'icon' => theme('image', array(
'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' => theme('image', array(
'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' => theme('image', array(
'path' => drupal_get_path('module', 'uc_store') . '/images/order_delete.gif',
'alt' => $alt,
)),
'title' => $alt,
);
}
$extra = module_invoke_all('uc_order_actions', $order);
if (count($extra)) {
$actions = array_merge($actions, $extra);
}
drupal_alter('uc_order_actions', $actions, $order);
if ($icon_html) {
$output = '';
foreach ($actions as $action) {
$action['classes'][] = 'uc-order-action';
if (empty($action['attributes'])) {
$action['attributes'] = array();
}
$action['attributes']['title'] = $action['title'];
$action['attributes']['class'] = implode(' ', $action['classes']);
$output .= l($action['icon'], $action['url'], array(
'attributes' => $action['attributes'],
'html' => TRUE,
));
}
return $output;
}
else {
return $actions;
}
}