function _regcode_voucher_accesscheck in Registration codes 6
Same name and namespace in other branches
- 6.2 regcode_voucher/regcode_voucher.module \_regcode_voucher_accesscheck()
- 7.2 regcode_voucher/regcode_voucher.module \_regcode_voucher_accesscheck()
- 7 regcode_voucher/regcode_voucher.module \_regcode_voucher_accesscheck()
Check whether an account has access to the voucher system
1 call to _regcode_voucher_accesscheck()
- regcode_voucher_user in regcode_voucher/
regcode_voucher.module - Implementation of hook_user().
1 string reference to '_regcode_voucher_accesscheck'
- regcode_voucher_menu in regcode_voucher/
regcode_voucher.module - Implementation of hook_menu().
File
- regcode_voucher/
regcode_voucher.module, line 197
Code
function _regcode_voucher_accesscheck($account, $context = '') {
// Pages enabled
$enabled = array_filter(variable_get('regcode_voucher_display', array()));
if (!in_array($context, $enabled)) {
return FALSE;
}
// Role based access
$allowed = array_filter(variable_get('regcode_voucher_allowed_roles', array()));
$disallowed = array_filter(variable_get('regcode_voucher_disallowed_roles', array()));
$access = FALSE;
foreach ($account->roles as $rid => $role) {
if (isset($allowed[$rid])) {
$access = TRUE;
}
}
foreach ($account->roles as $rid => $role) {
if (isset($disallowed[$rid])) {
$access = FALSE;
}
}
return $access;
}