Index: flag.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag/flag.module,v
retrieving revision 1.17
diff -u -F '^[^a-z]*function' -U 13 -r1.17 flag.module
--- flag.module	16 Aug 2010 20:45:18 -0000	1.17
+++ flag.module	20 Aug 2010 11:04:52 -0000
@@ -1635,74 +1635,74 @@ function flag_get_content_id($fcid) {
  *   Optional. The user ID whose flags we're checking. If none given, the
  *   current user will be used.
  * @param $sid
  *   Optional. The user SID (provided by Session API) whose flags we're
  *   checking. If none given, the current user will be used. The SID is 0 for
  *   logged in users.
  * @param $reset
  *   Reset the internal cache and execute the SQL query another time.
  *
  * @return $flags
  *   If returning a single node's flags, an array of the structure
  *   [name] => (fid => [fid], uid => [uid] nid => [nid], timestamp => [timestamp])
  *
- *   If returning all nodes, an array of the arrays for each node.
- *   [nid] => [name] => Object from above.
+ *   If returning all nodes, an array of the arrays for each flag.
+ *   [name] => [nid] => Object from above.
  *
  */
 function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $sid = NULL, $reset = FALSE) {
   static $flagged_content;
 
   if ($reset) {
     $flagged_content = array();
     if (!isset($content_type)) {
       return;
     }
   }
 
   $uid = !isset($uid) ? $GLOBALS['user']->uid : $uid;
   $sid = !isset($sid) ? flag_get_sid($uid) : $sid;
 
   if (isset($content_id)) {
-    if (!isset($flagged_content[$uid][$content_type][$content_id])) {
+    if (!isset($flagged_content[$uid][$sid][$content_type][$content_id])) {
       $flag_names = _flag_get_flag_names();
       $flagged_content[$uid][$sid][$content_type][$content_id] = array();
       $result = db_select('flag_content', 'fc')
         ->fields('fc')
         ->condition('content_type', $content_type)
         ->condition('content_id', $content_id)
         ->condition(db_or()
           ->condition('uid', $uid)
           ->condition('uid', 0)
         )
         ->condition('sid', $sid)
         ->execute();
 
       foreach ($result as $flag_content) {
         $flagged_content[$uid][$sid][$content_type][$content_id][$flag_names[$flag_content->fid]] = $flag_content;
       }
     }
     return $flagged_content[$uid][$sid][$content_type][$content_id];
   }
 
   else {
-    if (!isset($flagged_content[$uid][$sid]['all'][$content_type])) {
+    if (!isset($flagged_content[$uid][$sid][$content_type]['all'])) {
       $flag_names = _flag_get_flag_names();
-      $flagged_content[$uid][$sid]['all'][$content_type] = TRUE;
+      $flagged_content[$uid][$sid][$content_type]['all'] = array();
       $result = db_select('flag_content', 'fc')
         ->fields('fc')
         ->condition('content_type', $content_type)
         ->condition(db_or()
-          ->condition('uid', $account->uid)
+          ->condition('uid', $uid)
           ->condition('uid', 0)
         )
         ->condition('sid', $sid)
         ->execute();
       foreach ($result as $flag_content) {
         $flagged_content[$uid][$sid][$content_type]['all'][$flag_names[$flag_content->fid]][$flag_content->content_id] = $flag_content;
       }
     }
     return $flagged_content[$uid][$sid][$content_type]['all'];
   }
 
 }
 
