You are here

function rss_permissions_feed_url_access in RSS Permissions 7

Same name and namespace in other branches
  1. 6 rss_permissions.module \rss_permissions_feed_url_access()

This function checks if user has permissions to view a given feed. The logic is slightly different from rss_permissions_menu_access, since we only have the feed URL to work with.

2 calls to rss_permissions_feed_url_access()
rss_permissions_html_head_alter in ./rss_permissions.module
Implementation of theme_html_head_alter(). Remove RSS link from HEAD, if the user has no permission for that feed.
rss_permissions_theme_feed_icon in ./rss_permissions.module
Overriding theme_feed_icon(). Check permission to view the feed before displaying the icon.

File

./rss_permissions.module, line 152

Code

function rss_permissions_feed_url_access($url) {
  global $base_url, $base_path;
  if (strstr($url, $base_url . $base_path)) {
    $url = str_replace($base_url, '', $url);
  }

  // Site's main RSS feed.
  if ('rss.xml' == $url || url('rss.xml', array(
    'absolute' => TRUE,
  )) == $url) {
    return user_access('access content') && user_access('access site RSS feed');
  }

  // Taxonomy RSS feeds.
  if (preg_match('/^.*taxonomy\\/term\\/([0-9]+)\\/feed$/i', $url, $matches) > 0) {
    return user_access('access content') && user_access('access taxonomy RSS feeds');
  }

  // Individual user blog RSS feeds.
  if (preg_match('/^.*blog\\/([0-9]+)\\/feed$/i', $url, $matches) > 0) {
    $blog_uid = $matches[1];
    $account = user_load($blog_uid);
    return blog_page_user_access($account) && user_access('access user blog RSS feeds');
  }

  // Main blog RSS feed.
  if (url('blog/feed') == $url) {
    return user_access('access content') && user_access('access main blog RSS feed');
  }

  // Aggregator RSS feeds.
  if (strpos($url, 'aggregator/rss') != FALSE || url('aggregator/opml') == $url) {
    return user_access('access news feeds') && user_access('access aggregator RSS feeds');
  }

  // Just to be safe, fall back to a reasonable default.
  return user_access('access content');
}