Skip navigation
Help

uc_order_can_delete

6 uc_order.module uc_order_can_delete($order, $account = NULL)
7 uc_order.module uc_order_can_delete($order, $account = NULL)

Access callback for admin/store/orders/%uc_order/delete.

Returns TRUE if an order can be deleted by the current user.

4 calls to uc_order_can_delete()

1 string reference to 'uc_order_can_delete'

File

ubercart/uc_order/uc_order.module, line 2171
Handles all things concerning Ubercart orders.

Code

function uc_order_can_delete($order, $account = NULL) {
  if (user_access('unconditionally delete orders', $account)) {
    // Unconditional deletion perms are always TRUE.
    return TRUE;
  }
  elseif (user_access('delete orders', $account)) {
    // Only users with unconditional deletion perms can delete completed orders.
    $state = uc_order_status_data($order->order_status, 'state');
    if ($state == 'completed') {
      return FALSE;
    }
    else {
      $can_delete = TRUE;
      // See if any modules have a say in this order's eligibility for deletion.
      foreach (module_implements('uc_order') as $module) {
        $function = $module . '_uc_order';
        if (function_exists($function) && $function('can_delete', $order, NULL) === FALSE) {
          $can_delete = FALSE;
          break;
        }
      }

      return $can_delete;
    }
  }
  else {
    return FALSE;
  }
}