You are here

function flag_flag_is_flagged_access_check in Flag 7.3

Check for access.

1 string reference to 'flag_flag_is_flagged_access_check'
flag_is_flagged.inc in plugins/access/flag_is_flagged/flag_is_flagged.inc

File

plugins/access/flag_is_flagged/flag_is_flagged.inc, line 85

Code

function flag_flag_is_flagged_access_check($conf, $context) {
  $flag = flag_get_flag($conf['flag_name']);
  if (!$flag || empty($context->data)) {
    return FALSE;
  }

  // Get the ID of the entity.
  list($id) = entity_extract_ids($flag->entity_type, $context->data);

  // Get either the count of users who have flagged this entity or find out
  // whether the current user has flagged this node, depending on settings.
  if (isset($conf['flag_user']) && $conf['flag_user'] == 'any') {
    $count = count(flag_get_entity_flags($flag->entity_type, $id, $conf['flag_name']));
    return $count;
  }
  else {
    return $flag
      ->is_flagged($id);
  }
}