You are here

function _invoice_user_has_admin_access_to_invoice in Invoice 6

Same name and namespace in other branches
  1. 7 invoice_helpers.inc \_invoice_user_has_admin_access_to_invoice()

Returns if the user has access to administer the given invoice

Parameters

integer $invoice_id:

Return value

boolean

4 calls to _invoice_user_has_admin_access_to_invoice()
invoice_delete_item in ./invoice_ajax.inc
Delete an invoice item
invoice_edit_item in ./invoice_ajax.inc
Edit an invoice item
invoice_invoices in ./invoice.module
Overview of all invoices
invoice_save_item in ./invoice_ajax.inc
Add an invoice item

File

./invoice_helpers.inc, line 233
Invoice module

Code

function _invoice_user_has_admin_access_to_invoice($invoice_id) {
  $hasAccess = FALSE;
  if (empty($invoice_id)) {
    $hasAccess = TRUE;
  }
  else {
    if (user_access('administer invoices')) {
      $hasAccess = TRUE;
    }
    else {
      if (user_access('administer own invoices')) {
        $count = db_result(db_query("SELECT COUNT(*) AS count FROM {invoice_invoices} WHERE iid=%d AND uid=%d", $invoice_id, $GLOBALS['user']->uid));
        if ($count > 0) {
          $hasAccess = TRUE;
        }
      }
    }
  }
  return $hasAccess;
}