function rss_permissions_feed_url_access in RSS Permissions 6
Same name and namespace in other branches
- 7 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_preprocess_page in ./
rss_permissions.module - Implementation of theme_preprocess_page(). Use regex to remove RSS link from HEAD, if the user has no permission for that feed.
- theme_rss_permissions_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 230
Code
function rss_permissions_feed_url_access($url) {
// Check against the global flag.
if (variable_get('rss_permissions_disable_all', FALSE)) {
return FALSE;
}
// Otherwise, check against granular permissions.
// Site's main RSS feed.
if (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]+)\\/([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');
}