forked from roadster31/BetterContact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterContact.php
54 lines (45 loc) · 2.34 KB
/
BetterContact.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : [email protected] */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace BetterContact;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Base\MessageQuery;
use Thelia\Model\Message;
use Thelia\Module\BaseModule;
class BetterContact extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'bettercontact';
const FORM_NAME = 'bettercontact.form';
const MESSAGE_NAME = 'bettercontact.mail_template';
public function postActivation(ConnectionInterface $con = null)
{
// Create messages from templates, if not already defined
$email_templates_dir = __DIR__.DS.'I18n'.DS.'email-templates'.DS;
if (null === MessageQuery::create()->findOneByName(self::MESSAGE_NAME)) {
$message = new Message();
$message
->setName(self::MESSAGE_NAME)
->setLocale('en_US')
->setTitle('Contact form message')
->setSubject('A new contact message was just sent')
->setHtmlMessage(file_get_contents($email_templates_dir.'en.html'))
->setTextMessage(file_get_contents($email_templates_dir.'en.txt'))
->setLocale('fr_FR')
->setTitle('Message de contact')
->setSubject('Un nouveau message de contact vient d\'être expédié')
->setHtmlMessage(file_get_contents($email_templates_dir.'fr.html'))
->setTextMessage(file_get_contents($email_templates_dir.'fr.txt'))
->save()
;
}
}
}