You are here

function rss_permissions_menu_access in RSS Permissions 6

Same name and namespace in other branches
  1. 7 rss_permissions.module \rss_permissions_menu_access()

Check permissions to access menu callbacks.

1 string reference to 'rss_permissions_menu_access'
rss_permissions_menu_alter in ./rss_permissions.module
Implementation of hook_menu_alter().

File

./rss_permissions.module, line 166

Code

function rss_permissions_menu_access($module) {

  // Do a blanket check fo the global flag here for every case except for
  // taxonomy, which uses the same menu callback for page and feed).
  $disable_all_feeds = variable_get('rss_permissions_disable_all', FALSE);
  if ($module != 'taxonomy') {
    if ($disable_all_feeds) {
      return FALSE;
    }
  }

  // Otherwise, check granular permissions.
  switch ($module) {

    // Main site RSS feed.
    case 'node':
      return user_access('access content') && user_access('access site RSS feed');
      break;

    // Taxonomy RSS feeds.
    // Taxonomy module uses the same menu callback both for page and feed.
    // Make sure we are on the feed page before overriding the access callback.
    case 'taxonomy':
      if (func_num_args() >= 2 && func_get_arg(1) == 'feed') {
        if ($disable_all_feeds) {
          return FALSE;
        }
        else {
          return user_access('access content') && user_access('access taxonomy RSS feeds');
        }
      }
      else {
        return user_access('access content');
      }
      break;

    // Individual user blog RSS feeds.
    case 'blog_user':
      $account = func_get_arg(1);
      return blog_page_user_access($account) && user_access('access user blog RSS feeds');
      break;

    // Main blog RSS feed.
    case 'blog':
      return user_access('access content') && user_access('access main blog RSS feed');
      break;

    // Aggregator RSS feeds.
    case 'aggregator':
      return user_access('access news feeds') && user_access('access aggregator RSS feeds');
      break;

    // Reasonable default.
    default:
      return user_access('access content');
  }
}