| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.module,v 1.13.2.60 2009/06/30 23:47:32 quicksketch Exp $ |
// $Id: fivestar.module,v 1.13.2.61 2009/06/30 23:58:17 quicksketch Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 697 |
exit($output); |
exit($output); |
| 698 |
} |
} |
| 699 |
|
|
| 700 |
$result = _fivestar_cast_vote($type, $cid, $value, $tag, NULL, TRUE); |
_fivestar_cast_vote($type, $cid, $value, $tag, TRUE); |
| 701 |
votingapi_recalculate_results($type, $cid); |
votingapi_recalculate_results($type, $cid); |
| 702 |
|
$result = fivestar_get_votes($type, $cid, $tag); |
| 703 |
|
|
| 704 |
if ($type == 'node') { |
if ($type == 'node') { |
| 705 |
$node = node_load($cid); |
$node = node_load($cid); |
| 742 |
* Internal function to handle vote casting, flood control, XSS, IP based |
* Internal function to handle vote casting, flood control, XSS, IP based |
| 743 |
* voting, etc... |
* voting, etc... |
| 744 |
*/ |
*/ |
| 745 |
function _fivestar_cast_vote($type, $cid, $value, $tag = NULL, $uid = NULL, $result = FALSE, $skip_validation = FALSE) { |
function _fivestar_cast_vote($type, $cid, $value, $tag = NULL, $uid = NULL, $skip_validation = FALSE) { |
| 746 |
global $user; |
global $user; |
| 747 |
$tag = empty($tag) ? 'vote' : $tag; |
$tag = empty($tag) ? 'vote' : $tag; |
| 748 |
$uid = empty($uid) ? $user->uid : $uid; |
$uid = empty($uid) ? $user->uid : $uid; |
| 766 |
|
|
| 767 |
if ($value == 0) { |
if ($value == 0) { |
| 768 |
votingapi_delete_votes($user_votes); |
votingapi_delete_votes($user_votes); |
| 769 |
|
return $user_votes[0]; |
| 770 |
} |
} |
| 771 |
else { |
else { |
| 772 |
$votes = $criteria += array('value' => $value); |
$votes = $criteria += array('value' => $value); |
| 773 |
votingapi_set_votes($votes, $user_votes); |
votingapi_set_votes($votes, $user_votes); |
| 774 |
|
return $votes[0]; |
| 775 |
} |
} |
|
return fivestar_get_votes($type, $cid, $tag, $uid); |
|
| 776 |
} |
} |
| 777 |
|
|
| 778 |
|
return array(); |
| 779 |
} |
} |
| 780 |
|
|
| 781 |
function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { |
function fivestar_get_votes($type, $cid, $tag = 'vote', $uid = NULL) { |