You are here

function quiz_access in Quiz 6.5

Same name and namespace in other branches
  1. 5.2 quiz.module \quiz_access()
  2. 5 quiz.module \quiz_access()
  3. 6.6 quiz.module \quiz_access()
  4. 6.2 quiz.module \quiz_access()
  5. 6.3 quiz.module \quiz_access()
  6. 6.4 quiz.module \quiz_access()
  7. 7.5 quiz.module \quiz_access()

Implementation of hook_access().

File

./quiz.module, line 98
Quiz Module

Code

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

  // Admin can do all of this.
  if (user_access('administer quiz', $account)) {
    return TRUE;
  }
  if (!user_access('access quiz')) {

    // If you can't access, you get NOTHING!
    // Otherwise, we allow further permission checking.
    return FALSE;
  }
  switch ($op) {
    case 'create':
      return user_access('create quiz', $account);
    case 'update':
      return user_access('edit any quiz', $account) || user_access('edit own quiz', $account) && $account->uid == $node->uid;
    case 'delete':
      return user_access('delete any quiz', $account) || user_access('delete own quiz', $account) && $account->uid == $node->uid;
  }
}