You are here

function flag_rules_action_fetch_users in Flag 7.2

Same name and namespace in other branches
  1. 7.3 flag.rules.inc \flag_rules_action_fetch_users()

Base action implementation: Fetch users who flagged an entity.

1 string reference to 'flag_rules_action_fetch_users'
flag_rules_action_info in ./flag.rules.inc
Implements hook_rules_action_info().

File

./flag.rules.inc, line 314
Rules integration for the Flag module.

Code

function flag_rules_action_fetch_users($flag, $entity) {
  $result = db_select('flag_content', 'fc')
    ->fields('fc', array(
    'uid',
  ))
    ->condition('content_type', $flag->content_type)
    ->condition('content_id', $flag
    ->get_content_id($entity))
    ->condition('fid', $flag->fid)
    ->execute();
  $uids = $result
    ->fetchCol();

  // Filter out anonymous users.
  return array(
    'users' => array_filter($uids),
  );
}