From b805f9dc80d8025222b47e57714a8fed10448b85 Mon Sep 17 00:00:00 2001
From: Sascha Grossenbacher <saschagros+test@gmail.com>
Date: Sun, 13 Mar 2011 17:29:36 +0100
Subject: [PATCH 1/2] by Berdir: Remove call to deleted function, update documentation.

---
 user_relationship_blocks/README.txt                |    5 ++---
 .../user_relationship_blocks.module                |    1 -
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/user_relationship_blocks/README.txt b/user_relationship_blocks/README.txt
index b0a61cb..1eae28b 100644
--- a/user_relationship_blocks/README.txt
+++ b/user_relationship_blocks/README.txt
@@ -47,9 +47,8 @@ User Relationships: {Relationship Type}
 
 
 * A note about the user being viewed:
-  This user is found using a PHP function. It can be configured per block to be specific to your site.
-  This is for more expert users (and is really only needed by expert users). You can find the current
-  default code in the "_user_relationship_blocks_find_user_php" function in "user_relationship_blocks.module"
+  This user is found using _user_relationship_blocks_get_uid(). This can be
+  overriden by implementhing hook_user_relationship_blocks_get_uid().
 
 
 Theme Developers
diff --git a/user_relationship_blocks/user_relationship_blocks.module b/user_relationship_blocks/user_relationship_blocks.module
index 77aa189..599da4b 100644
--- a/user_relationship_blocks/user_relationship_blocks.module
+++ b/user_relationship_blocks/user_relationship_blocks.module
@@ -350,7 +350,6 @@ function _user_relationship_blocks_insert_defaults() {
           'bid' => $bid,
           'size' => 10,
           'sort' => 'newest',
-          'get_account' => _user_relationship_blocks_find_user_php(),
         ))
         ->execute();
     }
-- 
1.7.4.1


From 6ece086270bd82284c0ddb0c0e011835ef3ccdc3 Mon Sep 17 00:00:00 2001
From: Sascha Grossenbacher <saschagros+test@gmail.com>
Date: Sun, 13 Mar 2011 17:30:16 +0100
Subject: [PATCH 2/2] Issue #1081410 by Berdir: Fixed issues when there are remaining role configurations for deleted user relationship types.

---
 .../user_relationships_api.api.inc                 |   26 +++++++++----------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/user_relationships_api/user_relationships_api.api.inc b/user_relationships_api/user_relationships_api.api.inc
index e055a90..05222d4 100644
--- a/user_relationships_api/user_relationships_api.api.inc
+++ b/user_relationships_api/user_relationships_api.api.inc
@@ -61,34 +61,32 @@ function user_relationships_type_load($param = array(), $reset = NULL) {
 
 
 /**
- * Public API for loading the full list of relationship types.
+ * Load all relationship types.
  *
  * @param $reset
- *    a boolean that forces a reset of the internal static types list
+ *   A boolean that forces a reset of the internal static types list
  *
  * @return
- *    array of relationship_type objects
+ *   Array of relationship_type objects
  */
 function user_relationships_types_load($reset = NULL) {
   static $relationship_types_list = array();
 
   if ($reset || empty($relationship_types_list)) {
-    //clear the cached list, since some relationships may have disappeared
+    // Clear the cached list, since some relationships may have disappeared.
     $relationship_types_list = db_query("SELECT * FROM {user_relationship_types}")->fetchAllAssoc('rtid');
-    //load role permissions for all types
-    $result = db_query('SELECT rtid, rid FROM {user_relationship_type_roles} ORDER BY rtid, rid');
+    // Load role permissions for all types.
+    $result = db_query('SELECT rtid, rid FROM {user_relationship_type_roles} WHERE rtid IN (:rtids) ORDER BY rtid, rid', array(':rtids' => array_keys($relationship_types_list)));
     foreach ($result as $mapping) {
-      $rtype = $relationship_types_list[$mapping->rtid];
-      // //roles is an associative array {role id} => {role id}
-      $rtype->roles[$mapping->rid] = $mapping->rid;//] = $mapping->name;
+      // roles is an associative array {role id} => {role id}.
+      $relationship_types_list[$mapping->rtid]->roles[$mapping->rid] = $mapping->rid;//] = $mapping->name;
     }
 
-    //load role receive permissions for all types
-    $results = db_query('SELECT rtid, rid FROM {user_relationship_type_roles_receive} ORDER BY rtid, rid');
+    // Load role receive permissions for all types.
+    $results = db_query('SELECT rtid, rid FROM {user_relationship_type_roles_receive} WHERE rtid IN (:rtids) ORDER BY rtid, rid', array(':rtids' => array_keys($relationship_types_list)));
     foreach ($results as $mapping) {
-      $rtype = $relationship_types_list[$mapping->rtid];
-      // //roles is an associative array {role id} => {role id}
-      $rtype->roles_receive[$mapping->rid] = $mapping->rid;//] = $mapping->name;
+      // roles_receive is an associative array {role id} => {role id}.
+      $relationship_types_list[$mapping->rtid]->roles_receive[$mapping->rid] = $mapping->rid;
     }
   }
 
-- 
1.7.4.1

