diff --git a/plugins/user_relationship_private_nodes/user_relationship_private_nodes.info b/plugins/user_relationship_private_nodes/user_relationship_private_nodes.info
new file mode 100644
index 0000000..eee9f9b
--- /dev/null
+++ b/plugins/user_relationship_private_nodes/user_relationship_private_nodes.info
@@ -0,0 +1,5 @@
+; $Id$
+name = User Relationship Private Nodes
+description = "Provides per node access control based on relationship to author"
+dependencies = user_relationships
+package = "User Relationships"
diff --git a/plugins/user_relationship_private_nodes/user_relationship_private_nodes.install b/plugins/user_relationship_private_nodes/user_relationship_private_nodes.install
new file mode 100644
index 0000000..d0823c2
--- /dev/null
+++ b/plugins/user_relationship_private_nodes/user_relationship_private_nodes.install
@@ -0,0 +1,29 @@
+<?php
+// $Id$
+
+function user_relationship_private_nodes_install() {
+
+	switch($GLOBALS['db_type']) {
+		case 'mysql':
+		case 'mysqli':
+
+			db_query("
+				CREATE TABLE {user_relationship_private_nodes} (
+					nid int(10) unsigned NOT NULL,
+					rtids varchar(255) NOT NULL,
+					PRIMARY KEY  (nid)
+				)
+			");
+			break;
+
+		case 'pgsql':
+			break;
+	}
+}
+
+
+function user_relationship_private_nodes_uninstall() {
+
+  db_query('DROP TABLE {user_relationship_private_nodes}');
+}
+
diff --git a/plugins/user_relationship_private_nodes/user_relationship_private_nodes.module b/plugins/user_relationship_private_nodes/user_relationship_private_nodes.module
new file mode 100644
index 0000000..6ad0226
--- /dev/null
+++ b/plugins/user_relationship_private_nodes/user_relationship_private_nodes.module
@@ -0,0 +1,157 @@
+<?php
+// $Id$
+// Copyright (C) 2008 Jonathan Brown
+// http://openpackage.biz/
+
+
+function user_relationship_private_nodes_enable() {
+	node_access_rebuild();
+}
+
+
+function user_relationship_private_nodes_disabling($set = NULL) {
+	static $disabling = FALSE;
+
+	if($set !== NULL) {
+		$disabling = $set;
+	}
+
+	return $disabling;
+}
+
+
+function user_relationship_private_nodes_disable() {
+	user_relationship_private_nodes_disabling(TRUE);
+	node_access_rebuild();
+}
+
+
+function user_relationship_private_nodes_form_alter($form_id, &$form) {
+
+	if(is_null($form['type']) || $form['type']['#value'] .'_node_form' != $form_id)
+  	return;
+
+	$types = user_relationships_types_load();
+
+	if(!count($types))
+		return;
+		
+	foreach($types as $rtid => $type)
+		$types[$rtid] = $type->plural_name;
+		
+	asort($types);
+	
+	$description = "If no box is ticked, then anyone can view.";
+
+	$form['user_relationship_types'] = array(
+		'#type' => 'checkboxes',
+		'#multiple' => TRUE,
+		'#options' => $types,
+		'#title' => t('Only show to'),
+		'#default_value' => $form['#node']->user_relationship_types,
+		'#description' => t($description)
+	); 
+}
+
+
+function user_relationship_private_nodes_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+
+	switch($op) {
+
+		case 'insert':
+		case 'update':
+		
+			foreach($node->user_relationship_types as $key => $value) {
+				if(!$value)
+					unset($node->user_relationship_types[$key]);
+			}
+		
+			$rtids = serialize($node->user_relationship_types);
+		
+			db_query("
+				INSERT INTO {user_relationship_private_nodes}
+				SET nid = %d,
+					rtids = '%s'
+				ON DUPLICATE KEY UPDATE rtids = '%s'
+			",
+				$node->nid,
+				$rtids,
+				$rtids
+			);
+			break;
+
+		case 'load':
+			$node->user_relationship_types = unserialize(db_result(db_query("
+				SELECT rtids
+				FROM {user_relationship_private_nodes}
+				WHERE nid = %d
+			",
+				$node->nid
+			)));
+			break;
+
+		case 'delete':
+			db_query("
+				DELETE FROM {user_relationship_private_nodes}
+				WHERE nid = %d
+			",
+				$node->nid
+			);
+			break;
+	}
+}
+
+
+function user_relationship_private_nodes_node_grants($user, $op) {
+	if($op != 'view')
+		return;
+
+
+	// get this user's relationships
+	
+	$relationships = user_relationships_load(array(
+		'requester_id' => $user->uid,
+		'approved' => TRUE
+	));
+	
+  foreach($relationships as $relationship) {
+		$grants['user_relationship_type_' . $relationship->rtid][] = $relationship->requestee_id;
+	}
+
+	$grants['user_relationship_author'] = array($user->uid);
+
+	return $grants;
+}
+
+
+function user_relationship_private_nodes_node_access_records($node) {
+	if(user_relationship_private_nodes_disabling()) {
+		return;
+	}
+
+	if(is_array($node->user_relationship_types)) {
+		foreach($node->user_relationship_types as $rtid) {
+
+			$grants[] = array(
+				'realm' => 'user_relationship_type_' . $rtid,
+				'gid' => $node->uid,
+				'grant_view' => TRUE,
+				'grant_update' => FALSE,
+				'grant_delete' => FALSE
+			);
+		}
+	}
+
+	if(count($grants)) {
+		$grants[] = array(
+			'realm' => 'user_relationship_author', 
+			'gid' => $node->uid, 
+			'grant_view' => TRUE, 
+			'grant_update' => FALSE, 
+			'grant_delete' => FALSE
+		);
+	}
+		
+	return $grants;
+}
+
diff --git a/user_relationships_api.inc b/user_relationships_api.inc
