--- links_related.module.dist	2009-06-24 16:48:01.000000000 -0500
+++ links_related.module	2009-08-11 14:53:23.000000000 -0500
@@ -33,6 +33,13 @@ function links_related_help($section="")
   }
 }
 
+/*
+ * Implementation of hook_perm().
+ */
+function links_related_perm() {
+  return array('add related links');
+} // function links_related_perm()
+
 // **************** Node functions ***********************
 
 /**
@@ -190,7 +197,9 @@ function links_related_nodeapi(&$node, $
     case 'insert':
     case 'update':
       if (variable_get('links_related_types_'. $node->type, FALSE)) {
-        links_save_links_for_node($node, 'links_related');
+        if (user_access('add related links')) {
+          links_save_links_for_node($node, 'links_related');
+        }
       }
       break;
     case 'view':
@@ -233,39 +242,42 @@ function links_related_form_alter(&$form
       break;
 
     case $node->type .'_node_form':
-      // The actual node edit form. This allows the users to enter the
-      // links_related into appropriate node types' edit screens.
-      if (variable_get('links_related_types_'.$node->type, 0)) {
-        _links_related_sort_links($node->links_related);
-        $links =& $node->links_related;
-
-        $form['links_related'] = array(
-          '#type' => 'fieldset',
-          '#tree' => TRUE,
-          '#title' => t('Related Links'),
-          '#description' => t('Links are stored as part of the !page. Monitoring and dead link detection are centrally managed from there. <strong>To add more links, just click &quot;Preview&quot; to add another blank row. To remove a link from this article, just blank out its URL field or check the Delete box.</strong> If you blank out the title but leave the URL, then the system will suggest a title for you. The Weight allows you to determine the order in which links are displayed; lower numbers float to the top.',array('!page'=>l(t('links management feature'),'admin/content/links'))),
-          // Not collapsible if links are required
-          '#collapsible' => variable_get('links_related_types_'.$node->type, 0) < 2,
-          '#collapsed' => (count($links) == 0 && ! variable_get('links_related_always_expand',0)),
-          //'#weight' => -16,
-        );
-
-        $form['links_related']['#theme'] = 'links_related_form';
-        // Existing links first
-        $i = 0;
-        foreach ($links as $link) {
-          $form['links_related'][$i++] = links_related_form_line($link);
-        }
-        $blanks = variable_get('links_related_blank_lines','2');
-        for ($j=0; $j<$blanks; $j++) {
-          $form['links_related'][$i++] = links_related_form_line(NULL);
-        }
-        if (variable_get('links_related_types_'.$node->type, 0) >= 2) {
-          // The first one is required
-          $form['links_related'][0]['url']['#required'] = 1;
-          $form['links_related']['#title'] .= ' '.t('(at least one link required for this content type)');
+      if (user_access('add related links')) {
+        // The actual node edit form. This allows the users to enter the
+        // links_related into appropriate node types' edit screens.
+        if (variable_get('links_related_types_'.$node->type, 0)) {
+          _links_related_sort_links($node->links_related);
+          $links =& $node->links_related;
+
+          $form['links_related'] = array(
+            '#type' => 'fieldset',
+            '#tree' => TRUE,
+            '#title' => t('Related Links'),
+            '#description' => t('Links are stored as part of the !page. Monitoring and dead link detection are centrally managed from there. <strong>To add more links, just click &quot;Preview&quot; to add another blank row. To remove a link from this article, just blank out its URL field or check the Delete box.</strong> If you blank out the title but leave the URL, then the system will suggest a title for you. The Weight allows you to determine the order in which links are displayed; lower numbers float to the top.',array('!page'=>l(t('links management feature'),'admin/content/links'))),
+            // Not collapsible if links are required
+            '#collapsible' => variable_get('links_related_types_'.$node->type, 0) < 2,
+            '#collapsed' => (count($links) == 0 && ! variable_get('links_related_always_expand',0)),
+            //'#weight' => -16,
+          );
+
+          $form['links_related']['#theme'] = 'links_related_form';
+          // Existing links first
+          $i = 0;
+          foreach ($links as $link) {
+            $form['links_related'][$i++] = links_related_form_line($link);
+          }
+          $blanks = variable_get('links_related_blank_lines','2');
+          for ($j=0; $j<$blanks; $j++) {
+            $form['links_related'][$i++] = links_related_form_line(NULL);
+          }
+          if (variable_get('links_related_types_'.$node->type, 0) >= 2) {
+            // The first one is required
+            $form['links_related'][0]['url']['#required'] = 1;
+            $form['links_related']['#title'] .= ' '.t('(at least one link required for this content type)');
+          }
         }
-      }
+      } // if (user_access('add related links')) 
+      
       break;
   }
 }
