| 98 |
break; |
break; |
| 99 |
|
|
| 100 |
case 'vote': |
case 'vote': |
| 101 |
recordVote ( $url , $user_rating , $cid , $database); |
recordVote ( $user_rating , $cid , $database); |
| 102 |
break; |
break; |
| 103 |
|
|
| 104 |
default: |
default: |
| 1498 |
} |
} |
| 1499 |
|
|
| 1500 |
function recordVote() { |
function recordVote() { |
| 1501 |
global $database, $mosConfig_live_site; |
global $database, $mosConfig_live_site, $mosConfig_offset; |
| 1502 |
|
|
| 1503 |
$user_rating = mosGetParam( $_REQUEST, 'user_rating', 0 ); |
$user_rating = mosGetParam( $_REQUEST, 'user_rating', 0 ); |
| 1504 |
$cid = mosGetParam( $_REQUEST, 'cid', 0 ); |
$cid = mosGetParam( $_REQUEST, 'cid', 0 ); |
| 1506 |
$Itemid = mosGetParam( $_REQUEST, 'Itemid', 0 ); |
$Itemid = mosGetParam( $_REQUEST, 'Itemid', 0 ); |
| 1507 |
$Itemid = intval( $Itemid ); |
$Itemid = intval( $Itemid ); |
| 1508 |
$user_rating = intval( $user_rating ); |
$user_rating = intval( $user_rating ); |
| 1509 |
|
$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); |
| 1510 |
|
|
| 1511 |
$url = sefReltoAbs("index.php?option=com_content&task=view&id={$cid}&Itemid={$Itemid}"); |
$url = sefReltoAbs("index.php?option=com_content&task=view&id={$cid}&Itemid={$Itemid}"); |
| 1512 |
if ( ( $user_rating >= 1 ) and ( $user_rating <= 5 ) ) { |
if ( ( $user_rating >= 1 ) and ( $user_rating <= 5 ) ) { |
| 1513 |
$currip = getenv( 'REMOTE_ADDR' ); |
$currip = getenv( 'REMOTE_ADDR' ); |
| 1514 |
|
|
| 1515 |
|
$query = "SELECT * FROM #__content as c WHERE id = $cid AND (c.state = '1' OR c.state = '-1')" |
| 1516 |
|
. "\n AND (c.publish_up = '0000-00-00 00:00:00' OR c.publish_up <= '$now')" |
| 1517 |
|
. "\n AND (c.publish_down = '0000-00-00 00:00:00' OR c.publish_down >= '$now')" |
| 1518 |
|
; |
| 1519 |
|
$database->setQuery( $query ); |
| 1520 |
|
$database->loadObject( $row ); |
| 1521 |
|
if ( $row != NULL){ |
| 1522 |
$query = "SELECT * FROM #__content_rating WHERE content_id = $cid"; |
$query = "SELECT * FROM #__content_rating WHERE content_id = $cid"; |
| 1523 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 1524 |
$votesdb = NULL; |
$votesdb = NULL; |
| 1542 |
} |
} |
| 1543 |
} |
} |
| 1544 |
mosRedirect ( $url, T_('Thanks for your vote!') ); |
mosRedirect ( $url, T_('Thanks for your vote!') ); |
| 1545 |
|
} else { |
| 1546 |
|
mosRedirect ( $url, T_('The rating for this item is not allowed!') ); |
| 1547 |
|
} |
| 1548 |
} |
} |
| 1549 |
} |
} |
| 1550 |
|
|