--- carbon_footprint_orig.inc	2007-02-08 07:54:05.000000000 +0000
+++ carbon_footprint_patched.inc	2007-02-14 19:18:15.000000000 +0000
@@ -60,7 +60,12 @@ function carbon_footprint_page(&$map, $u
              "INNER JOIN {users} u ON n.uid = u.uid " .
              "WHERE (u.uid = %d " .          (empty($uid) ?  " OR 1) " : ") ").     // opt select by user 		
              "AND (f.organization = '%s' " . (empty($org) ?  " OR 1) " : ") ") ;    // opt select by org
-
+  
+  //if og_carbon is present, filter by organic group - sql condition
+  if(module_exist('og_carbon') && module_exist('og_basic')) {
+    $sql = og_carbon_sql($sql, 'condition');
+    }
+  
   // non admin users only permitted to see shared footprints and 
   // footprints from same group or public footprints. 
   // have to filter in the SQL in case there are a lot of records
@@ -75,7 +80,12 @@ function carbon_footprint_page(&$map, $u
              "    ) " ;
   $sql .=    "GROUP BY f.nid " ; 
   $sql .= tablesort_sql($header); 
-
+  
+  //if og_carbon is present, filter by organic group - sql rewrite
+  if(module_exist('og_carbon') && module_exist('og_basic')) {
+    $sql = og_carbon_sql($sql, 'rewrite');
+    }
+  
 //  drupal_set_message(" my sql ". $sql . " org:". $org. " uid:" . $uid, 'info'); 
     
   // get the links (no range limit here)
