class VotingApi_Criteria in Voting API 7.3
Criteria to select VotingApi_Votes
This is basically the same as VotingApi_Vote except that timestamp is interpreted as the vote-rollover.
Hierarchy
- class \VotingApi_Vote
- class \VotingApi_Criteria
Expanded class hierarchy of VotingApi_Criteria
File
- ./
votingapi.module, line 91 - A generalized voting API for Drupal.
View source
class VotingApi_Criteria extends VotingApi_Vote {
public function __construct($data) {
parent::__construct($data);
if ($this->uid != 0) {
$this->vote_source = NULL;
}
$this
->calculateWindow();
}
/**
* Calculate the correct timestamp for the vote-rollover.
*/
protected function calculateWindow() {
$window = -1;
if ($this->uid == 0) {
if (!empty($this->vote_source)) {
$window = variable_get('votingapi_anonymous_window', 86400);
}
}
else {
$window = variable_get('votingapi_user_window', -1);
}
if ($window >= 0) {
$this->timestamp = REQUEST_TIME - $window;
}
}
/**
* Select individual votes from the database.
*
* @param $limit
* An optional integer specifying the maximum number of votes to return.
* @return
* An array of votes matching the criteria.
*/
public function select($limit = 0) {
return VotingApi_VoteStorage::get()
->selectVotes($this, $limit);
}
/**
* Delete all matching votes.
*/
public function delete() {
VotingApi_Vote::deleteMultiple($this
->select());
}
public static function byEntity($entity_type, $entity_ids) {
$class = get_called_class();
return new $class(array(
'entity_type' => $entity_type,
'entity_id' => $entity_ids,
));
}
/**
* Retrieve the value of the first vote matching the criteria.
*/
public function singleValue() {
$results = $this
->select();
return $results[0]->value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
VotingApi_Criteria:: |
public static | function | ||
VotingApi_Criteria:: |
protected | function | Calculate the correct timestamp for the vote-rollover. | |
VotingApi_Criteria:: |
public | function | Delete all matching votes. | |
VotingApi_Criteria:: |
public | function | Select individual votes from the database. | |
VotingApi_Criteria:: |
public | function | Retrieve the value of the first vote matching the criteria. | |
VotingApi_Criteria:: |
public | function |
Overrides VotingApi_Vote:: |
|
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public | property | ||
VotingApi_Vote:: |
public static | function | Delete votes from the database. | |
VotingApi_Vote:: |
public | function | ||
VotingApi_Vote:: |
public static | function | Save a collection of votes to the database. |