Index: flag_friend_access/flag_friend_access.info
===================================================================
RCS file: flag_friend_access/flag_friend_access.info
diff -N flag_friend_access.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ flag_friend_access.info	24 Mar 2009 19:35:28 -0000
@@ -0,0 +1,5 @@
+name = Flag friend access control
+description = Allows users to specify that only their friends can view this piece of content
+package = Flags
+dependencies[] = flag_friend
+core = 6.x
\ No newline at end of file
Index: flag_friend_access/flag_friend_access.module
===================================================================
RCS file: flag_friend_access/flag_friend_access.module
diff -N flag_friend_access.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ flag_friend_access.module	24 Mar 2009 19:35:28 -0000
@@ -0,0 +1,59 @@
+<?php
+// $Id:$
+
+/**
+ * @file: provides access control for nodes. Allow only the users friends to
+ * have access to it
+ */
+
+/**
+ * Implementation of hook_node_grants().
+ */
+function flag_friend_access_node_grants($account, $op) {
+  // module only controls view operations
+  if ($op == 'view') {
+    $friends = flag_friend_get_friends($account->uid);
+    $grants = array();
+    if (!empty($friends)) {
+      $grants['flag_friend'] = array_keys($friends);
+    }
+    return $grants;
+  }
+}
+
+/**
+ * Implementation of hook_node_access_records().
+ */
+function flag_friend_access_node_access_records($node) {
+  if ($node->flag_friend_access) {
+    return array(
+      array(
+        'realm' => 'flag_friend',
+        'gid' => $node->uid,
+        'grant_view' => 1,
+        'grant_update' => 0,
+        'grant_delete' => 0,
+        'priority' => 5,
+      ),
+    );
+  }
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function flag_friend_access_form_alter(&$form, &$form_state, $form_id) {
+  // add in a checkbox only if the 
+  if ($form['#node']->type . '_node_form' == $form_id && empty($form['#node']->nid)) {
+    // we have a node form alter in our stuff
+    $form['flag_friend_control'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Friend Access Control'),
+      '#collapsable' => FALSE,
+    );
+    $form['flag_friend_control']['flag_friend_access'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Only My Friends'),
+    );
+  }
+}
\ No newline at end of file
