--- /user_relationships/plugins/user_relationship_views/user_relationship_views.module	2007-12-20 03:37:21.000000000 -0500
+++ /user_relationships/plugins/user_relationship_views/user_relationship_views.module	2008-01-31 16:15:00.000000000 -0500
@@ -62,6 +62,20 @@
         'notafield' => TRUE,
         'help'      => t('This will display the relationships between the current user and the author.'),
       ),
+     'number_relationships_to_author' => array(
+        'name'      => t("User Relationships: Number of Relationships held by Particular User"),
+        'handler'   => 'user_relationship_views_number_relationships_field_handler',
+        'option'    => array(
+          '#type'     => 'select',
+          '#options'  => array(
+           'both' => t('Both'),
+            1     => t('User is Requestee'),
+            0     => t('User is Requester')
+          ),
+        ),
+        'notafield' => TRUE,
+        'help'      => t('This will display the number of relationships held by a particular user. This may not accurately account for implied relationships'),
+      ),
       'approved' => array(
         'name' => t('User Relationships: Approval Status'),
         'handler' => 'user_relationship_views_approved_field_handler',
@@ -190,6 +204,35 @@
   return theme('user_relationships_approval_status', $value);
 }
 
+/**
+ * handler for displaying the number of relationships held by an author 
+ */
+function user_relationship_views_number_relationships_field_handler($field_info, $field_data, $value, $data) {
+  global $user;
+//query to lookup UID (likely can be improved)
+if (module_exists('usernode')) {
+$uidlookup = db_result(db_query("SELECT `uid` FROM `usernode` WHERE `nid` =".$data->nid, $data->nid));
+} else {
+//module has not be tested without usernode module 
+$uidlookup = $data->nid;
+}
+
+//query to count number of relationships
+//both
+if ($field_data['options'] = 'both') {
+	$relcount = db_num_rows(db_query("SELECT * FROM `user_relationships` WHERE `requestee_id` =".$uidlookup." OR `requester_id` =".$uidlookup." AND `approved` =1", $data->nid));
+}
+//requestee
+if ($field_data['options'] = '1') {
+	$relcount = db_num_rows(db_query("SELECT * FROM `user_relationships` WHERE `requestee_id` =".$uidlookup." AND `approved` =1", $data->nid));
+}
+//requester
+if ($field_data['options'] = '0') {
+	$relcount = db_num_rows(db_query("SELECT * FROM `user_relationships` WHERE `requester_id` =".$uidlookup." AND `approved` =1", $data->nid));
+}
+//I might have done a very poor job with the following line. This is my first time using arrays. Please look at it before you use this code.
+	return in_array($data->nid) ? (0) : $relcount;
+}
 
 /**
  * handler for displaying how the author relates to the current user
