Beispiel #1
0
 public function postActivation(ConnectionInterface $con = null)
 {
     // Setup some default values
     if (null === self::getConfigValue('atos_merchantId', null)) {
         self::setConfigValue('atos_transactionId', 1);
         self::setConfigValue('minimum_amount', 0);
         self::setConfigValue('maximum_amount', 0);
         self::setConfigValue('send_payment_confirmation_message', 1);
     }
     // Try to chmod binaries if they're not executables
     $binFile = self::getBinDirectory() . 'request';
     if (!is_executable($binFile)) {
         @chmod($binFile, 0755);
     }
     $binFile = self::getBinDirectory() . 'response';
     if (!is_executable($binFile)) {
         @chmod($binFile, 0755);
     }
     $database = new Database($con);
     $database->insertSql(null, array(__DIR__ . DS . 'Config' . DS . 'thelia.sql'));
     // Create payment confirmation message from templates, if not already defined
     $email_templates_dir = __DIR__ . DS . 'I18n' . DS . 'email-templates' . DS;
     if (null === MessageQuery::create()->findOneByName(self::CONFIRMATION_MESSAGE_NAME)) {
         $message = new Message();
         $message->setName(self::CONFIRMATION_MESSAGE_NAME)->setHtmlTemplateFileName('atos-payment-confirmation.html')->setTextTemplateFileName('atos-payment-confirmation.txt')->setLocale('en_US')->setTitle('Atos payment confirmation')->setSubject('Payment of order {$order_ref}')->setLocale('fr_FR')->setTitle('Confirmation de paiement par Atos')->setSubject('Confirmation du paiement de votre commande {$order_ref}')->save();
     }
     $this->replacePath();
 }
Beispiel #2
0
 /**
  * @param MessageModel $message
  * @depends testModify
  */
 public function testDelete(MessageModel $message)
 {
     $event = new MessageDeleteEvent($message->getId());
     $action = new Message();
     $action->delete($event, null, $this->getMockEventDispatcher());
     $deletedMessage = $event->getMessage();
     $this->assertInstanceOf('Thelia\\Model\\Message', $deletedMessage);
     $this->assertTrue($deletedMessage->isDeleted());
 }
 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();
 }
Beispiel #4
0
 public function createMailMessage()
 {
     // Create payment confirmation message from templates, if not already defined
     if (null === MessageQuery::create()->findOneByName(self::CONFIRMATION_MESSAGE_NAME)) {
         $languages = LangQuery::create()->find();
         $message = new Message();
         $message->setName(self::CONFIRMATION_MESSAGE_NAME)->setHtmlTemplateFileName(self::CONFIRMATION_MESSAGE_NAME . '.html')->setTextTemplateFileName(self::CONFIRMATION_MESSAGE_NAME . '.txt');
         foreach ($languages as $language) {
             /** @var Lang $language */
             $locale = $language->getLocale();
             $message->setLocale($locale)->setTitle(Translator::getInstance()->trans("Payment confirmation for Stripe Payment", [], self::MESSAGE_DOMAIN, $locale))->setSubject(Translator::getInstance()->trans('Payment confirmation of your order {$order_ref} on {$store_name}', [], self::MESSAGE_DOMAIN, $locale));
         }
         $message->save();
     }
 }
Beispiel #5
0
 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'));
     // Create payment confirmation message from templates, if not already defined
     $email_templates_dir = __DIR__ . DS . 'I18n' . DS . 'email-templates' . DS;
     if (null === MessageQuery::create()->findOneByName(self::CONFIRMATION_MESSAGE_NAME)) {
         $message = new Message();
         $message->setName(self::CONFIRMATION_MESSAGE_NAME)->setLocale('en_US')->setTitle('Payzen payment confirmation')->setSubject('Payment of order {$order_ref}')->setHtmlMessage(file_get_contents($email_templates_dir . 'en.html'))->setTextMessage(file_get_contents($email_templates_dir . 'en.txt'))->setLocale('fr_FR')->setTitle('Confirmation de paiement par PayZen')->setSubject('Confirmation du paiement de votre commande {$order_ref}')->setHtmlMessage(file_get_contents($email_templates_dir . 'fr.html'))->setTextMessage(file_get_contents($email_templates_dir . 'fr.txt'))->save();
     }
     /* Deploy the module's image */
     $module = $this->getModuleModel();
     if (ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
         $this->deployImageFolder($module, sprintf('%s/images', __DIR__), $con);
     }
 }
Beispiel #6
0
 /**
  * @inheritdoc
  */
 public function postActivation(ConnectionInterface $con = null)
 {
     // Create payment confirmation message from templates, if not already defined
     $email_templates_dir = __DIR__ . DS . 'I18n' . DS . 'email-templates' . DS;
     if (null === MessageQuery::create()->findOneByName(self::CONFIRMATION_MESSAGE_NAME)) {
         $message = new Message();
         $message->setName(self::CONFIRMATION_MESSAGE_NAME)->setLocale('en_US')->setTitle('Paybox payment confirmation')->setSubject('Payment of order {$order_ref}')->setHtmlMessage(file_get_contents($email_templates_dir . 'en.html'))->setTextMessage(file_get_contents($email_templates_dir . 'en.txt'))->setLocale('fr_FR')->setTitle('Confirmation de paiement par PayBox')->setSubject('Confirmation du paiement de votre commande {$order_ref}')->setHtmlMessage(file_get_contents($email_templates_dir . 'fr.html'))->setTextMessage(file_get_contents($email_templates_dir . 'fr.txt'))->save();
     }
     if (null === MessageQuery::create()->findOneByName(self::NOTIFICATION_MESSAGE_NAME)) {
         $message = new Message();
         $message->setName(self::NOTIFICATION_MESSAGE_NAME)->setLocale('en_US')->setTitle('Paybox payment status notification')->setSubject('Paybox payment status for order {$order_ref}: {$paybox_payment_status}')->setHtmlMessage(file_get_contents($email_templates_dir . 'notification-en.html'))->setTextMessage(file_get_contents($email_templates_dir . 'notification-en.txt'))->setLocale('fr_FR')->setTitle('Notification du résultat d\'un paiement par Paybox')->setSubject('Résultats du paiement Paybox de la commande {$order_ref} : {$paybox_payment_status}')->setHtmlMessage(file_get_contents($email_templates_dir . 'notification-fr.html'))->setTextMessage(file_get_contents($email_templates_dir . 'notification-fr.txt'))->save();
     }
     /* Deploy the module's image */
     $module = $this->getModuleModel();
     if (ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
         $this->deployImageFolder($module, sprintf('%s' . DS . 'images', __DIR__), $con);
     }
 }
 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();
     }
 }
Beispiel #8
0
 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']);
     }
 }
 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();
     }
 }
Beispiel #10
0
 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();
     }
 }
 /**
  * @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();
     }
 }
Beispiel #12
0
 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);
     }
 }
Beispiel #13
0
 /**
  * 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());
 }
Beispiel #14
0
 /**
  * Create a new messageuration entry
  *
  * @param \Thelia\Core\Event\Message\MessageCreateEvent $event
  */
 public function create(MessageCreateEvent $event)
 {
     $message = new MessageModel();
     $message->setDispatcher($event->getDispatcher())->setName($event->getMessageName())->setLocale($event->getLocale())->setTitle($event->getTitle())->setSecured($event->getSecured())->save();
     $event->setMessage($message);
 }
 /**
  * @param Message $object
  * @return int
  */
 protected function getObjectId($object)
 {
     return $object->getId();
 }
Beispiel #16
0
 /**
  * Exclude object from result
  *
  * @param   ChildMessage $message Object to remove from the list of results
  *
  * @return ChildMessageQuery The current query, for fluid interface
  */
 public function prune($message = null)
 {
     if ($message) {
         $this->addUsingAlias(MessageTableMap::ID, $message->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Beispiel #17
0
 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();
     }
 }
Beispiel #18
0
 /**
  * Filter the query by a related \Thelia\Model\Message object
  *
  * @param \Thelia\Model\Message|ObjectCollection $message The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildMessageVersionQuery The current query, for fluid interface
  */
 public function filterByMessage($message, $comparison = null)
 {
     if ($message instanceof \Thelia\Model\Message) {
         return $this->addUsingAlias(MessageVersionTableMap::ID, $message->getId(), $comparison);
     } elseif ($message instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(MessageVersionTableMap::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByMessage() only accepts arguments of type \\Thelia\\Model\\Message or Collection');
     }
 }
Beispiel #19
0
 /**
  * Declares an association between this object and a ChildMessage object.
  *
  * @param                  ChildMessage $v
  * @return                 \Thelia\Model\MessageVersion The current object (for fluent API support)
  * @throws PropelException
  */
 public function setMessage(ChildMessage $v = null)
 {
     if ($v === null) {
         $this->setId(NULL);
     } else {
         $this->setId($v->getId());
     }
     $this->aMessage = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildMessage object, it will not be re-added.
     if ($v !== null) {
         $v->addMessageVersion($this);
     }
     return $this;
 }