You are here

function flag_get_content_flags in Flag 6

Same name and namespace in other branches
  1. 5 flag.module \flag_get_content_flags()
  2. 6.2 flag.module \flag_get_content_flags()
  3. 7.2 flag.module \flag_get_content_flags()

Return a list of users who have flagged a piece of content.

File

./flag.module, line 1049

Code

function flag_get_content_flags($content_type, $content_id, $reset = FALSE) {
  static $content_flags;
  if (!isset($content_flags[$content_type][$content_id]) || $reset) {
    $flag_names = _flag_get_flag_names();
    $result = db_query("SELECT * FROM {flag_content} WHERE content_type = '%s' AND content_id = %d ORDER BY timestamp DESC", $content_type, $content_id);
    while ($flag_content = db_fetch_object($result)) {
      $content_flags[$content_type][$content_id]['users'][$flag_content->uid][$flag_names[$flag_content->fid]] = $flag_content;
    }
  }
  return $content_flags[$content_type][$content_id]['users'];
}