* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7082 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class Ekomi extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'ekomi'; $this->tab = 'advertising_marketing'; $this->version = 1.0; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('eKomi'); $this->description = $this->l('Adds an eKomi block'); } public function install() { return (parent::install() AND $this->registerHook('rightColumn') AND $this->registerHook('newOrder')); } public function getContent() { $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitEkomi')) { $email = Tools::getValue('ekomi_email'); Configuration::updateValue('PS_EKOMI_DISPLAY', Tools::getValue('ekomi_display')); Configuration::updateValue('PS_EKOMI_SCRIPT', htmlentities(str_replace(array("\r\n", "\n"), '', Tools::getValue('ekomi_script')))); if (!empty($email) && !Validate::isEmail($email)) Configuration::updateValue('PS_EKOMI_EMAIL', ''); else Configuration::updateValue('PS_EKOMI_EMAIL', Tools::getValue('ekomi_email')); $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } return $output.$this->displayForm(); } public function displayForm() { return '
'.$this->l('Settings').'





'.$this->l('Show or don\'t show the block (orders will be sent to eKomi whether you choose to hide or display the block).').'

'.$this->l('Please fill the form with the data that eKomi gives you.').'

'; } public function hookRightColumn($params) { if (!Configuration::get('PS_EKOMI_SCRIPT')) return; if (!Configuration::get('PS_EKOMI_DISPLAY')) return; return stripslashes(html_entity_decode(Configuration::get('PS_EKOMI_SCRIPT'))).'

'; } public function hookLeftColumn($params) { return $this->hookRightColumn($params); } public function hookNewOrder($params) { if (!Configuration::get('PS_EKOMI_EMAIL')) return true; /* Email generation */ $subject = '[Ekomi-Prestashop] '.Configuration::get('PS_SHOP_NAME'); $templateVars = array( '{firstname}' => $params['customer']->firstname, '{lastname}' => $params['customer']->lastname, '{email}' => $params['customer']->email, '{id_order}' => $params['order']->id ); /* Email sending */ if (!Mail::Send(1, 'ekomi', $subject, $templateVars, Configuration::get('PS_EKOMI_EMAIL'), NULL, $params['customer']->email, Configuration::get('PS_SHOP_NAME'), NULL, NULL, dirname(__FILE__).'/mails/')) return true; return true; } }