first commit
This commit is contained in:
35
modules/aapfree/controllers/front/index.php
Normal file
35
modules/aapfree/controllers/front/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2016 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2016 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
108
modules/aapfree/controllers/front/question.php
Normal file
108
modules/aapfree/controllers/front/question.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* PrestaShop module created by VEKIA, a guy from official PrestaShop community ;-)
|
||||
*
|
||||
* @author VEKIA https://www.prestashop.com/forums/user/132608-vekia/
|
||||
* @copyright 2010-2019 VEKIA
|
||||
* @license This program is not free software and you can't resell and redistribute it
|
||||
*
|
||||
* CONTACT WITH DEVELOPER http://mypresta.eu
|
||||
* support@mypresta.eu
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__) . '../../../aapfree.php');
|
||||
|
||||
class aapfreequestionModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public function initContent()
|
||||
{
|
||||
if (Module::isEnabled('aapfree') && Tools::getValue('action') == 'sendQuestion' && Tools::getValue('secure_key') == $this->module->secure_key) {
|
||||
// Retrocompatibilty with old theme
|
||||
|
||||
$customerMail = Tools::getValue('email');
|
||||
$author = Tools::getValue('author');
|
||||
$phone = Tools::getValue('phone');
|
||||
$id_product = Tools::getValue('id_product');
|
||||
$question = Tools::getValue('question');
|
||||
|
||||
if (!$customerMail || !$id_product) {
|
||||
die('0');
|
||||
}
|
||||
|
||||
$isValidEmail = Validate::isEmail($customerMail);
|
||||
if (false === $isValidEmail) {
|
||||
die('0');
|
||||
}
|
||||
|
||||
|
||||
/** check if combination **/
|
||||
$combinations_array = array();
|
||||
$combination_id = 0;
|
||||
if (Tools::getValue('group', 'false') != 'false') {
|
||||
$groups = Tools::getValue('group');
|
||||
if (empty($groups)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$combination_id = (int)Product::getIdProductAttributeByIdAttributes(
|
||||
Tools::getValue('id_product'),
|
||||
$groups,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$combination_variable = '';
|
||||
$combination = '';
|
||||
if ($combination_id > 0) {
|
||||
$comb = new Combination($combination_id);
|
||||
if (is_object($comb)) {
|
||||
foreach ($comb->getAttributesName(Tools::getValue('id_lang')) AS $attr) {
|
||||
$attribute = new Attribute($attr['id_attribute'], Tools::getValue('id_lang'));
|
||||
$attribute_group = new AttributeGroup($attribute->id_attribute_group, Tools::getValue('id_lang'));
|
||||
$combinations_array[] = $attribute_group->public_name . ': ' . $attr['name'];
|
||||
}
|
||||
$combination_variable = implode(",", $combinations_array);
|
||||
$combination = '(' . implode(",", $combinations_array) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
/* Email generation */
|
||||
$product = new Product((int)$id_product, false, Tools::getValue('id_lang'));
|
||||
$productLink = Context::getContext()->link->getProductLink($product);
|
||||
|
||||
$templateVars = array(
|
||||
'{product}' => $product->name . $combination,
|
||||
'{combination}' => $combination_variable,
|
||||
'{product_link}' => $productLink,
|
||||
'{productLink}' => $productLink,
|
||||
'{customer}' => $author,
|
||||
'{phone}' => $phone,
|
||||
'{customerMail}' => $customerMail,
|
||||
'{question}' => $question
|
||||
);
|
||||
|
||||
/* Email sending */
|
||||
if (!Mail::Send((int)Tools::getValue('id_lang'),
|
||||
'send_question',
|
||||
sprintf(Configuration::get('aapfree_TITLE', (int)Tools::getValue('id_lang')), $author, $product->name),
|
||||
$templateVars,
|
||||
Configuration::get('PS_SHOP_EMAIL'),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
dirname(__FILE__) . '/mails/',
|
||||
false,
|
||||
Context::getContext()->shop->id,
|
||||
null,
|
||||
$customerMail,
|
||||
$author
|
||||
)) {
|
||||
die('0');
|
||||
}
|
||||
die('1');
|
||||
}
|
||||
die('0');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user