function og_quiz_ogs_access in OG Quiz 7
Helper function to check multiple permissions on all node groups. Returns null if no groups are available.
Parameters
stdClass $node:
string|array $permissions:
stdClass $account = NULL:
Return value
bool|null
8 calls to og_quiz_ogs_access()
- og_quiz_access_results in ./
og_quiz.module - Custom access callback for accessing quiz results.
- og_quiz_form_quiz_results_manage_results_form_alter in ./
og_quiz.module - Implements hook_form_quiz_results_manage_results_form_alter().
- og_quiz_get_user_results in ./
og_quiz.module - Page callback for viewing user results. Filter by courses the viewer is actually a member of.
- og_quiz_node_view in ./
og_quiz.module - Implements hook_node_view().
- og_quiz_take_access in ./
og_quiz.module - Custom access callback for taking quiz.
File
- ./
og_quiz.module, line 333 - Module hooks and custom logic.
Code
function og_quiz_ogs_access($node, $permissions, $account = NULL) {
$groups = og_get_entity_groups('node', $node);
if (!empty($groups)) {
if (is_string($permissions)) {
$permissions = array(
$permissions,
);
}
if (!isset($account)) {
global $user;
$account = clone $user;
}
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;
}