You are here

function classified_node_access in Classified Ads 6.3

Same name and namespace in other branches
  1. 7.3 classified.module \classified_node_access()

Implements the D7 hook_node_access().

1 call to classified_node_access()
classified_access in ./classified.module
Implements hook_access().

File

./classified.module, line 1157
A pure D6 classified ads module inspired by the ed_classified module.

Code

function classified_node_access($node, $op, $account) {

  // Admin bypasses checks
  if (user_access('administer classified ads', $account)) {
    return TRUE;
  }
  $ret = FALSE;
  switch ($op) {
    case 'create':
      $ret = user_access('create classified ad content', $account);
      break;
    case 'update':
      $ret = user_access('edit any classified ad content', $account) || user_access('edit own classified ad content', $account) && $account->uid == $node->uid;
      break;
    case 'delete':
      $ret = user_access('delete any classified ad content', $account) || user_access('delete own classified ad content', $account) && $account->uid == $node->uid;
      break;
    case 'view':

      // Core allows anyone with 'access content' to see published nodes, and
      // authenticated authors to see their unpublished nodes, which is exactly
      // what we want, so no need to interfere.
      $ret = NULL;
      break;
  }
  return $ret;
}