You are here

function og_quiz_user_access in OG Quiz 7

Helper function to check multiple permissions on all user groups. Returns null if no groups are available.

Parameters

stdClass $account:

string|array $permissions:

Return value

bool|null

2 calls to og_quiz_user_access()
og_quiz_access_my_result in ./og_quiz.module
Custom access callback for viewing own results.
og_quiz_user_results_access in ./og_quiz.module
Custom access callback for viewing user results tab

File

./og_quiz.module, line 369
Module hooks and custom logic.

Code

function og_quiz_user_access($account, $permissions) {
  $groups = og_get_entity_groups('user', $account);
  if (!empty($groups)) {
    if (is_string($permissions)) {
      $permissions = array(
        $permissions,
      );
    }
    foreach ($groups as $entity_type => $entity_groups) {
      foreach ($entity_groups as $etid => $gid) {
        foreach ($permissions as $permission) {
          if (og_user_access($entity_type, $gid, $permission, $account)) {
            return TRUE;
          }
        }
      }
    }
    return FALSE;
  }
  return NULL;
}