Example #1
0
 /**
  *
  *
  */
 function addReview()
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
     $productreviews = JTable::getInstance('productcomments', 'TiendaTable');
     $post = JRequest::get('post');
     $captcha_enable = Tienda::getInstance()->get('use_captcha', '0');
     $privatekey = "6LcAcbwSAAAAANZOTZWYzYWRULBU_S--368ld2Fb";
     $Itemid = $post['Itemid'];
     $recaptcha_challenge_field = $post['recaptcha_challenge_field'];
     $recaptcha_response_field = $post['recaptcha_response_field'];
     $captcha = '1';
     if ($captcha_enable) {
         $captcha = '0';
         Tienda::load('TiendaRecaptcha', 'library.recaptcha');
         $recaptcha = new TiendaRecaptcha();
         if ($_POST["recaptcha_response_field"]) {
             $resp = $recaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
             if ($resp->is_valid) {
                 $captcha = '1';
             }
         }
     }
     $product_id = $post['product_id'];
     $date = JFactory::getDate();
     $productreviews->bind($post);
     $productreviews->created_date = $date->toMysql();
     $redirect = "index.php?option=com_tienda&view=products&task=view&id=" . $product_id . "filter_category=" . $product_id . "&Itemid=" . $Itemid;
     $redirect = JRoute::_($redirect);
     if ($captcha == '1') {
         if (!$productreviews->save()) {
             $this->messagetype = 'message';
             $this->message = JText::_('COM_TIENDA_UNABLE_TO_SAVE_REVIEW') . " :: " . $productreviews->getError();
         } else {
             $dispatcher = JDispatcher::getInstance();
             $dispatcher->trigger('onAfterSaveProductComments', array($productreviews));
             $this->messagetype = 'message';
             $this->message = JText::_('COM_TIENDA_SUCCESSFULLY_SUBMITTED_REVIEW');
         }
     } else {
         $this->messagetype = 'message';
         $this->message = JText::_('COM_TIENDA_INCORRECT_CAPTCHA');
     }
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
Example #2
0
" size="40" name="user_name" id="user_name"/>
        	<?php 
}
?>
            <div><?php 
echo JText::_('COM_TIENDA_COMMENT');
?>
: *</div>
            <div><textarea name="productcomment_text" id="productcomment_text" rows="10" style="width: 99%;" ><?php 
echo base64_decode(JRequest::getVar('rc', ''));
?>
</textarea></div>
            <?php 
if (Tienda::getInstance()->get('use_captcha', '0') == 1) {
    Tienda::load('TiendaRecaptcha', 'library.recaptcha');
    $recaptcha = new TiendaRecaptcha();
    ?>
            <div><?php 
    echo $recaptcha->recaptcha_get_html($publickey);
    ?>
</div>
            <?php 
}
?>
                    
            <input type="button" name="review" id="review" onclick="javscript:tiendaFormValidation( '<?php 
echo $url_validate;
?>
','validationmessage_comments', 'addReview', document.commentsForm );" value="<?php 
echo JText::_('COM_TIENDA_SUBMIT_COMMENT');
?>
Example #3
0
 function sendAskedQuestion()
 {
     $config = Tienda::getInstance();
     $post = JRequest::get('post');
     $valid = true;
     $this->messagetype = 'message';
     $this->message = '';
     $add_link = '';
     if (empty($post['sender_name']) && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_NAME_FIELD_IS_REQUIRED');
         $this->messagetype = 'notice';
     }
     jimport('joomla.mail.helper');
     if (!JMailHelper::isEmailAddress($post['sender_mail']) && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_PLEASE_ENTER_A_CORRECT_EMAIL_ADDRESS');
         $this->messagetype = 'notice';
         $add_link .= "&sender_name={$post['sender_name']}";
         $add_link .= !empty($post['sender_message']) ? "&sender_message={$post['sender_message']}" : '';
     }
     if (empty($post['sender_message']) && $valid) {
         $valid = false;
         $this->message = JText::_('COM_TIENDA_MESSAGE_FIELD_IS_REQUIRED');
         $this->messagetype = 'notice';
         $add_link .= "&sender_name={$post['sender_name']}&sender_mail={$post['sender_mail']}";
     }
     //captcha checking
     $captcha = true;
     if ($config->get('ask_question_showcaptcha', '1') == 1 && $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 = false;
         $this->message = JText::_('COM_TIENDA_INCORRECT_CAPTCHA');
         $this->messagetype = 'notice';
         $add_link .= "&sender_name={$post['sender_name']}&sender_mail={$post['sender_mail']}&sender_message={$post['sender_message']}";
     }
     if ($valid) {
         $mainframe = JFactory::getApplication();
         $sendObject = new JObject();
         $sendObject->mailfrom = $post['sender_mail'];
         $sendObject->namefrom = $post['sender_name'];
         $sendObject->mailto = $config->get('emails_defaultemail', $mainframe->getCfg('mailfrom'));
         $sendObject->body = $post['sender_message'];
         //get product info
         JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
         $model = JModel::getInstance('Products', 'TiendaModel');
         $model->setId($post['product_id']);
         $sendObject->item = $model->getItem();
         Tienda::load("TiendaHelperBase", 'helpers._base');
         $helper = TiendaHelperBase::getInstance('Email');
         if ($send = $helper->sendEmailToAskQuestionOnProduct($sendObject)) {
             $this->message = JText::_('COM_TIENDA_MESSAGE_SUCCESSFULLY_SENT');
         } else {
             $this->message = JText::_('COM_TIENDA_ERROR_IN_SENDING_MESSAGE');
             $this->messagetype = 'notice';
         }
         if (Tienda::getInstance()->get('ask_question_modal', '1')) {
             $url = "index.php?option=com_tienda&view=products&task=askquestion&id={$post['product_id']}&tmpl=component&return=" . $post['return'] . $add_link . "&success=1";
             $redirect = JRoute::_($url);
         } else {
             $redirect = JRoute::_(base64_decode($post['return']));
         }
     } else {
         $url = "index.php?option=com_tienda&view=products&task=askquestion&id={$post['product_id']}&tmpl=component&return=" . $post['return'] . $add_link;
         $redirect = JRoute::_($url);
     }
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }