<?php
/**
* @package HikaShop for Joomla!
* @version 4.7.0
* @author hikashop.com
* @copyright (C) 2010-2022 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
class hikashopVoteClassOverride extends hikashopClass
{
function checkVote(&$element)
{
$safeHtmlFilter = JFilterInput::getInstance(array(), array(), 1, 1);
if (empty($element->vote_ref_id) || (int)$element->vote_ref_id == 0) {
$this->error = array('code' => '505001', 'message' => hikashop_display(JText::_('HIKA_VOTE_ITEM_ID_MISSING'), 'error', true));
return false;
}
if ((!isset($element->vote_type) || empty($element->vote_type)) && (!hikashop_isClient('administrator') || hikashop_isClient('administrator') && $element->vote_id == 0)) {
$this->error = array('code' => '505015', 'message' => hikashop_display(JText::_('HIKA_VOTE_TYPE_MISSING'), 'error', true));
return false;
}
$allowedVoteType = $this->config->get('enable_status_vote', 'nothing');
$element->vote_rating = (isset($element->vote_rating)) ? $element->vote_rating : 0;
$element->vote_comment = trim($safeHtmlFilter->clean(strip_tags((isset($element->vote_comment)) ? $element->vote_comment : ''), 'string'));
$correctRating = 1;
if ((int)$element->vote_rating == 0 || (int)$element->vote_rating > $this->config->get('vote_star_number', 5))
$correctRating = 0;
$user = hikashop_loadUser(true);
if ($this->config->get('access_vote', 'public') == 'registered' && empty($user->user_cms_id)) {
$this->error = array('code' => '505017', 'message' => hikashop_display(JText::_('ONLY_REGISTERED_CAN_VOTE'), 'error', true));
return false;
}
if (hikashop_isClient('administrator')) {
$element->vote_user_id = hikashop_getIP();
} else {
if (!empty($user->user_cms_id)) {
$element->vote_user_id = (int)$user->user_id;
$element->vote_pseudo = trim($safeHtmlFilter->clean(strip_tags((isset($element->vote_pseudo)) ? $element->vote_pseudo : ''), 'string'));
$element->vote_email = $user->email;
} else {
$element->vote_user_id = hikashop_getIP();
$element->vote_pseudo = trim($safeHtmlFilter->clean(strip_tags((isset($element->vote_pseudo)) ? $element->vote_pseudo : ''), 'string'));
if ((!$correctRating || $allowedVoteType == 'both') && !empty($element->vote_comment)) {
if (!$element->vote_pseudo) {
$this->error = array('code' => '505011', 'message' => hikashop_display(JText::_('HIKA_VOTE_PSEUDO_REQUIRED'), 'error', true));
return false;
}
if ($this->config->get('email_comment', '1')) {
$element->vote_email = trim($safeHtmlFilter->clean(strip_tags((isset($element->vote_email)) ? $element->vote_email : ''), 'string'));
if (!$element->vote_email || empty($element->vote_email)) {
$this->error = array('code' => '505012', 'message' => hikashop_display(JText::_('HIKA_VOTE_EMAIL_REQUIRED'), 'error', true));
return false;
}
}
}
}
if ($this->config->get('access_vote', 'public') != 'public' && empty($user->user_cms_id)) {
$this->error = array('code' => '505002', 'message' => hikashop_display(JText::_('HIKA_VOTE_REGISTRATION_REQUIRED'), 'error', true));
return false;
}
if ($element->vote_type == 'product' && $this->config->get('access_vote', 'public') == 'buyed') {
$hasBought = $this->hasBought($element->vote_ref_id, $user->user_id);
if (!$hasBought) {
$this->error = array('code' => '505003', 'message' => hikashop_display(JText::_('HIKA_VOTE_ITEM_BOUGHT_REQUIRED'), 'error', true));
return false;
}
}
}
if (in_array($allowedVoteType, array('vote', 'two')) && $element->vote_rating != 0)
$element->vote_comment = '';
if ($allowedVoteType == 'nothing') {
$this->error = array('code' => '505005', 'message' => hikashop_display(JText::_('HIKA_VOTE_NOT_ALLOWED'), 'error', true));
return false;
}
if ($allowedVoteType == 'vote' && !$correctRating) {
$this->error = array('code' => '505006', 'message' => hikashop_display(JText::_('HIKA_VOTE_WRONG_RATING_VALUE'), 'error', true));
return false;
}
if ($allowedVoteType == 'comment' && $element->vote_comment == '') {
$this->error = array('code' => '505007', 'message' => hikashop_display(JText::_('HIKA_VOTE_EMPTY_COMMENT'), 'error', true));
return false;
}
if ($allowedVoteType == 'two' && $element->vote_comment == '' && !$correctRating) {
$this->error = array('code' => '505008', 'message' => hikashop_display(JText::_('HIKA_VOTE_WRONG_VOTE_COMMENT_VALUE'), 'error', true));
return false;
}
if ($allowedVoteType == 'both' && ($element->vote_comment == '' || !$correctRating)) {
$this->error = array('code' => '505009', 'message' => hikashop_display(JText::_('HIKA_VOTE_MISSING_VOTE_COMMENT_VALUE'), 'error', true));
return false;
}
if (!empty($element->vote_comment) && (!isset($element->vote_id) || $element->vote_id == 0)) {
$nbComment = $this->commentPassed($element->vote_type, $element->vote_ref_id, $element->vote_user_id);
if (in_array($allowedVoteType, array('comment', 'two', 'both')) && !empty($element->vote_comment) && $nbComment >= $this->config->get('comment_by_person_by_product', '30')) {
$this->error = array('code' => '505010', 'message' => hikashop_display(JText::_('HIKA_VOTE_LIMIT_REACHED'), 'error', true));
return false;
}
}
return true;
}
}
ma modification n'est pas prise en compte alors que si je la fait directement dans la classe vote elle l'est.
Si jamais vous voyez mon erreur, c'est super parce que moi pas.