Index: cck_field_privacy.install
===================================================================
--- cck_field_privacy.install	(revision 284)
+++ cck_field_privacy.install	(working copy)
@@ -28,7 +28,8 @@
       ),
       'permission' => array(
         'description' => t('TODO'),
-        'type' => 'char',
+        'type' => 'varchar',
+        'length' => 32,
         'not null' => TRUE,
       ),
     ),
@@ -123,4 +124,10 @@
   $weight = (int) db_result(db_query("SELECT weight FROM {system} WHERE name = 'fieldgroup'"));
   db_query("UPDATE {system} SET weight = %d WHERE name = 'cck_field_privacy'", $weight + 10);
   return $ret;
-}
\ No newline at end of file
+}
+
+function cck_field_privacy_update_6102(){
+  $ret = array();
+  db_change_field($ret, 'cckfp', 'permission', 'permission', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE));
+  return $ret;
+}
Index: cck_field_privacy.js
===================================================================
--- cck_field_privacy.js	(revision 284)
+++ cck_field_privacy.js	(working copy)
@@ -3,25 +3,28 @@
     if (typeof(Drupal) == 'undefined' || typeof(Drupal.settings) == 'undefined') return; // abort
 
     for (field_name in Drupal.settings.cck_field_privacy.default_value) {
-      $('#'+ field_name +'link').bind('click', cck_field_privacy.click); // bind padlock elements
+      $('#'+ field_name +'link').bind('click', cck_field_privacy.click); // bind padlock elements      
     }
   },
 
   click: function() {
     var field_name = $(this).attr('id').substr(0, $(this).attr('id').length-4),
-        field_state = Drupal.settings.cck_field_privacy.default_value[field_name];
-
+    field_state = Drupal.settings.cck_field_privacy.default_value[field_name];
+	console.log(field_state);
+	//get relationships
+    var rels = Drupal.settings.cck_field_privacy.relationships;
+	var radios = '';
+	for(var rel in rels){
+    	radios += "<div><label><input type='radio' value="+rels[rel]+" name='privacy' />"+rels[rel]+"</label></div>";
+    }
+    
     // display prompt
     var prompt = $.prompt(
       // @TODO: Output the list of privacy options in Drupal.settings.
       // @TODO: Make Buddies conditional based on module_exists('buddylist').
       //        then remove as a dependency.
-      // @TODO: Provide all available relationships when module_exists('user_relationships').
       '<p><strong>Privacy Settings</strong></p>'+
-      '<form>'+
-      '  <div><label><input type="radio" value="e" name="privacy" /> Everyone</label></div>'+
-      '  <div><label><input type="radio" value="b" name="privacy" /> Buddies</label></div>'+
-      '  <div><label><input type="radio" value="n" name="privacy" /> Nobody</label></div>'+
+      '<form>'+radios+
       '</form>', {
 
       overlayspeed: 'fast',
@@ -54,4 +57,8 @@
   }
 };
 
-$(cck_field_privacy.init); // onload
\ No newline at end of file
+
+Drupal.behaviors.cck_field_privacy = function(context){
+  $(cck_field_privacy.init); // onload
+}
+
Index: cck_field_privacy.module
===================================================================
--- cck_field_privacy.module	(revision 284)
+++ cck_field_privacy.module	(working copy)
@@ -80,7 +80,8 @@
   $items['admin/content/cck_field_privacy'] = array(
       'title' => 'Content field privacy',
       'description' => 'Configure field privacy controls.',
-      'page callback' => 'cck_field_privacy_admin_settings',
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('cck_field_privacy_admin_settings_form'),
       'access arguments' => array('administer cck field privacy'),
       'type' => MENU_NORMAL_ITEM,
     );
@@ -109,25 +110,25 @@
         return;
       }
       //Assume we are 'all clear' first, and see if anything changes that status
-			$access_clear = TRUE;
+	  $access_clear = TRUE;
       $type = $node->type;
       $result = db_query("SELECT field_name, permission FROM {cckfp} WHERE uid = %d AND type_name = '%s' ORDER BY field_name DESC", $node->uid, $node->type);
       if ($result) {
         while ($permissions = db_fetch_object($result)) {
-          if ($permissions->permission == 'b') {
- 						foreach (module_invoke_all('cck_field_privacy_access', $node_user, $user) as $access_result ) {
-					    if (!$access_result) {   
-								$access_clear=FALSE;
-    					}
-              continue; 
-            }
-          }
-          if ($permissions->permission == 'e') {
+          if ($permissions->permission == 'Everyone') {
             continue;
           }
-          if ($permissions->permission == 'n') {
+          if ($permissions->permission == 'Nobody') {
             $access_clear = FALSE;
           }
+          else{
+ 			foreach (module_invoke_all('cck_field_privacy_access', $node_user, $user, $permissions->permission) as $access_result ) {
+			  if (!$access_result) {   
+			    $access_clear=FALSE;
+    		  }
+              continue; 
+            }
+          }
           if ($access_clear == FALSE) {
             $field = $permissions->field_name;
             $node->$field['#access'] = FALSE;
@@ -185,7 +186,7 @@
                 if ($field_pref == "") {
                   //Get the default state of the field
                   $type_default_name = 'cckfp_' . $node_name .'_default';
-                  $field_pref = variable_get($type_default_name, 'e');
+                  $field_pref = variable_get($type_default_name, 'everyone');
                 }  
 
                 // Let's add the field name to the array of fields
@@ -215,7 +216,10 @@
           }
         }
       }
-
+      
+	  //retrieve the types of relationships available
+	  $rels = variable_get('cckfp_rel_type_options', 'everyone');
+	  
       // include javascript and css
       jquery_impromptu_add(); // css and js
       drupal_add_js(drupal_get_path('module', 'cck_field_privacy') .'/cck_field_privacy.js');
@@ -226,6 +230,7 @@
           'action' => url('cck_field_privacy/ajax'),
           'uid' => $uid,
           'content_type' => $node_name,
+          'relationships' => $rels,
           'default_value' => $cckfp_enabled_fields,
         ),
       ), 'setting');
@@ -250,6 +255,7 @@
       $field = $_POST['field'];
       $type = $_POST['type'];
       $setting = $_POST['setting'];
+      
       if ($userinfo != 'NULL' && $field != 'NULL' && $type != 'NULL' && $setting != 'NULL') {
         $sql = "INSERT INTO {cckfp} (uid, field_name, type_name, permission) VALUES(%d, '%s', '%s', '%s') ON DUPLICATE KEY UPDATE uid=%d, field_name='%s', type_name='%s', permission='%s'";
         $result = db_query($sql, $userinfo['uid'], $field, $type, $setting, $userinfo['uid'], $field, $type, $setting);
@@ -265,19 +271,12 @@
   exit;
 }
 
+
 /**
- * Page for the admin settings form.
+ * Creates the admin form Page.
  * Use this instead of standard settings for because
  * we serialize all the data into one variable.
  */
-function cck_field_privacy_admin_settings() {
-  $output = drupal_get_form('cck_field_privacy_admin_settings_form');
-  return $output;
-}
-
-/**
- * Creates the admin form.
- */
 function cck_field_privacy_admin_settings_form() {
   $form['field_perms'] = array(
     '#type' => 'fieldset',
@@ -328,13 +327,32 @@
               '#description' => t('Enable permissions on this field.'),
             );
           }
+         
+          $options = array(
+            'everyone' => t('Everyone'),
+			'nobody' => t('Nobody')
+          );
+          //if user relationship module exists grab the 
+          //relationship types
+          if(module_exists('user_relationships_api')){
+            module_load_include('inc', 'user_relationships_api', 'user_relationships_api.api');
+            $ur_types = user_relationships_types_load();
+            
+            //build options array for form.
+            foreach($ur_types as $rel){
+              $options[$rel->plural_name] = $rel->plural_name;
+            }    
+          }
           
+          //set what options are so we can retrieve them later in the modal dialog
+          variable_set('cckfp_rel_type_options', $options);
+          
           $form['field_fields'][$enabled_type]['cckfp_' . $enabled_type . '_default'] = array(
             '#type' => 'radios',
             '#title' => t('Default Value'),
             '#description' => t('You may choose a default privacy value for the fields in this content type.'),
-            '#default_value' => variable_get('cckfp_' . $enabled_type . '_default', 'e'),
-            '#options' => array('e' => t('Everyone'), 'b' => t('Buddies'), 'n' => t('Nobody')),
+            '#default_value' => variable_get('cckfp_' . $enabled_type . '_default', 'everyone'),
+            '#options' => $options,
             '#weight' => 1,
           );
         }
@@ -420,6 +438,7 @@
       variable_set($key, $value);
     }
   }
+  
   variable_set('cckfp_values', serialize($stored_values));
   drupal_set_message('Settings Changed.');
 }
\ No newline at end of file
