/** * Add review * */ function addReview() { $input = JFactory::getApplication()->input; JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); Citruscart::load('CitruscartHelperProduct', 'helpers.product'); $productreviews = JTable::getInstance('productcomments', 'CitruscartTable'); $post = $input->getArray($_POST); $product_id = $post['product_id']; $Itemid = $post['Itemid']; $user = JFactory::getUser(); $valid = true; $this->messagetype = 'message'; $productcomment = CitruscartHelperProduct::strip_html_tags($post['productcomment_text']); //set in case validation fails $linkAdd = ''; $linkAdd .= '&rn=' . base64_encode($post['user_name']); $linkAdd .= '&re=' . base64_encode($post['user_email']); $linkAdd .= '&rc=' . base64_encode($productcomment); if (!$user->id) { if (empty($post['user_name']) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_NAME_FIELD_IS_REQUIRED'); $this->messagetype = 'notice'; } jimport('joomla.mail.helper'); if (!JMailHelper::isEmailAddress($post['user_email']) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_PLEASE_ENTER_A_CORRECT_EMAIL_ADDRESS'); $this->messagetype = 'notice'; } if (in_array($post['user_email'], CitruscartHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE'); $this->messagetype = 'notice'; } } else { if (in_array($user->email, CitruscartHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE'); $this->messagetype = 'notice'; } } if (empty($post['productcomment_rating']) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_RATING_IS_REQUIRED'); $this->messagetype = 'notice'; } if (empty($productcomment) && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_COMMENT_FIELD_IS_REQUIRED'); $this->messagetype = 'notice'; } $captcha = true; if (Citruscart::getInstance()->get('use_captcha', '0') && $valid) { $privatekey = "6LcAcbwSAAAAANZOTZWYzYWRULBU_S--368ld2Fb"; $captcha = false; if ($_POST["recaptcha_response_field"]) { Citruscart::load('CitruscartRecaptcha', 'library.recaptcha'); $recaptcha = new CitruscartRecaptcha(); $resp = $recaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $post['recaptcha_challenge_field'], $post['recaptcha_response_field']); if ($resp->is_valid) { $captcha = true; } } } if (!$captcha && $valid) { $valid = false; $this->message = JText::_('COM_CITRUSCART_INCORRECT_CAPTCHA'); $this->messagetype = 'notice'; } if ($valid) { $date = JFactory::getDate(); $productreviews->bind($post); $productreviews->created_date = $date->toSql(); $productreviews->productcomment_enabled = Citruscart::getInstance()->get('product_reviews_autoapprove', '0'); if (!$productreviews->save()) { $this->message = JText::_('COM_CITRUSCART_UNABLE_TO_SAVE_REVIEW') . " :: " . $productreviews->getError(); $this->messagetype = 'notice'; } else { $dispatcher = JDispatcher::getInstance(); JFactory::getApplication()->triggerEvent('onAfterSaveProductComments', array($productreviews)); $this->message = JText::_('COM_CITRUSCART_SUCCESSFULLY_SUBMITTED_REVIEW'); //successful $linkAdd = ''; } } $redirect = "index.php?option=com_citruscart&view=products&task=view&id=" . $product_id . $linkAdd . "&Itemid=" . $Itemid; $redirect = JRoute::_($redirect); $this->setRedirect($redirect, $this->message, $this->messagetype); }
$publickey = "6LcAcbwSAAAAAIEtIoDhP0cj7AAQMK9hqzJyAbeD"; $baseurl = $this->baseurl; $user = JFactory::getUser(); $url_validate = JRoute::_('index.php?option=com_citruscart&controller=products&view=products&task=validateReview&format=raw'); $share_review_enable = Citruscart::getInstance()->get('share_review_enable', '0'); $app = JFactory::getApplication(); ?> <div id="citruscart_customer_review"> <h3><?php echo JText::_('COM_CITRUSCART_REVIEWS'); ?> </h3> <?php if ($review_enable == 1 && ($result == 1 || $count > 0)) { $emails = CitruscartHelperProduct::getUserEmailForReview($this->comments_data->product_id); } ?> <div> <div class="rowDiv" style="padding-top: 5px;"> <?php if ($review_enable == 1 && $user->id) { ?> <div class="leftAlignDiv"> <input onclick="citruscartShowHideDiv('new_review_form');" value="<?php echo JText::_('COM_CITRUSCART_ADD_REVIEW'); ?> " type="button" class="btn btn-warning" /> </div> <?php }