Все файлы приложить не могу, но вот mail.php:
Код:
<?php
// Assign contact info
$name = stripcslashes($_POST['name']);
$emailAddr = stripcslashes($_POST['email']);
$issue = stripcslashes($_POST['issue']);
$comment = stripcslashes($_POST['message']);
$subject = stripcslashes($_POST['subject']);
// Set headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset: utf8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 7bit' . "\r\n";
$headers .= "From: $emailAddr" . "\r\n" .
"Reply-To: $emailAddr" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
// Format message
$contactMessage = '
<div>текст формы</div>
';
// Send and check the message status
$response = (mail(Configuration::get('BOX_ADMIN_MAIL'), $subject, $contactMessage, $headers) ) ? "success" : "failure";
$output = json_encode(array("response" => $response));
header('content-type: application/json; charset=utf-8');
echo($output);
?>
и вот php модуля. Оба лежат в папке модуля естественно.
Код:
<?php
if (!defined('_PS_VERSION_'))
exit;
class MailBox extends Module
{
public function __construct()
{
$this->name = 'mailbox';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = '';
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('MailBox');
$this->description = $this->l('box');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
public function install()
{
return (parent::install() &&
Configuration::updateValue('BOX_ARROW', 1) &&
Configuration::updateValue('BOX_ADMIN_MAIL','example@yourdomain.com') &&
$this->registerHook('displayHeader') &&
$this->registerHook('displayMailBox'));
}
public function uninstall()
{
Configuration::deleteByName('BOX_CART') &&
Configuration::deleteByName('BOX_ACC') &&
Configuration::deleteByName('BOX_MAIL') &&
Configuration::deleteByName('BOX_ARROW') &&
Configuration::deleteByName('BOX_ADMIN_MAIL');
return parent::uninstall();
}
public function getContent()
{
$html = '';
Context::getContext()->cookie->email;
if (Tools::isSubmit('submitConfiguration'))
Configuration::updateValue('BOX_CART', (int)(Tools::getValue('box_cart_sw')));
Configuration::updateValue('BOX_ACC', (int)(Tools::getValue('box_acc_sw')));
Configuration::updateValue('BOX_MAIL', (int)(Tools::getValue('box_mail_sw')));
Configuration::updateValue('BOX_ARROW', (int)(Tools::getValue('box_arrow_sw')));
Configuration::updateValue('BOX_ADMIN_MAIL', Tools::getValue('box_admin_mail'));
$this->_clearCache('mailbox.tpl');
$html .= $this->displayConfirmation($this->l('The settings have been updated.'));
$html .= $this->renderForm();
return $html;
}
/**
* Returns module content
*
* @param array $params Parameters
* @return string Content
*/
public function hookdisplayMailBox($params)
{
if (!$this->isCached('mailbox.tpl', $this->getCacheId()))
$this->smarty->assign(
array(
'box_cart' => Configuration::get('BOX_CART'),
'box_acc' => Configuration::get('BOX_ACC'),
'box_mail' => Configuration::get('BOX_MAIL'),
'box_arrow' => Configuration::get('BOX_ARROW'),
'box_admin_mail' => Configuration::get('BOX_ADMIN_MAIL')
));
return $this->display(__FILE__, 'mailbox.tpl', $this->getCacheId());
}
public function hookHeader($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return;
$this->context->controller->addCSS(($this->_path).'css/mailbox.css', 'all');
$this->context->controller->addCSS(($this->_path).'css/contactable.css', 'all');
$this->context->controller->addJS(($this->_path).'js/mailbox.js', 'all');
$this->context->controller->addJS(($this->_path).'js/jquery.contactable.js', 'all');
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'switch',
'label' => $this->l('Display Cart box?'),
'name' => 'box_cart_sw',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('YES')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('NO')
)
),
),
array(
'type' => 'switch',
'label' => $this->l('Display Account box?'),
'name' => 'box_acc_sw',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('YES')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('NO')
)
),
),
array(
'type' => 'switch',
'label' => $this->l('Display Mail box?'),
'name' => 'box_mail_sw',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('YES')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('NO')
)
),
),
array(
'type' => 'text',
'label' => $this->l('Administrator email'),
'name' => 'box_admin_mail',
'class' => 'fixed-width-xl',
'desc' => $this->l('E-mail that will receive mails through the contact form')
),
array(
'type' => 'switch',
'label' => $this->l('Display Up arrow box?'),
'name' => 'box_arrow_sw',
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('YES')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('NO')
)
),
),
),
'submit' => array(
'title' => $this->l('Save'),
)
),
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitConfiguration';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function getConfigFieldsValues()
{
return array(
'box_cart_sw' => Tools::getValue('box_cart_sw', Configuration::get('BOX_CART')),
'box_acc_sw' => Tools::getValue('box_acc_sw', Configuration::get('BOX_ACC')),
'box_mail_sw' => Tools::getValue('box_mail_sw', Configuration::get('BOX_MAIL')),
'box_admin_mail' => Tools::getValue('box_admin_mail', Configuration::get('BOX_ADMIN_MAIL')),
'box_arrow_sw' => Tools::getValue('box_arrow_sw', Configuration::get('BOX_ARROW'))
);
}
}
В принципе остальные файлы значения не имеют.
Вот мне нужно как-то в mail.php в этой строке:
$response = (example@example.com, $subject, $contactMessage, $headers) ) ? "success" : "failure" ;
вместо example@example.com вызвать значение box_admin_mail, я пробовал mail(Configuration::get('BOX_ADMIN_MAIL') но ничего.
Спасибо.