public function postActivation(ConnectionInterface $con = null) { // delete existing message $message = MessageQuery::create()->filterByName('mail_virtualproduct')->findOne($con); if (null !== $message) { $message->delete($con); } // create new message $message = new Message(); $message->setName('mail_virtualproduct')->setSecured(0); $basePath = __DIR__ . '/Config/message/%s.xml'; $languages = LangQuery::create()->find(); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $path = sprintf($basePath, $language->getLocale()); if (file_exists($path) && is_readable($path)) { $dom = new SimpleXMLElement(file_get_contents($path)); if ($dom) { $message->setTitle((string) $dom->title); $message->setSubject((string) $dom->subject); $message->setTextMessage((string) $dom->text); $message->setHtmlMessage((string) $dom->html); } } } $message->save(); }
public function postActivation(ConnectionInterface $con = null) { // register config variables if (null === ConfigQuery::read(self::CONFIG_TRACKING_URL, null)) { ConfigQuery::write(self::CONFIG_TRACKING_URL, self::DEFAULT_TRACKING_URL); } if (null === ConfigQuery::read(self::CONFIG_PICKING_METHOD, null)) { ConfigQuery::write(self::CONFIG_PICKING_METHOD, self::DEFAULT_PICKING_METHOD); } if (null === ConfigQuery::read(self::CONFIG_TAX_RULE_ID, null)) { ConfigQuery::write(self::CONFIG_TAX_RULE_ID, self::DEFAULT_TAX_RULE_ID); } // create new message if (null === MessageQuery::create()->findOneByName('mail_custom_delivery')) { $message = new Message(); $message->setName('mail_custom_delivery')->setHtmlTemplateFileName('custom-delivery-shipping.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('custom-delivery-shipping.txt')->setTextLayoutFileName('')->setSecured(0); $languages = LangQuery::create()->find(); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle($this->trans('Custom delivery shipping message', [], $locale)); $message->setSubject($this->trans('Your order {$order_ref} has been shipped', [], $locale)); } $message->save(); } }
public function postActivation(ConnectionInterface $con = null) { $languages = LangQuery::create()->find(); ConfigQuery::write(self::CONFIG_ENABLED, self::DEFAULT_ENABLED); ConfigQuery::write(self::CONFIG_THRESHOLD, self::DEFAULT_THRESHOLD); ConfigQuery::write(self::CONFIG_EMAILS, self::DEFAULT_EMAILS); // create new message if (null === MessageQuery::create()->findOneByName('stockalert_customer')) { $message = new Message(); $message->setName('stockalert_customer')->setHtmlTemplateFileName('alert-customer.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('alert-customer.txt')->setTextLayoutFileName('')->setSecured(0); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle($this->trans('Stock Alert - Customer', [], $locale)); $message->setSubject($this->trans('Product {$product_title} is available again', [], $locale)); } $message->save(); $message = new Message(); $message->setName('stockalert_administrator')->setHtmlTemplateFileName('alert-administrator.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('alert-administrator.txt')->setTextLayoutFileName('')->setSecured(0); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle($this->trans('Stock Alert - Administrator', [], $locale)); $message->setSubject($this->trans('Product {$product_title} is (nearly) out of stock', [], $locale)); } $message->save(); } try { RestockingAlertQuery::create()->findOne(); } catch (\Exception $e) { $database = new Database($con); $database->insertSql(null, [__DIR__ . '/Config/thelia.sql']); } }
protected function initializeMessage() { // create new message if (null === MessageQuery::create()->findOneByName('mail_tnt_france')) { $message = new Message(); $message->setName('mail_tnt_france')->setHtmlTemplateFileName('mail-tnt-france.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('mail-tnt-france.txt')->setTextLayoutFileName('')->setSecured(0); $languages = LangQuery::create()->find(); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setSubject($this->trans('Your order {$order_ref} has been shipped.', [], $locale)); $message->setTitle($this->trans('TNT France shipping message', [], $locale)); } $message->save(); } }
public function postActivation(ConnectionInterface $con = null) { // create new message if (null === MessageQuery::create()->findOneByName('mail_virtualproduct')) { $message = new Message(); $message->setName('mail_virtualproduct')->setHtmlTemplateFileName('virtual-product-download.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('virtual-product-download.txt')->setTextLayoutFileName('')->setSecured(0); $languages = LangQuery::create()->find(); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setSubject($this->trans('Order {$order_ref} validated. Download your files.', [], $locale)); $message->setTitle($this->trans('Virtual product download message', [], $locale)); } $message->save(); } }
/** * @param ConnectionInterface $con */ public function postActivation(ConnectionInterface $con = null) { $database = new Database($con->getWrappedConnection()); $database->insertSql(null, [__DIR__ . DS . 'Config' . DS . 'thelia.sql']); $languages = LangQuery::create()->find(); if (null === MessageQuery::create()->findOneByName(self::MESSAGE_SEND_CONFIRMATION)) { $message = new Message(); $message->setName(self::MESSAGE_SEND_CONFIRMATION)->setHtmlLayoutFileName('')->setHtmlTemplateFileName(self::MESSAGE_SEND_CONFIRMATION . '.html')->setTextLayoutFileName('')->setTextTemplateFileName(self::MESSAGE_SEND_CONFIRMATION . '.txt'); foreach ($languages as $language) { /** @var Lang $language */ $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle($this->trans('Order send confirmation', $locale)); $message->setSubject($this->trans('Order send confirmation', $locale)); } $message->save(); } }
public function postActivation(ConnectionInterface $con = null) { // Once activated, create the module schema in the Thelia database. $database = new Database($con); $database->insertSql(null, array(__DIR__ . DS . 'Config' . DS . 'thelia.sql')); $languages = LangQuery::create()->find(); if (null === MessageQuery::create()->findOneByName(self::CONFIRMATION_MESSAGE_NAME)) { $message = new Message(); $message->setName(self::CONFIRMATION_MESSAGE_NAME)->setHtmlLayoutFileName('')->setHtmlTemplateFileName(self::CONFIRMATION_MESSAGE_NAME . '.html')->setTextLayoutFileName('')->setTextTemplateFileName(self::CONFIRMATION_MESSAGE_NAME . '.txt'); foreach ($languages as $language) { /** @var Lang $language */ $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle($this->trans('Order payment confirmation', $locale)); $message->setSubject($this->trans('Order {$order_ref} payment confirmation', $locale)); } $message->save(); } /* Deploy the module's image */ $module = $this->getModuleModel(); if (ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__), $con); } }
/** * Create message with HTML and TEXT body from template HTMl and TEXT fields * using a text and a html layout */ public function testMessageWithTextAndHtmlBodyAndTextAndHtmlExtendableLayout() { $message = new ModelMessage(); $message->setLocale('fr_FR'); $message->setSubject("The subject"); $message->setTextMessage('TEXT <template> & content v={$myvar}'); $message->setHtmlMessage('HTML <template> & content v={$myvar}'); $message->setHtmlLayoutFileName('layout6.html.tpl'); $message->setTextLayoutFileName('layout6.text.tpl'); $path = TemplateHelper::getInstance()->getActiveMailTemplate()->getAbsolutePath(); $this->parser->assign('myvar', 'my-value'); file_put_contents($path . DS . 'layout6.html.tpl', 'HTML Layout 6: {block name="message-body"}{$message_body nofilter}{/block}'); file_put_contents($path . DS . 'layout6.text.tpl', 'TEXT Layout 6: {block name="message-body"}{$message_body nofilter}{/block}'); $instance = \Swift_Message::newInstance(); $message->buildMessage($this->parser, $instance); $this->assertEquals("The subject", $instance->getSubject()); $this->assertEquals("HTML Layout 6: HTML <template> & content v=my-value", $instance->getBody()); $this->assertEquals("TEXT Layout 6: TEXT <template> & content v=my-value", $instance->getChildren()[0]->getBody()); }
public function postActivation(ConnectionInterface $con = null) { // Config if (null === ConfigQuery::read('comment_activated')) { ConfigQuery::write('comment_activated', Comment::CONFIG_ACTIVATED); } if (null === ConfigQuery::read('comment_moderate')) { ConfigQuery::write('comment_moderate', Comment::CONFIG_MODERATE); } if (null === ConfigQuery::read('comment_ref_allowed')) { ConfigQuery::write('comment_ref_allowed', Comment::CONFIG_REF_ALLOWED); } if (null === ConfigQuery::read('comment_only_customer')) { ConfigQuery::write('comment_only_customer', Comment::CONFIG_ONLY_CUSTOMER); } if (null === ConfigQuery::read('comment_only_verified')) { ConfigQuery::write('comment_only_verified', Comment::CONFIG_ONLY_VERIFIED); } if (null === ConfigQuery::read('comment_request_customer_ttl')) { ConfigQuery::write('comment_request_customer_ttl', Comment::CONFIG_REQUEST_CUSTOMMER_TTL); } if (null === ConfigQuery::read('comment_notify_admin_new_comment')) { ConfigQuery::write('comment_notify_admin_new_comment', Comment::CONFIG_NOTIFY_ADMIN_NEW_COMMENT); } // Schema try { CommentQuery::create()->findOne(); } catch (\Exception $ex) { $database = new Database($con->getWrappedConnection()); $database->insertSql(null, [__DIR__ . DS . 'Config' . DS . 'thelia.sql']); } // Messages // load the email localization files (the module was just loaded so they are not loaded yet) $languages = LangQuery::create()->find(); /** @var Lang $language */ foreach ($languages as $language) { Translator::getInstance()->addResource("php", __DIR__ . "/I18n/email/default/" . $language->getLocale() . ".php", $language->getLocale(), self::MESSAGE_DOMAIN_EMAIL); } // Request comment from customer if (null === MessageQuery::create()->findOneByName('comment_request_customer')) { $message = new Message(); $message->setName('comment_request_customer')->setHtmlTemplateFileName('request-customer-comment.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('request-customer-comment.txt')->setTextLayoutFileName('')->setSecured(0); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle(Translator::getInstance()->trans('Request customer comment', [], self::MESSAGE_DOMAIN)); $message->setSubject(Translator::getInstance()->trans('', [], self::MESSAGE_DOMAIN)); } $message->save(); } // Notify admin of new comment if (null === MessageQuery::create()->findOneByName('new_comment_notification_admin')) { $message = new Message(); $message->setName('new_comment_notification_admin')->setHtmlTemplateFileName('new-comment-notification-admin.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('new-comment-notification-admin.txt')->setTextLayoutFileName('')->setSecured(0); foreach ($languages as $language) { $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle(Translator::getInstance()->trans('Notify store admin of new comment', [], self::MESSAGE_DOMAIN_EMAIL, $locale)); $subject = Translator::getInstance()->trans('New comment on %ref_type_title "%ref_title"', [], self::MESSAGE_DOMAIN_EMAIL, $locale); $subject = str_replace('%ref_type_title', '{$ref_type_title|lower}', $subject); $subject = str_replace('%ref_title', '{$ref_title}', $subject); $message->setSubject($subject); } $message->save(); } }