You are here

function flag_flag::is_flagged in Flag 6

Same name and namespace in other branches
  1. 5 flag.inc \flag_flag::is_flagged()
  2. 6.2 flag.inc \flag_flag::is_flagged()
  3. 7.3 includes/flag/flag_flag.inc \flag_flag::is_flagged()
  4. 7.2 flag.inc \flag_flag::is_flagged()

Returns TRUE if a certain user has flagged this content.

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

Parameters

$uid: Optional. The user ID whose flags we're checking. If none given, the current user will be used.

File

./flag.inc, line 423
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 is_flagged($content_id, $uid = NULL) {
  $uid = !isset($uid) ? $GLOBALS['user']->uid : $uid;

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