Ejemplo n.º 1
0
$selectsort = $this->comments_data->selectsort;
$result = @$this->comments_data->result;
$review_enable = @$this->comments_data->review_enable;
$count = @$this->comments_data->count;
$url = JURI::getInstance()->toString();
$root = JURI::getInstance()->root();
$return_url = str_replace($root, '', $url);
$linkurl = TiendaHelperProduct::getSocialBookMarkUri($url);
$Itemid = JRequest::getInt('Itemid', '0');
$publickey = "6LcAcbwSAAAAAIEtIoDhP0cj7AAQMK9hqzJyAbeD";
$baseurl = $this->baseurl;
$user = JFactory::getUser();
$url_validate = JRoute::_('index.php?option=com_tienda&controller=products&view=products&task=validateReview&format=raw');
$share_review_enable = Tienda::getInstance()->get('share_review_enable', '0');
if ($review_enable == 1 && ($result == 1 || $count > 0)) {
    $emails = TiendaHelperProduct::getUserEmailForReview($this->comments_data->product_id);
    ?>
<div id="product_review_header" class="tienda_header">
    <span><?php 
    echo JText::_('COM_TIENDA_REVIEWS');
    ?>
</span>
</div>
<?php 
}
?>
 <div>
    <div class="rowDiv" style="padding-top: 5px;">
        <?php 
if ($review_enable == 1 && $result == 1) {
    ?>
Ejemplo n.º 2
0
 /**
  * Add review
  *
  */
 function addReview()
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     Tienda::load('TiendaHelperProduct', 'helpers.product');
     $productreviews = JTable::getInstance('productcomments', 'TiendaTable');
     $post = JRequest::get('post');
     $product_id = $post['product_id'];
     $Itemid = $post['Itemid'];
     $user = JFactory::getUser();
     $valid = true;
     $this->messagetype = 'message';
     //set in case validation fails
     $linkAdd = '';
     $linkAdd .= '&rn=' . base64_encode($post['user_name']);
     $linkAdd .= '&re=' . base64_encode($post['user_email']);
     $linkAdd .= '&rc=' . base64_encode($post['productcomment_text']);
     if (!$user->id) {
         if (empty($post['user_name']) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_NAME_FIELD_IS_REQUIRED');
             $this->messagetype = 'notice';
         }
         jimport('joomla.mail.helper');
         if (!JMailHelper::isEmailAddress($post['user_email']) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_PLEASE_ENTER_A_CORRECT_EMAIL_ADDRESS');
             $this->messagetype = 'notice';
         }
         if (in_array($post['user_email'], TiendaHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_YOU_ALREADY_SUBMITTED_A_REVIEW_CAN_ONLY_SUBMIT_REVIEW_ONCE');
             $this->messagetype = 'notice';
         }
     } else {
         if (in_array($user->email, TiendaHelperProduct::getUserEmailForReview($post['product_id'])) && $valid) {
             $valid = false;
             $this->message = JText::_('COM_TIENDA_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_TIENDA_RATING_IS_REQUIRED');
         $this->messagetype = 'notice';
     }
     if (empty($post['productcomment_text']) && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_COMMENT_FIELD_IS_REQUIRED');
         $this->messagetype = 'notice';
     }
     $captcha = true;
     if (Tienda::getInstance()->get('use_captcha', '0') && $valid) {
         $privatekey = "6LcAcbwSAAAAANZOTZWYzYWRULBU_S--368ld2Fb";
         $captcha = false;
         if ($_POST["recaptcha_response_field"]) {
             Tienda::load('TiendaRecaptcha', 'library.recaptcha');
             $recaptcha = new TiendaRecaptcha();
             $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_TIENDA_INCORRECT_CAPTCHA');
         $this->messagetype = 'notice';
     }
     if ($valid) {
         $date = JFactory::getDate();
         $productreviews->bind($post);
         $productreviews->created_date = $date->toMysql();
         $productreviews->productcomment_enabled = Tienda::getInstance()->get('product_reviews_autoapprove', '0');
         if (!$productreviews->save()) {
             $this->message = JText::_('COM_TIENDA_UNABLE_TO_SAVE_REVIEW') . " :: " . $productreviews->getError();
             $this->messagetype = 'notice';
         } else {
             $dispatcher = JDispatcher::getInstance();
             $dispatcher->trigger('onAfterSaveProductComments', array($productreviews));
             $this->message = JText::_('COM_TIENDA_SUCCESSFULLY_SUBMITTED_REVIEW');
             //successful
             $linkAdd = '';
         }
     }
     $redirect = "index.php?option=com_tienda&view=products&task=view&id=" . $product_id . $linkAdd . "&Itemid=" . $Itemid;
     $redirect = JRoute::_($redirect);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }