diff --git a/relatedlinks.module b/relatedlinks.module index 891aa90..ab8855f 100644 --- a/relatedlinks.module +++ b/relatedlinks.module @@ -527,16 +527,36 @@ function _relatedlinks_filter($links) { $url_cache = array(); foreach ($links as $link) { - if (!in_array($link['url'], $url_cache)) { + if ( !in_array($link['url'], $url_cache) + && strpos($link['url'],'mailto:')=== false ) { //added by ht to not load mailto links if (empty($link['title'])) { // URLs without a title display the URL. $link['title'] = $link['url']; } + $url_cache[] = $link['url']; // Parsed links have already been through the wringer prior to insert. $title = $link['type'] == RELATEDLINKS_PARSED ? $link['title'] : check_plain($link['title']); - $urls[] = ''. $title .''; + // Check if user has permission to view internal links + if (strpos($link['url'], 'http') === false) { //Make sure this is internal link + $path = $link['url']; + $normal_path = drupal_get_normal_path($path); + + if (substr($normal_path, 0, 5) == 'node/') { + if(is_numeric(substr($normal_path, 5))) { + $nid = substr($normal_path, 5); + $node = node_load($nid); + if (node_access("view", $node)) { + // User can view this node. + $urls[] = ''. $title .''; + } + } + } + } + else { //Always let external links through + $urls[] = ''. $title .''; + } } }