? .cvsignore
? fix_blocks.patch
Index: user_relationship_blocks/user_relationship_blocks.api.php
===================================================================
RCS file: user_relationship_blocks/user_relationship_blocks.api.php
diff -N user_relationship_blocks/user_relationship_blocks.api.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ user_relationship_blocks/user_relationship_blocks.api.php	10 Feb 2011 13:02:30 -0000
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @file
+ * API documentation for user_relationship_blocks module.
+ */
+
+/**
+ * Return the user that is currently displayed.
+ *
+ * @param $delta
+ *   The delta of the currently viewed block.
+ * 
+ * @return
+ *   The uid of the user currently displayed on this page, if any.
+ * 
+ */
+function hook_user_relationship_blocks_get_uid($delta) {
+  if (arg(0) = 'mypath') {
+    return arg(1);
+  }
+}
\ No newline at end of file
Index: user_relationship_blocks/user_relationship_blocks.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_relationships/user_relationship_blocks/Attic/user_relationship_blocks.install,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 user_relationship_blocks.install
--- user_relationship_blocks/user_relationship_blocks.install	14 Jan 2011 23:28:10 -0000	1.1.4.2
+++ user_relationship_blocks/user_relationship_blocks.install	10 Feb 2011 13:02:30 -0000
@@ -14,7 +14,6 @@ function user_relationship_blocks_schema
       'bid'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
       'size'        => array('type' => 'int', 'unsigned' => TRUE, 'default' => 10),
       'sort'        => array('type' => 'varchar', 'length' => 255, 'default' => 'newest'),
-      'get_account' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
     ),
     'primary key' => array('bid'),
   );
@@ -56,3 +55,10 @@ function user_relationship_blocks_update
   return $ret;
 }
 
+/**
+ * Drop unecessary get_account column.
+ */
+function user_relationship_blocks_update_7000() {
+  db_drop_field('user_relationship_blocks', 'get_account');
+}
+
Index: user_relationship_blocks/user_relationship_blocks.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_relationships/user_relationship_blocks/Attic/user_relationship_blocks.module,v
retrieving revision 1.1.4.3
diff -u -p -r1.1.4.3 user_relationship_blocks.module
--- user_relationship_blocks/user_relationship_blocks.module	9 Feb 2011 00:30:28 -0000	1.1.4.3
+++ user_relationship_blocks/user_relationship_blocks.module	10 Feb 2011 13:02:30 -0000
@@ -185,16 +185,6 @@ function user_relationship_blocks_block_
     '#type'   => 'hidden',
     '#value'  => $delta,
   );
-  $form['get_account'] = array(
-    '#type'           => 'textarea',
-    '#size'           => 4,
-    '#weight'         => 1,
-//    '#required'       => TRUE,
-    '#title'          => t('Return uid of the target user'),
-    '#description'    => t("(EXPERT ONLY) Enter a php snippet, surrounded by %php_snippet, which returns a numeric user id you want to work on. By default, for user pages, it is the user being viewed. For nodes or blogs, it is the node author. Clear the field to restore this default.", array('%php_snippet' => '<?php ?>')),
-    '#default_value'  => $settings->get_account,
-  );
-
   return $form;
 }
 
@@ -216,8 +206,7 @@ function user_relationship_blocks_block_
   }
   list($block_type, $rtid, $extra) = $exploded;
 
-
-  $is_my_block = ($block_type == UR_BLOCK_MY || $block_type == 'pending');
+  $is_my_block = ($block_type == UR_BLOCK_MY || in_array($block_type, array('pending')));
   if ($is_my_block && !$user->uid) {
     return;
   }
@@ -230,7 +219,7 @@ function user_relationship_blocks_block_
   if ($is_my_block && $user->uid) {
     $account = $user;
   }
-  else if (module_exists('php') && !empty($settings->get_account) && $uid = php_eval($settings->get_account)) {
+  else if ($uid = _user_relationship_blocks_get_uid($delta)) {
     $account = user_load($uid);
   }
 
@@ -245,21 +234,34 @@ function user_relationship_blocks_block_
 
 
 /**
- *  Default get_account php
- *  This will retrieve the author of the node being viewed or the user being viewed
- */
-function _user_relationship_blocks_find_user_php() {
-  return <<<PHP
-<?php
-  if (arg(0) == 'node' && is_numeric(arg(1))) {
-    \$node = node_load(arg(1));
-    return \$node->uid;
+ * Figure out which account is currently viewed.
+ *
+ * @param $delta
+ *   The delta of the block that is currently viewed.
+ *
+ * @return
+ *   Either the uid of the user owning the displayed profile, node or blog.
+ */
+function _user_relationship_blocks_get_uid($delta) {
+
+  // Call hook, this allows other modules to declare other ways to detect the
+  // currently viewed user.
+  foreach (module_implements('user_relationship_blocks_get_uid') as $module) {
+    $function = $module . '_user_relationship_blocks_get_uid';
+    if ($uid = $function($delta)) {
+      return $uid;
+    }
   }
-  else if ((arg(0) == 'user' || arg(0) == 'blog') && is_numeric(arg(1))) {
+
+  if ($node = menu_get_object()) {
+    return $node->uid;
+  }
+  if ($user = menu_get_object('user')) {
+    return $user->uid;
+  }
+  if (arg(0) == 'blog' && arg(1) > 0) {
     return arg(1);
   }
-?>
-PHP;
 }
 
 
@@ -317,10 +319,6 @@ function user_relationship_blocks_block_
   static $settings = array();
 
   if (isset($edit)) {
-    //can't find a better spot for this. If get_account php snippet is cleared by user, revert to default value
-    if (empty($edit['get_account'])) {
-      $edit['get_account'] = _user_relationship_blocks_find_user_php();
-    }
     if (empty($edit['bid'])) {
       $edit['bid'] = $edit['delta'];
     }
Index: user_relationship_blocks/templates/user_relationships-actions_block.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_relationships/user_relationship_blocks/templates/Attic/user_relationships-actions_block.tpl.php,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 user_relationships-actions_block.tpl.php
--- user_relationship_blocks/templates/user_relationships-actions_block.tpl.php	14 Jan 2011 23:28:10 -0000	1.1.4.2
+++ user_relationship_blocks/templates/user_relationships-actions_block.tpl.php	10 Feb 2011 13:02:30 -0000
@@ -7,7 +7,7 @@
  */
 $output = array();
 
-if ($current_relationships) {
+if (!empty($current_relationships)) {
   $output[] = theme('item_list', array('items' => $current_relationships, 'title' => t('Your relationships to this user'), 'attributes' => array('class' => 'user_relationships')));
 }
 
