Index: notifications_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/notifications/notifications_content/notifications_content.module,v
retrieving revision 1.4.2.9
diff -u -r1.4.2.9 notifications_content.module
--- notifications_content.module	13 Apr 2008 10:33:04 -0000	1.4.2.9
+++ notifications_content.module	21 Apr 2008 16:20:01 -0000
@@ -25,7 +25,9 @@
     );
   }
   else {
-    if ($user->uid && arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'notifications' && ($user->uid == arg(1) || user_access('administer notifications'))) {
+    if ($user->uid && arg(0) == 'user' &&
+        is_numeric(arg(1)) && arg(2) == 'notifications' &&
+        ($user->uid == arg(1) || user_access('administer notifications'))) {
       $account = ($user->uid == arg(1)) ? $user : user_load(array('uid' => arg(1)));
       $items[] = array(
         'path' => 'user/'. $account->uid .'/notifications/thread',
@@ -62,8 +64,19 @@
 /**
  * Implementation of hook_perm()
  */
-function notifications_content_perm() {
-  return array('subscribe to content', 'subscribe to content type', 'subscribe to author');
+function notifications_content_perm() {  
+  $perms = array(
+    'subscribe to content',
+    'subscribe to content type',
+    'subscribe to author'
+  );
+  
+  if(variable_get('notifications_content_types_perms', FALSE)) {    
+    foreach(notifications_content_types('type') as $key => $type) {
+      $perms[] = 'subscribe to '. $type .' content type';  
+    }
+  }
+  return $perms;
 }
 
 /**
@@ -77,7 +90,7 @@
     '#weight' => -10,
     '#collapsible' => TRUE,
   );
-
+  
   $form['content']['notifications_content_types'] = array(
     '#type'          => 'checkboxes',
     '#title'         => t('Allowed content types'),
@@ -86,6 +99,21 @@
     '#description'   => t('Select content types which should be <em>allowed</em> for subscriptions to content type.'),
     '#multiple'      => TRUE,
   );
+  
+  $form['permission_system'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('User Permission system'),
+    //'#description' => t('Integration with user permission system for managing content-type subscriptions'),
+    '#collapsible' => TRUE,   
+  );
+  
+  $form['permission_system']['notifications_content_types_perms'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable permission system integration'),
+    '#description' => t('Enabling this feature, subscribing to allowed content types will be managed using !user-permission',
+      array('!user-permission' => l(t('user permission'), 'admin/user/access', NULL, NULL, 'module-notifications_content'))),
+    '#default_value' => variable_get('notifications_content_types_perms', FALSE),
+  );
 
   return system_settings_form($form);
 }
@@ -464,9 +492,20 @@
     $account = $user;
   }
   // List of all subscribed node types
-  $subscriptions = notifications_get_subscriptions(array('type' => 'nodetype', 'uid' => $account->uid), array('type' => NULL), TRUE, 'value');
+  $subscriptions = notifications_get_subscriptions(
+   array(
+      'type' => 'nodetype',
+      'uid' => $account->uid),
+    array('type' => NULL),
+    TRUE,
+    'value');
   
   $types = notifications_content_types('name');
+  
+  if(variable_get('notifications_content_types_perms', FALSE)) {
+    $types = _notifications_content_types_allowed($types, $account);
+  }
+  
   if (!$types) {
     $output = t('There are no active content types.');    
   }
@@ -480,6 +519,21 @@
 }
 
 /**
+ * User allowed content types for subscriptions
+ * 
+ * @todo: use array passed by reference for perfermance issues?
+ * @author: thePanz#gmail.com
+ */
+function _notifications_content_types_allowed($types, &$user) {  
+  foreach($types as $key => $type) {
+    if(!user_access('subscribe to '. $type .' content type', $user)) {      
+      unset($types[$key]);
+    }
+  }  
+  return $types;
+}
+
+/**
  * User subscriptions to content types
  */
 function notifications_content_page_author($account = NULL) {
--- notification_content.intall
+++ notification_content.intall
@@ -0,0 +1,0 @@


