You are here

function flag_flag::get_flagging_record in Flag 7.2

Same name and namespace in other branches
  1. 6.2 flag.inc \flag_flag::get_flagging_record()
  2. 7.3 includes/flag/flag_flag.inc \flag_flag::get_flagging_record()

Returns the flagging record.

This method returns the "flagging record": the {flag_content} record that exists for each flagged item (for a certain user). If the item isn't flagged, returns NULL. This method could be useful, for example, when you want to find out the 'fcid' or 'timestamp' values.

Thanks to using a cache, inquiring several different flags about the same item results in only one SQL query.

Parameters are the same as is_flagged()'s.

1 call to flag_flag::get_flagging_record()
flag_flag::is_flagged in ./flag.inc
Determines if a certain user has flagged this content.

File

./flag.inc, line 754
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function get_flagging_record($content_id, $uid = NULL, $sid = NULL) {
  $uid = $this->global ? 0 : (!isset($uid) ? $GLOBALS['user']->uid : $uid);
  $sid = $this->global ? 0 : (!isset($sid) ? flag_get_sid($uid) : $sid);

  // flag_get_user_flags() does caching.
  $user_flags = flag_get_user_flags($this->content_type, $content_id, $uid, $sid);
  return isset($user_flags[$this->name]) ? $user_flags[$this->name] : NULL;
}