1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
<?php
class ProductQuestionController extends HttpViewController
{
protected $tellAFriendContentView;
protected $emailService;
protected $db;
public function init()
{
$this->tellAFriendContentView = MainFactory::create('TellAFriendContentView');
$this->emailService = StaticGXCoreLoader::getService('Email');
$this->db = StaticGXCoreLoader::getDatabaseQueryBuilder();
}
public function actionDefault()
{
$this->_setupContentView();
$response = [
'success' => true,
'content' => $this->tellAFriendContentView->get_html()
];
return MainFactory::create('JsonHttpControllerResponse', $response);
}
public function actionSend()
{
$this->_setupContentView();
$this->tellAFriendContentView->setPost($_POST);
$this->tellAFriendContentView->setName($_POST['name']);
$this->tellAFriendContentView->setEmail($_POST['email']);
$this->tellAFriendContentView->setMessage($_POST['message']);
$this->tellAFriendContentView->setPrivacyAccepted(isset($_POST['privacy_accepted']) ? 1 : 0);
$contentHtml = $this->tellAFriendContentView->get_html();
$contentArray = $this->tellAFriendContentView->get_content_array();
$response = [
'success' => !isset($contentArray['ERROR']),
'content' => $contentHtml
];
return MainFactory::create('JsonHttpControllerResponse', $response);
}
protected function _setupContentView()
{
$this->tellAFriendContentView->set_content_template('module/product_question.html');
$this->tellAFriendContentView->set_flat_assigns(false);
$this->tellAFriendContentView->setProductsId((int)$_GET['productId']);
$captcha = MainFactory::create_object('Captcha');
$this->tellAFriendContentView->setCaptchaObject($_SESSION['captcha_object'] = &$captcha);
$this->tellAFriendContentView->setCustomerId((int)$_SESSION['customer_id']);
$this->tellAFriendContentView->setCustomerFirstName($_SESSION['customer_first_name']);
$this->tellAFriendContentView->setCustomerLastName($_SESSION['customer_last_name']);
$this->tellAFriendContentView->setLanguagesId((int)$_SESSION['languages_id']);
if(array_key_exists('properties_values_ids', $_GET) && is_array($_GET['properties_values_ids']))
{
$this->tellAFriendContentView->setPropertyValueIds($_GET['properties_values_ids']);
}
if(array_key_exists('id', $_GET) && is_array($_GET['id']))
{
$this->tellAFriendContentView->setAttributeIds($_GET['id']);
}
}
}