You are here

function votingapi_select_votes in Voting API 7.2

Same name and namespace in other branches
  1. 6.2 votingapi.module \votingapi_select_votes()
  2. 6 votingapi.module \votingapi_select_votes()

Select individual votes from the database.

Parameters

$criteria: A keyed array used to build the select query. Keys can contain a single value or an array of values to be matched. $criteria['vote_id'] (If this is set, all other keys are skipped) $criteria['entity_id'] $criteria['entity_type'] $criteria['value_type'] $criteria['tag'] $criteria['uid'] $criteria['vote_source'] $criteria['timestamp'] (If this is set, records with timestamps GREATER THAN the set value will be selected.)

$limit: An optional integer specifying the maximum number of votes to return.

Return value

An array of votes matching the criteria.

3 calls to votingapi_select_votes()
MigrateDestinationVotingApiVote::import in ./votingapi.migrate.inc
Derived classes must implement import(), to construct one new object (pre-pppulated using field mappings in the Migration). It is expected to call prepare and complete handlers, passing them $row (the raw data from the source).
votingapi_select_single_vote_value in ./votingapi.module
Retrieve the value of the first vote matching the criteria passed in.
votingapi_set_votes in ./votingapi.module
Cast a vote on a particular piece of content.

File

./votingapi.module, line 415
A generalized voting API for Drupal.

Code

function votingapi_select_votes($criteria = array(), $limit = 0) {
  $window = -1;
  if (empty($criteria['uid']) || $criteria['uid'] == 0) {
    if (!empty($criteria['vote_source'])) {
      $window = variable_get('votingapi_anonymous_window', 86400);
    }
  }
  else {
    $window = variable_get('votingapi_user_window', -1);
  }
  if ($window >= 0) {
    $criteria['timestamp'] = REQUEST_TIME - $window;
  }
  $function = variable_get('votingapi_storage_module', 'votingapi') . '_votingapi_storage_select_votes';
  return $function($criteria, $limit);
}