You are here

function uc_product_access in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_product/uc_product.module \uc_product_access()

Implementation of hook_access().

File

uc_product/uc_product.module, line 211
The product module for Ubercart.

Code

function uc_product_access($op, $node) {
  global $user;
  $type = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
  if ($type == 'product') {
    $type = '';
  }
  else {
    $type .= ' ';
  }
  switch ($op) {
    case 'create':
      return user_access('create ' . $type . 'products');
    case 'update':
    case 'delete':
      if (user_access('edit ' . $type . 'products') || user_access('edit own ' . $type . 'products') && $user->uid == $node->uid) {
        return TRUE;
      }
  }
}