public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, [__DIR__ . '/Config/thelia.sql']);
     // Add order-invoice.before-discount hook if not already defined
     if (null === HookQuery::create()->findOneByCode('order-invoice.before-discount')) {
         try {
             $hookEvent = new HookCreateEvent();
             $hookEvent->setCode('order-invoice.before-discount')->setType(TemplateDefinition::FRONT_OFFICE)->setNative(false)->setActive(true)->setLocale('en_US')->setTitle("Before discount code form block");
             $this->getDispatcher()->dispatch(TheliaEvents::HOOK_CREATE, $hookEvent);
             if ($hookEvent->hasHook()) {
                 // Assign module to this hook
                 $moduleHookEvent = new ModuleHookCreateEvent();
                 $moduleHookEvent->setModuleId($this->getModuleId())->setHookId($hookEvent->getHook()->getId())->setClassname('creditaccount.order_invoice.hook')->setMethod('orderInvoiceForm');
                 // Activate module hook
                 $this->getDispatcher()->dispatch(TheliaEvents::MODULE_HOOK_CREATE, $moduleHookEvent);
                 if ($moduleHookEvent->hasModuleHook()) {
                     $event = new ModuleHookToggleActivationEvent($moduleHookEvent->getModuleHook());
                     $this->getDispatcher()->dispatch(TheliaEvents::MODULE_HOOK_TOGGLE_ACTIVATION, $event);
                 }
             }
         } catch (\Exception $ex) {
             throw new TheliaProcessException(Translator::getInstance()->trans("Failed to put module in 'order-invoice.before-discount' hook (%err)", ['%err' => $ex->getMessage()]), $ex);
         }
     }
 }
 public function postActivation(ConnectionInterface $con = null)
 {
     try {
         OrderCommentQuery::create()->findOne();
     } catch (\Exception $e) {
         $database = new Database($con->getWrappedConnection());
         $database->insertSql(null, array(THELIA_ROOT . '/local/modules/OrderComment/Config/thelia.sql'));
     }
 }
Example #3
0
 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     // Insert email message
     $database->insertSql(null, array(__DIR__ . "/Config/setup.sql"));
     /* insert the images from image folder if not already done */
     $moduleModel = $this->getModuleModel();
     if (!$moduleModel->isModuleImageDeployed($con)) {
         $this->deployImageFolder($moduleModel, sprintf('%s/images', __DIR__), $con);
     }
 }
 /**
  * @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();
     }
 }
Example #5
0
 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
 }
 public function postActivation(ConnectionInterface $con = null)
 {
     return;
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
     /* insert the images from image folder if first module activation */
     $module = $this->getModuleModel();
     if (ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
         $this->deployImageFolder($module, sprintf('%s/images', __DIR__), $con);
     }
     /* set module title */
     $this->setTitle($module, array("de_DE" => "BitpayPayments", "en_US" => "BitpayPayments", "fr_FR" => "BitpayPayments"));
 }
Example #7
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();
     }
 }
Example #8
0
 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     // Insert email message
     $database->insertSql(null, array(__DIR__ . "/Config/setup.sql"));
 }
Example #9
0
 public function update($currentVersion, $newVersion, ConnectionInterface $con)
 {
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, array(__DIR__ . '/Config/update.sql'));
 }
 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, array(THELIA_ROOT . '/local/modules/OpenSearchServerSearch/Config/thelia.sql'));
 }