--- drupalchat.admin.inc	2011-02-24 21:13:57.000000000 -0500
+++ drupalchat.admin.inc	2011-05-26 16:18:56.000000000 -0400
@@ -1,4 +1,5 @@
 <?php
+//$Id: drupalchat.admin.inc,v 1.7 2011/01/06 20:17:02 darklrd Exp $
 /**
  * @file
  * Administrative functions to configure DrupalChat.
@@ -80,6 +81,9 @@
   if (module_exists('user_relationships_api')) {
     $form['drupalchat_rel']['#options'][DRUPALCHAT_REL_UR] = t('User Relationship module');
   }
+  if (module_exists('og')) {
+    $form['drupalchat_rel']['#options'][DRUPALCHAT_REL_OG] = t('Organic Groups module');
+  }
   if (module_exists('flag_friend')) {
     $form['drupalchat_rel']['#options'][DRUPALCHAT_REL_FF] = t('Flag Friend module');
   }
--- drupalchat.module	2011-02-24 21:13:57.000000000 -0500
+++ drupalchat.module	2011-05-26 17:31:40.000000000 -0400
@@ -1,4 +1,5 @@
 <?php 
+// $Id: drupalchat.module,v 1.24.2.2 2011/02/14 15:29:17 darklrd Exp $
 
 /**
  * @file
@@ -305,13 +306,21 @@
 	    $uid == $relationship->requester_id ? $users[] = $relationship->requestee_id : $users[] = $relationship->requester_id;
 	  }
   }
+elseif ($drupalchat_rel == DRUPALCHAT_REL_OG) {
+	$user = user_load(array("uid"=>$uid));
+	$og_array = array_keys($user->og_groups);
+	$og = implode("," , $og_array);
+	$results = db_query("SELECT DISTINCT uid AS uid FROM og_uid WHERE nid IN (" . $og . ") AND uid <> $uid");
+	 while ($result = db_fetch_object($results)) {
+      $users[] = $result->uid;
+    }
+  }
   elseif ($drupalchat_rel == DRUPALCHAT_REL_FF) {
     $result = db_query("SELECT * FROM {flag_friend} WHERE uid = %d OR friend_uid = %d", $uid, $uid);
     while ($friend = db_fetch_object($result)) {
       $uid == $friend->uid ? $users[] = $friend->friend_uid : $users[] = $friend->uid;
     }
   }
-  
 	return $users;
 }
 
@@ -319,7 +328,7 @@
 	global $user;
 	
 	$users = array();	 
-  if (variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH) > DRUPALCHAT_REL_AUTH) {
+  if (variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH) != 'DRUPALCHAT_REL_AUTH') {
     // Return empty on an empty buddylist
     if (empty($buddylist)) {
       $users['total'] = 0;
