commit 34d895a4dc28544fd2d89dcde7ba6e149969cbac
Author: Scott Reynolds <scott@parentsclick.com>
Date:   Mon Feb 22 09:09:57 2010 -0800

    use hook_profile_alter for flag friend
    http://drupal.org/node/721994

diff --git flag_friend.module flag_friend.module
index 3946792..a614402 100644
--- flag_friend.module
+++ flag_friend.module
@@ -212,16 +212,6 @@ function flag_friend_user($op, &$edit, &$account, $category = NULL) {
         return $form;
       }
       break;
-    case 'view':
-      global $user;
-      // Remove link if we're looking at our own so we cannot friend ourself
-      $flag = flag_get_flag('friend');
-      if ($user->uid == $account->uid) {
-        if ($account->content['flags'][$flag->name]) {
-          unset($account->content['flags'][$flag->name]);
-        }
-      }
-      break;
     case 'delete':
       // remove any friend relationships if an account is removed
       db_query("DELETE FROM {flag_friend} WHERE uid = %d OR friend_uid = %d", $account->uid, $account->uid);
@@ -230,6 +220,18 @@ function flag_friend_user($op, &$edit, &$account, $category = NULL) {
 }
 
 /**
+ * Implementation of hook_profile_alter().
+ */
+function flag_friend_profile_alter(&$account) {
+  if ($account->uid == $GLOBALS['user']->uid) {
+    $flag = flag_get_flag('friend');
+    if (!empty($flag) && isset($account->content['flags'][$flag->name])) {
+      unset($account->content['flags'][$flag->name]);
+    }
+  }
+}
+
+/**
  * Create a denial link.
  *
  * @param $type
