You are here

function _onepageprofile_check_access in One page profile 7

Same name and namespace in other branches
  1. 5.2 onepageprofile.module \_onepageprofile_check_access()
  2. 6 onepageprofile.module \_onepageprofile_check_access()

Check if access is allowed to this category by the user

We need to do this, instead of profile_category_access(), because we want integration with the profile_roles module.

File

./onepageprofile.module, line 208

Code

function _onepageprofile_check_access($account, $category) {
  $map = array(
    'user',
    $account,
    'edit',
    $category['name'],
  );

  // Check access by pretending our category is a menu item
  $category['access_callback'] = $category['access callback'];
  $category['access_arguments'] = serialize($category['access arguments']);
  _menu_check_access($category, $map);

  // Integrate with the profile_role module
  $menu['access'] = TRUE;
  if (function_exists('profile_role_access_category')) {
    $menu['access'] = profile_role_access_category($account, $category['name']);
  }
  return $menu['access'] && $category['access'];
}