You are here

function flag_flag::get_user_count in Flag 7.3

Same name and namespace in other branches
  1. 5 flag.inc \flag_flag::get_user_count()
  2. 6.2 flag.inc \flag_flag::get_user_count()
  3. 6 flag.inc \flag_flag::get_user_count()
  4. 7.2 flag.inc \flag_flag::get_user_count()

Returns the number of items a user has flagged.

For global flags, pass '0' as the user ID and session ID.

File

includes/flag/flag_flag.inc, line 1168
Contains the flag_flag class. Flag type classes use an 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_user_count($uid, $sid = NULL) {
  if (!isset($sid)) {
    $sid = flag_get_sid($uid);
  }
  return db_select('flagging', 'fc')
    ->fields('fc', array(
    'flagging_id',
  ))
    ->condition('fid', $this->fid)
    ->condition('uid', $uid)
    ->condition('sid', $sid)
    ->countQuery()
    ->execute()
    ->fetchField();
}