// Context part 18
This commit is contained in:
@@ -39,23 +39,21 @@ class ContactControllerCore extends FrontController
|
||||
{
|
||||
parent::preProcess();
|
||||
|
||||
if (self::$cookie->isLogged())
|
||||
if ($this->context->customer->isLogged())
|
||||
{
|
||||
self::$smarty->assign('isLogged', 1);
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError('Customer not found'));
|
||||
$this->context->smarty->assign('isLogged', 1);
|
||||
|
||||
$products = array();
|
||||
$orders = array();
|
||||
$getOrders = Db::getInstance()->ExecuteS('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_customer = '.(int)$customer->id.' ORDER BY date_add');
|
||||
WHERE id_customer = '.(int)$this->context->customer->id.' ORDER BY date_add');
|
||||
foreach ($getOrders as $row)
|
||||
{
|
||||
$order = new Order($row['id_order']);
|
||||
$date = explode(' ', $order->date_add);
|
||||
$orders[$row['id_order']] = Tools::displayDate($date[0], self::$cookie->id_lang);
|
||||
$orders[$row['id_order']] = Tools::displayDate($date[0], $this->context->language->id);
|
||||
$tmp = $order->getProducts();
|
||||
foreach ($tmp as $key => $val)
|
||||
$products[$val['product_id']] = $val['product_name'];
|
||||
@@ -68,8 +66,8 @@ class ContactControllerCore extends FrontController
|
||||
|
||||
foreach ($products as $key => $val)
|
||||
$orderedProductList .= '<option value="'.$key.'" '.((int)(Tools::getValue('id_product')) == $key ? 'selected' : '').' >'.$val.'</option>';
|
||||
self::$smarty->assign('orderList', $orderList);
|
||||
self::$smarty->assign('orderedProductList', $orderedProductList);
|
||||
$this->context->smarty->assign('orderList', $orderList);
|
||||
$this->context->smarty->assign('orderedProductList', $orderedProductList);
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitMessage'))
|
||||
@@ -90,7 +88,7 @@ class ContactControllerCore extends FrontController
|
||||
$this->errors[] = Tools::displayError('Message cannot be blank');
|
||||
elseif (!Validate::isCleanHtml($message))
|
||||
$this->errors[] = Tools::displayError('Invalid message');
|
||||
elseif (!($id_contact = (int)(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact((int)($id_contact), (int)(self::$cookie->id_lang)))))
|
||||
elseif (!($id_contact = (int)(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))))
|
||||
$this->errors[] = Tools::displayError('Please select a subject on the list.');
|
||||
elseif (!empty($_FILES['fileUpload']['name']) AND $_FILES['fileUpload']['error'] != 0)
|
||||
$this->errors[] = Tools::displayError('An error occurred during the file upload');
|
||||
@@ -98,15 +96,11 @@ class ContactControllerCore extends FrontController
|
||||
$this->errors[] = Tools::displayError('Bad file extension');
|
||||
else
|
||||
{
|
||||
if ((int)(self::$cookie->id_customer))
|
||||
$customer = new Customer((int)(self::$cookie->id_customer));
|
||||
else
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer = $this->context->customer;
|
||||
if (!$customer->id)
|
||||
$customer->getByEmail($from);
|
||||
}
|
||||
|
||||
$contact = new Contact($id_contact, self::$cookie->id_lang);
|
||||
$contact = new Contact($id_contact, $this->context->language->id);
|
||||
|
||||
if (!((
|
||||
$id_customer_thread = (int)Tools::getValue('id_customer_thread')
|
||||
@@ -152,15 +146,15 @@ class ContactControllerCore extends FrontController
|
||||
ORDER BY date_add DESC');
|
||||
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
|
||||
{
|
||||
self::$smarty->assign('alreadySent', 1);
|
||||
$this->context->smarty->assign('alreadySent', 1);
|
||||
$contact->email = '';
|
||||
$contact->customer_service = 0;
|
||||
}
|
||||
if (!empty($contact->email))
|
||||
{
|
||||
if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
|
||||
AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from))
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
if (Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
|
||||
AND Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from))
|
||||
$this->context->smarty->assign('confirmation', 1);
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
}
|
||||
@@ -171,7 +165,7 @@ class ContactControllerCore extends FrontController
|
||||
{
|
||||
$ct = new CustomerThread($id_customer_thread);
|
||||
$ct->status = 'open';
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->id_lang = (int)$this->context->language->id;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
if ($id_order = (int)Tools::getValue('id_order'))
|
||||
$ct->id_order = $id_order;
|
||||
@@ -190,7 +184,7 @@ class ContactControllerCore extends FrontController
|
||||
if ($id_product = (int)Tools::getValue('id_product'))
|
||||
$ct->id_product = $id_product;
|
||||
$ct->id_contact = (int)($id_contact);
|
||||
$ct->id_lang = (int)self::$cookie->id_lang;
|
||||
$ct->id_lang = (int)$this->context->language->id;
|
||||
$ct->email = $from;
|
||||
$ct->status = 'open';
|
||||
$ct->token = Tools::passwdGen(12);
|
||||
@@ -209,8 +203,8 @@ class ContactControllerCore extends FrontController
|
||||
if ($cm->add())
|
||||
{
|
||||
if (empty($contact->email))
|
||||
Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
|
||||
self::$smarty->assign('confirmation', 1);
|
||||
Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
|
||||
$this->context->smarty->assign('confirmation', 1);
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
@@ -234,8 +228,8 @@ class ContactControllerCore extends FrontController
|
||||
{
|
||||
parent::process();
|
||||
|
||||
$email = Tools::safeOutput(Tools::getValue('from', ((isset(self::$cookie) AND isset(self::$cookie->email) AND Validate::isEmail(self::$cookie->email)) ? self::$cookie->email : '')));
|
||||
self::$smarty->assign(array(
|
||||
$email = Tools::safeOutput(Tools::getValue('from', ((isset($this->context->cookie) AND isset($this->context->cookie->email) AND Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : '')));
|
||||
$this->context->smarty->assign(array(
|
||||
'errors' => $this->errors,
|
||||
'email' => $email,
|
||||
'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD')
|
||||
@@ -247,9 +241,9 @@ class ContactControllerCore extends FrontController
|
||||
$customerThread = Db::getInstance()->getRow('
|
||||
SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm
|
||||
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->id_current_shop.' AND token = \''.pSQL($token).'\'');
|
||||
self::$smarty->assign('customerThread', $customerThread);
|
||||
$this->context->smarty->assign('customerThread', $customerThread);
|
||||
}
|
||||
self::$smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang),
|
||||
$this->context->smarty->assign(array('contacts' => Contact::getContacts($this->context->language->id),
|
||||
'message' => html_entity_decode(Tools::getValue('message'))
|
||||
));
|
||||
}
|
||||
@@ -258,7 +252,7 @@ class ContactControllerCore extends FrontController
|
||||
{
|
||||
$_POST = array_merge($_POST, $_GET);
|
||||
parent::displayContent();
|
||||
self::$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
|
||||
$this->context->smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user