Index: restricted_content.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/restricted_content/restricted_content.admin.inc,v
retrieving revision 1.3
diff -u -p -r1.3 restricted_content.admin.inc
--- restricted_content.admin.inc	3 Jan 2009 07:05:20 -0000	1.3
+++ restricted_content.admin.inc	24 Feb 2011 21:47:25 -0000
@@ -14,7 +14,12 @@ function restricted_content_settings_for
     '#default_value' => restricted_content_var('message_anon'),
     '#wysiyg' => FALSE,
   );
-
+  $form['restricted_content_message_accessible'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Message to display for users with access to restricted content'),
+    '#default_value' => restricted_content_var('message_accessible'),
+    '#wysiyg' => FALSE,
+  );
   if (module_exists('token')) {
     $form['tokens'] = array(
       '#value' => theme('token_help', 'node'),
Index: restricted_content.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/restricted_content/restricted_content.info,v
retrieving revision 1.2
diff -u -p -r1.2 restricted_content.info
--- restricted_content.info	3 Jan 2009 07:05:20 -0000	1.2
+++ restricted_content.info	24 Feb 2011 21:47:25 -0000
@@ -4,3 +4,10 @@ description = Restrict content access fo
 core = 6.x
 package = Access control
 suggests[] = token
+
+; Information added by drupal.org packaging script on 2010-07-11
+version = "6.x-1.x-dev"
+core = "6.x"
+project = "restricted_content"
+datestamp = "1278835503"
+
Index: restricted_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/restricted_content/restricted_content.module,v
retrieving revision 1.13
diff -u -p -r1.13 restricted_content.module
--- restricted_content.module	27 Nov 2009 00:03:49 -0000	1.13
+++ restricted_content.module	24 Feb 2011 21:47:25 -0000
@@ -27,10 +27,11 @@ function restricted_content_menu() {
  * Implementation of hook_form_alter().
  */
 function restricted_content_form_alter(&$form, $form_state, $form_id) {
+  $nid = $form['nid']['#value']; //modified http://drupal.org/node/826350
   if ($form_id == 'node_type_form') {
     //restricted_content_node_form($form);
   }
-  elseif ($form['#id'] == 'node-form') {
+elseif ($form['#id'] == 'node-form' && isset($nid)) {
     $default = unserialize(db_result(db_query("SELECT rids FROM {restricted_content} WHERE nid = %d", $form['nid']['#value'])));
     restricted_content_node_form($form, $default);
     $form['#submit'][] = 'restricted_content_node_form_submit';
@@ -95,29 +96,63 @@ function restricted_content_node_access(
 
 function restricted_content_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
   global $user;
-
+  
+  //delete when restricted content no longer set
   if ($op == 'delete') {
+     drupal_set_message("Time to Delete");
     db_query("DELETE FROM {restricted_content} WHERE nid = %d", $node->nid);
   }
-  elseif ($op == 'alter' && !restricted_content_form_access($node->uid) && !restricted_content_node_access($node->nid)) {
-    $message = restricted_content_var('message');
+  
+  //NOTE: Removed check for admin restricted menu for testing
+  //User has access to node because of role and the node is restricted
+  if ($op == 'alter' && restricted_content_node_access($node->nid) && restricted_check($node->nid)) {
+      
+    $message = restricted_content_var('message_accessible');
     $node->restricted = TRUE;
     $node->comment = COMMENT_NODE_DISABLED;
 
+    // Perform token replacement if token module is available.
+    if (module_exists('token')) {
+      $message = token_replace($message, 'node', $node);
+    }
+    
+//    $new_combo_teaser = theme('display_restriction', $message, $content, "accessible");    
+    
+    if ($node->teaser) {
+      $node->teaser = theme('display_restriction', $message, "accessible", $node->teaser);
+    }
+
+    if ($node->body) {
+        $node->body = theme('display_restriction', $message, "accessible", $node->body);
+      }
+     }    
+     
+   //user does not have access to page either because or role or because anonymous
+  if ($op == 'alter' && !restricted_content_form_access($node->uid) && !restricted_content_node_access($node->nid)) {
+
+    $message = restricted_content_var('message');
+    $node->restricted = TRUE;
+    $node->comment = COMMENT_NODE_DISABLED;
+  
     // Add a register link of the user is anonymous and can register for an
     // account.
     if (!$user->uid && variable_get('user_register', 1)) {
       $message .= ' '. restricted_content_var('message_anon');
     }
-
+  
     // Perform token replacement if token module is available.
     if (module_exists('token')) {
       $message = token_replace($message, 'node', $node);
     }
+  
+    if ($node->teaser) {
+      $node->teaser = theme('display_restriction', $message, "restricted");
+    }
 
-    $node->teaser = $message;
-    $node->body = $message;
-  }
+    if ($node->body) {
+        $node->body = theme('display_restriction', $message, "restricted");
+    }
+          }
   /*elseif ($op == 'alter' && !empty($node->restricted)) {
     // Send a 403 if this is an individual page view.
     if ($page) {
@@ -144,6 +179,10 @@ function restricted_content_preprocess_n
  */
 function restricted_content_token_list($type = 'all') {
   $tokens['global']['site-register-url'] = t('The URL of the register user page');
+  $tokens['global']['restricted-content-message'] = t('Message to replace content for restricted users.');
+  $tokens['global']['restricted-content-message-anon'] = t('Additional message to display for restricted anonymous users.');
+  $tokens['global']['restricted-content-message-accessible'] = t('Message to display for users with access to restricted content.');
+
   if ($type == 'node' || $type == 'all') {
     $tokens['node']['type-name-lower'] = t('Node type (user-friendly version lowercased)');
   }
@@ -155,6 +194,10 @@ function restricted_content_token_list($
  */
 function restricted_content_token_values($type, $object = NULL) {
   $tokens['site-register-url'] = url('user/register');
+  $values['restricted-content-message'] =variable_get('restricted_content_message', 1);
+  $values['restricted-content-message-anon'] =variable_get('restricted_content_message_anon', 1);
+  $values['restricted-content-message-accessible'] =variable_get('restricted_content_message_accessible', 1);
+
   if ($type == 'node') {
     $tokens['type-name-lower'] = drupal_strtolower(node_get_types('name', $object));
   }
@@ -168,6 +211,7 @@ function restricted_content_variables() 
   return array(
     'restricted_content_message' => t('This !token-type-name has been restricted to certain users.', array('!token-type-name' => module_exists('token') ? '[type-name-lower]' : t('content'))),
     'restricted_content_message_anon' => t('Please <a href="!token-register">register for a user account</a> to view this !token-type-name.', array('!token-type-name' => module_exists('token') ? '[type-name-lower]' : t('content'), '!token-register' => module_exists('token') ? '[site-register-url]' : url('user/register'))),
+  'restricted_content_message_accessible' => t('You have special privileges to access this !token-type-name.', array('!token-type-name' => module_exists('token') ? '[type-name-lower]' : t('content'))),
   );
 }
 
@@ -188,3 +232,160 @@ function restricted_content_var($name, $
 
   return variable_get($name, isset($default) || !isset($defaults[$name]) ? $default : $defaults[$name]);
 }
+
+
+function restricted_check($nid) {
+    $query = "SELECT nid FROM {restricted_content} WHERE nid = '%d'";
+    $sql = db_query($query, $nid);
+      
+  if (db_affected_rows() > 0){
+     return TRUE;  
+   } 
+}
+
+
+/**
+ *  Implementation of hook_menu_link_alter().
+ *  Adds a restricted-content class to menu links
+ */
+
+function restricted_content_menu_link_alter(&$item, $menu) {
+  //if the node is marked as restricted add restricted content class
+   $path = explode('/', $item['link_path']);
+   $nid = $path[1];   
+  
+ if (restricted_check($nid)) {
+     $item['options']['attributes']['class'] = 'restricted-content';
+ }
+  else {
+     $item['options']['attributes']['class'] = '';      
+ }
+}
+
+/**
+ * Implementation of hook_action_info().
+ */
+function restricted_content_action_info() {
+  return array(
+    'restrict_content_action' => array(
+      'description' => t('Add restricted content conditions for a node'),
+      'configurable' => TRUE,
+      'type' => 'node',
+      'hooks' => array(
+        'nodeapi' => array('alter')
+      )
+    ),
+    'unrestrict_content_action' => array(
+      'description' => t('Remove restricted content conditions for a node'),
+      'type' => 'node',
+      'configurable' => FALSE,
+      'hooks' => array(
+        'nodeapi' => array('delete')
+      )
+    )
+  );
+}
+
+/**
+ * Action to restrict a node.
+ *
+ * @param $node
+ *   A node object.
+ * @param $context
+ *   An array providing more information about the context of the call to this action.
+ *
+ * @ingroup actions
+ * @see restrict_content_action_form()
+ * @see restrict_content_action_submit()
+ */
+function restrict_content_action($node, $context) {
+    // drupal_set_message(print_r($context['rids'], TRUE));
+  $rids = array_keys(array_filter($context['rids']));
+  db_query("DELETE FROM {restricted_content} WHERE nid = %d", $node->nid);
+  if ($rids) {
+    db_query("INSERT INTO {restricted_content} VALUES (%d, '%s')", $node->nid, serialize($rids));
+  }
+}
+
+/**
+ * Form builder; Prepare a form for selecting restricted roles.
+ *
+ * @ingroup forms
+ * @see restrict_content_action()
+ * @see restrict_content_action_submit()
+ */
+function restrict_content_action_form($context) {
+  $form = array();
+  $form['#node']->restricted_content = isset($context->restricted_content) ? $context->restricted_content : NULL;
+  $form['#node']->type = NULL;
+  restricted_content_node_form($form);
+  $form['restricted_content']['#weight'] = 0;
+  $form['restricted_content']['#collapsed'] = FALSE;
+  $form['restricted_content']['#description'] = t('The roles selected will be granted access to restricted content.');
+  return $form;
+}
+
+/**
+ * Process restrict_content_action_form form submissions.
+ *
+ * @see restrict_content_action()
+ */
+function restrict_content_action_submit($form, $form_state) {
+   return array('rids' => $form_state['values']['restricted_content']['rids']);
+}
+
+/**
+ * Action to unrestrict a node.
+ *
+ */
+function unrestrict_content_action($node, $context) {
+  if ($node->restricted = TRUE) {
+    $node->restricted_content['rids'] = $context->restricted_content['rids'];
+  }
+  module_invoke('restricted_content', 'nodeapi', $node, 'delete');
+}
+
+
+/**
+ * Implementation of hook_views_api().
+ */
+function restricted_content_views_api() {
+  return array(
+    'api' => 2,
+    'path' => drupal_get_path('module', 'restricted_content'),
+  );
+}
+
+
+/**
+ * Implementation of hook_theme().
+ */
+function restricted_content_theme() {
+    return array(
+        'display_restriction' => array(
+            'arguments' => array('message' => NULL, 'status' => NULL, 'content' => NULL))
+    );
+}
+
+/**
+* Theme function for theming quotes.
+*
+* @param $message
+* The message content as a string.
+* @param $status
+* The status of the restriction.
+* @param $content
+* The content to be appended to the message or removed
+* @return
+* An HTML themed string.
+*/
+function theme_display_restriction($message, $status, $content) {
+    $restriction_output = "<div id=\"restricted-text\" class=\"$status\">" . t($message) .'</div>';
+    
+    //appending $content when necessary
+    $restriction_output .= $content; 
+   
+  return $restriction_output;
+}
+
+
Index: restricted_content.views.inc
===================================================================
RCS file: restricted_content.views.inc
diff -N restricted_content.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ restricted_content.views.inc	24 Feb 2011 21:47:25 -0000
@@ -0,0 +1,48 @@
+<?php
+function restricted_content_views_data() {
+  $data = array();
+
+  $data['restricted_content']['table']['group'] = t('Node');
+
+  $data['restricted_content']['table']['join'] = array(
+    'node' => array(
+      'left_field' => 'nid',
+      'field' => 'nid',
+    ),
+    'restricted_content' => array(
+      'left_field' => 'nid',
+      'field' => 'nid',
+    ),
+  );
+
+  $data['restricted_content']['nid'] = array(
+    'title' => t('Restricted content'),
+    'help' => t('Whether or not the node is restricted.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'restricted_content_handler_bool',
+      'label' => t('Restricted'),
+      'type' => 'yes-no',
+    ),
+  );
+
+  return $data;
+
+}
+
+function restricted_content_views_handlers() {
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'restricted_content'),
+    ),
+    'handlers' => array(
+      'restricted_content_handler_bool' => array(
+        'parent' => 'views_handler_filter_boolean_operator',
+        'file' => 'restricted_content_handler_bool.inc',
+      ),
+    ),
+  );
+}
\ No newline at end of file
Index: restricted_content_handler_bool.inc
===================================================================
RCS file: restricted_content_handler_bool.inc
diff -N restricted_content_handler_bool.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ restricted_content_handler_bool.inc	24 Feb 2011 21:47:25 -0000
@@ -0,0 +1,10 @@
+<?php
+
+class restricted_content_handler_bool extends views_handler_filter_boolean_operator {
+  
+  function query() {
+    $this->ensure_my_table();
+    $qualified_name = "$this->table_alias.$this->real_field"; 
+    $this->query->add_where($this->options['group'], $qualified_name . (empty($this->value) ? " = 0 OR $qualified_name IS NULL" : ' IS NOT NULL'));
+  }
+}
\ No newline at end of file
