You are here

function ad_node_access in Advertisement 7

Implementation of hook_node_access().

File

./ad.module, line 629

Code

function ad_node_access($node, $op, $account) {
  switch ($op) {
    case 'create':
      return user_access('create advertisements', $account) || user_access('administer advertisements');
    case 'update':
      return user_access('edit any advertisement', $account) || user_access('edit own advertisements', $account) && is_ad_owner($node->nid) || user_access('administer advertisements', $account);
    case 'delete':
      return user_access('delete any advertisement', $account) || user_access('delete own advertisements', $account) && is_ad_owner($node->nid) || user_access('administer advertisements', $account);
    case 'view':

      // Return false if user doesn't have basic permissions to view
      // advertisements.  Don't return true to let default Drupal
      // domain/node access checks happen.
      if (!user_access('show advertisements', $account) && !user_access('administer advertisements', $account)) {
        return false;
      }
  }
}