function _regcode_voucher_accesscheck in Registration codes 7
Same name and namespace in other branches
- 6.2 regcode_voucher/regcode_voucher.module \_regcode_voucher_accesscheck()
 - 6 regcode_voucher/regcode_voucher.module \_regcode_voucher_accesscheck()
 - 7.2 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_form_user_profile_form_alter in regcode_voucher/
regcode_voucher.module  - Implements hook_form_FORM_ID_alter().
 
1 string reference to '_regcode_voucher_accesscheck'
- regcode_voucher_menu in regcode_voucher/
regcode_voucher.module  - Implements hook_menu().
 
File
- regcode_voucher/
regcode_voucher.module, line 213  - Main code and hooks for regcode voucher module.
 
Code
function _regcode_voucher_accesscheck($account, $context = '') {
  // Do not show for other users.
  global $user;
  if ($account->uid != $user->uid) {
    return FALSE;
  }
  // 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;
}