function _votingapi_cast_votes in Voting API 6.2
Same name and namespace in other branches
- 8.3 votingapi.drush.inc \_votingapi_cast_votes()
- 7.3 votingapi.drush.inc \_votingapi_cast_votes()
- 7.2 votingapi.devel.inc \_votingapi_cast_votes()
Utility function to generate votes on a node by a set of users.
1 call to _votingapi_cast_votes()
- votingapi_generate_votes in ./
votingapi.admin.inc - Utility function to generate votes.
File
- ./
votingapi.admin.inc, line 114 - Configuration forms and helper functions for VotingAPI module.
Code
function _votingapi_cast_votes($nid, $timestamp, $uids, $style) {
$votes = array();
foreach ($uids as $uid) {
switch ($style) {
case 'five':
if (rand(0, 2)) {
$votes[] = array(
'uid' => $uid,
'content_id' => $nid,
'value_type' => 'percent',
'timestamp' => time() - rand(0, time() - $timestamp),
'value' => rand(0, 5) * 20,
);
}
break;
case 'flag':
if (rand(0, 1)) {
$votes[] = array(
'uid' => $uid,
'content_id' => $nid,
'value_type' => 'points',
'timestamp' => time() - rand(0, time() - $timestamp),
'value' => 1,
);
}
break;
case 'updown':
if (rand(0, 3)) {
$votes[] = array(
'uid' => $uid,
'content_id' => $nid,
'value_type' => 'points',
'timestamp' => time() - rand(0, time() - $timestamp),
'value' => rand(0, 1) ? 1 : -1,
);
}
break;
}
}
votingapi_set_votes($votes, array());
}