Index: subscriptions.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/subscriptions/subscriptions.module,v
retrieving revision 1.62.2.45.2.2
diff -up -r1.62.2.45.2.2 subscriptions.module
--- subscriptions.module	21 Jul 2007 21:15:01 -0000	1.62.2.45.2.2
+++ subscriptions.module	22 Jul 2007 18:49:20 -0000
@@ -250,57 +250,81 @@ function subscriptions_menu($may_cache) 
 
   if (variable_get('subscriptions_usersmenu', 1) && arg(0) == 'user' && is_numeric(arg(1))) {
     $account = user_load(array('uid' => arg(1)));
-
+    $dft_index = count($items);
+    $dft_set = 0;
+    
     // User subscription pages
-    if (($user->uid == $account->uid) || user_access('admin users subscriptions')) {
+    if (($user->uid == $account->uid && user_access('maintain own subscriptions')) || user_access('admin users subscriptions')) {
       $items[] = array(
         'path' => "user/". arg(1) ."/subscriptions",
         'title' => t('Subscriptions'),
         'callback' => 'subscriptions_page',
-        'access' => user_access('maintain own subscriptions'),
+        'access' => true,
         'type' => MENU_LOCAL_TASK,
-        'callback arguments' => array(arg(1), "content"),
+        'callback arguments' => array(arg(1), "maintain"),
       );
       // User Subscriptions submenus
+      // comment subscription
+      if ($access = user_access('subscribe to content', $account)) {
+        if (++$dft_set == 1) {
+          $items[$dft_index]['callback arguments'][1] = "content";
+        }
+      }
+      $items[] = array(
+        'path' => "user/". arg(1) ."/subscriptions/node",
+        'title' => t('threads'),
+        'callback' => 'subscriptions_page',
+        'access' => $access,
+        'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
+        'weight' => -1,
+        'callback arguments' => array(arg(1), "content"),
+      );
+
+      // blog subscription
       if (module_exists('blog')) {
+        if ($access = user_access('subscribe to blogs', $account)) {
+          if (++$dft_set == 1) {
+            $items[$dft_index]['callback arguments'][1] = "blogs";
+          }
+        }
         $items[] = array(
           'path' => "user/". arg(1) ."/subscriptions/blogs",
           'title' => t('blogs'),
           'callback' => 'subscriptions_page',
-          'access' => user_access('subscribe to blogs'),
-          'type' => MENU_LOCAL_TASK,
+          'access' => $access,
+          'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
           'callback arguments' => array(arg(1), "blogs"),
         );
       }
 
-      // comment subscription
-      $items[] = array(
-        'path' => "user/". arg(1) ."/subscriptions/node",
-        'title' => t('threads'),
-        'callback' => 'subscriptions_page',
-        'access' => user_access('subscribe to content'),
-        'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1,
-        'callback arguments' => array(arg(1), "content"),
-      );
-
       // Content type subscription
+      if ($access = user_access('subscribe to content types', $account)) {
+        if (++$dft_set == 1) {
+          $items[$dft_index]['callback arguments'][1] = "type";
+        }
+      }
       $items[] = array(
         'path' => "user/". arg(1) ."/subscriptions/type",
         'title' => t('content types'),
         'callback' => 'subscriptions_page',
-        'access' => user_access('subscribe to content types'),
-        'type' => MENU_LOCAL_TASK,
+        'access' => $access,
+        'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
         'callback arguments' => array(arg(1), "type"),
       );
 
       // Taxonomy subscription
       if (module_exists('taxonomy')) {
+        if ($access = user_access('subscribe to taxonomy terms', $account)) {
+          if (++$dft_set == 1) {
+            $items[$dft_index]['callback arguments'][1] = "taxonomy";
+          }
+        }
         $items[] = array(
           'path' => "user/". arg(1) ."/subscriptions/taxonomy",
           'title' => t('categories'),
           'callback' => 'subscriptions_page',
-          'access' => user_access('subscribe to taxonomy terms'),
-          'type' => MENU_LOCAL_TASK,
+          'access' => $access,
+          'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
           'callback arguments' => array(arg(1), "taxonomy"),
         );
       }
@@ -318,57 +342,80 @@ function subscriptions_menu($may_cache) 
   }
 
   // My subscriptions pages
-  if ($may_cache) {
+  if ($may_cache && user_access('maintain own subscriptions')) {
+    $dft_index = count($items);
+    $dft_set = 0;
+    
     $items[] = array(
       'path' => 'subscriptions',
       'title' => t('My subscriptions'),
-      'access' => user_access('subscribe to content'),
+      'access' => true,
       'callback' => 'subscriptions_page',
       'type' => MENU_NORMAL_ITEM,
-      'callback arguments' => array($user->uid, "content"),
+      'callback arguments' => array($user->uid, "maintain"),
     );
 
     // comment subscription
+    if ($access = user_access('subscribe to content')) {
+      if (++$dft_set == 1) {
+        $items[$dft_index]['callback arguments'][1] = "content";
+      }
+    }
     $items[] = array(
       'path' => "subscriptions/node",
       'title' => t('threads'),
       'callback' => 'subscriptions_page',
-      'access' => user_access('subscribe to content'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
+      'access' => $access,
+      'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
       'weight' => -1,
       'callback arguments' => array($user->uid, "content"),
     );
 
     // User Subscriptions submenus
     if (module_exists('blog')) {
+      if ($access = user_access('subscribe to blogs')) {
+        if (++$dft_set == 1) {
+          $items[$dft_index]['callback arguments'][1] = "blogs";
+        }
+      }
       $items[] = array(
         'path' => "subscriptions/blogs",
         'title' => t('blogs'),
         'callback' => 'subscriptions_page',
-        'access' => user_access('subscribe to blogs'),
-        'type' => MENU_LOCAL_TASK,
+        'access' => $access,
+        'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
         'callback arguments' => array($user->uid, "blogs"),
       );
     }
 
     // Content type subscription
+    if ($access = user_access('subscribe to content types')) {
+      if (++$dft_set == 1) {
+        $items[$dft_index]['callback arguments'][1] = "type";
+      }
+    }
     $items[] = array(
       'path' => "subscriptions/type",
       'title' => t('content types'),
       'callback' => 'subscriptions_page',
-      'access' => user_access('subscribe to content types'),
-      'type' => MENU_LOCAL_TASK,
+      'access' => $access,
+      'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
       'callback arguments' => array($user->uid, "type"),
     );
 
     // Taxonomy subscription
     if (module_exists('taxonomy')) {
+      if ($access = user_access('subscribe to taxonomy terms')) {
+        if (++$dft_set == 1) {
+          $items[$dft_index]['callback arguments'][1] = "taxonomy";
+        }
+      }
       $items[] = array(
         'path' => "subscriptions/taxonomy",
         'title' => t('categories'),
         'callback' => 'subscriptions_page',
-        'access' => user_access('subscribe to taxonomy terms'),
-        'type' => MENU_LOCAL_TASK,
+        'access' => $access,
+        'type' => (($access && ($dft_set == 1)) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK),
         'callback arguments' => array($user->uid, "taxonomy"),
       );
     }
@@ -1058,7 +1105,16 @@ function subscriptions_add($sid, $uid, $
 
 
 /**
- * query to get list of subscibed nodes
+ * return no permissions form
+ */
+function subscriptions_no_permissions() {
+  $subsrows['subform'] = array('#value' => t('You have no subscription permissions enabled!'));
+  return $subsrows;
+}
+
+
+/**
+ * query to get list of subscribed nodes
  *
  */
 function subscriptions_nodes($account = NULL) {
@@ -1458,6 +1514,10 @@ function subscriptions_page($uid, $displ
     default:
       // set output by type
       switch ($display_type) {
+        case 'maintain':
+          $output = drupal_get_form('subscriptions_no_permissions');
+          break;
+          
         case 'blogs':
           $output = subscriptions_blogs($account);
           break;
