name = 'mailjet'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->displayName = 'Mailjet'; parent::__construct(); $this->description = $this->l('This modules sends through Mailjet all email coming from your Prestashop installation'); if (Configuration::get('MAILJET_ACTIVATE') == 1 && (strlen(Configuration::get('MAILJET_API_KEY')) < 3 || strlen(Configuration::get('MAILJET_SECRET_KEY')) < 3)) $this->warning = $this->l('The module is activated but api key or secret key are not correctly set.'); // Defines ajax lang variables in way to translate them $this->l('Mailjet Test E-mail'); $this->l('Hello'); $this->l('This E-mail confirms you that Mailjet has successfully been installed on your shop.'); $this->l('The E-mail was not successfully sent'); } /* ** Install / Uninstall Methods ** */ public function install() { // Can't do anything else for retrocompatibility if (md5_file(dirname(__FILE__).'/override/Message.php') != md5_file(dirname(__FILE__).'/../../tools/swift/Swift/Message.php')) return false; if (!@copy(dirname(__FILE__).'/override/Message-mailjet.php', dirname(__FILE__).'/../../tools/swift/Swift/Message.php')) return false; // Create Token Configuration::updateValue('MAILJET_TOKEN', md5(rand())); // Install module if (!parent::install()) return false; return true; } public function uninstall() { // Can't do anything else for retrocompatibility if (md5_file(dirname(__FILE__).'/override/Message-mailjet.php') != md5_file(dirname(__FILE__).'/../../tools/swift/Swift/Message.php')) return false; if (!@copy(dirname(__FILE__).'/override/Message.php', dirname(__FILE__).'/../../tools/swift/Swift/Message.php')) return false; // Uninstall module Configuration::updateValue('PS_MAIL_METHOD', 1); Configuration::updateValue('PS_MAIL_SERVER', ""); Configuration::updateValue('PS_MAIL_USER', ""); Configuration::updateValue('PS_MAIL_PASSWD', ""); Configuration::updateValue('PS_MAIL_SMTP_ENCRYPTION', ""); Configuration::updateValue('PS_MAIL_SMTP_PORT', 25); if (!Configuration::deleteByName('MAILJET_TOKEN') OR !Configuration::deleteByName('MAILJET_SECRET_KEY') OR !Configuration::deleteByName('MAILJET_API_KEY') OR !parent::uninstall()) return false; return true; } /* ** Form Config Methods ** */ public function getContent() { global $cookie; $lang = new Language((int)($cookie->id_lang)); if (!in_array($lang->iso_code, array('fr', 'en', 'es'))) $lang->iso_code = 'en'; $output = '
'; if (Tools::isSubmit('submitMailjet')) { Configuration::updateValue('MAILJET_API_KEY', pSQL(Tools::getValue('mailjet_api_key'))); Configuration::updateValue('MAILJET_SECRET_KEY', pSQL(Tools::getValue('mailjet_secret_key'))); Configuration::updateValue('MAILJET_ACTIVATE', (int)(Tools::getValue('mailjet_activation'))); // If mailjet activation, let's configure if ((int)Tools::getValue('mailjet_activation') == 1) { Configuration::updateValue('PS_MAIL_METHOD', 2); Configuration::updateValue('PS_MAIL_SERVER', "in.mailjet.com"); Configuration::updateValue('PS_MAIL_USER', pSQL(Configuration::get('MAILJET_API_KEY'))); Configuration::updateValue('PS_MAIL_PASSWD', pSQL(Configuration::get('MAILJET_SECRET_KEY'))); Configuration::updateValue('PS_MAIL_SMTP_ENCRYPTION', "tls"); Configuration::updateValue('PS_MAIL_SMTP_PORT', 465); } else { Configuration::updateValue('PS_MAIL_METHOD', 1); Configuration::updateValue('PS_MAIL_SERVER', ""); Configuration::updateValue('PS_MAIL_USER', ""); Configuration::updateValue('PS_MAIL_PASSWD', ""); Configuration::updateValue('PS_MAIL_SMTP_ENCRYPTION', ""); Configuration::updateValue('PS_MAIL_SMTP_PORT', 25); } $output .= ''.$this->l('This module sends through Mailjet all email coming from your Prestashop installation (and most third party modules)').'.