// Add mail with identifiers in installer + some missing trad

This commit is contained in:
rMalie
2012-02-08 16:07:41 +00:00
parent 641d84a277
commit a718f293c6
13 changed files with 278 additions and 25 deletions
+8 -6
View File
@@ -44,9 +44,6 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
{
require_once _PS_INSTALL_MODELS_PATH_.'database.php';
$this->model_database = new InstallModelDatabase();
require_once _PS_INSTALL_MODELS_PATH_.'mail.php';
$this->model_mail = new InstallModelMail();
}
/**
@@ -136,11 +133,16 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
$password = Tools::getValue('smtpPassword');
$email = Tools::getValue('testEmail');
$result = $this->model_mail->sendTestMail($smtp_checked, $server, $login, $password, $port, $encryption, $email);
require_once _PS_INSTALL_MODELS_PATH_.'mail.php';
$this->model_mail = new InstallModelMail($smtp_checked, $server, $login, $password, $port, $encryption, $email);
$result = $this->model_mail->send(
$this->l('Test message from PrestaShop'),
$this->l('This is a test message, your server is now available to send email')
);
$this->ajaxJsonAnswer(
(bool)$result,
($result) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters')
$result === false,
($result === false) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters')
);
}
+45
View File
@@ -93,6 +93,8 @@ class InstallControllerHttpProcess extends InstallControllerHttp
$this->processInstallFixtures();
else if (Tools::getValue('installTheme') && !empty($this->session->process_validated['installModules']))
$this->processInstallTheme();
else if (Tools::getValue('sendEmail') && !empty($this->session->process_validated['installTheme']))
$this->processSendEmail();
else
{
// With no parameters, we consider that we are doing a new install, so session where the last process step
@@ -235,6 +237,47 @@ class InstallControllerHttpProcess extends InstallControllerHttp
if ($this->model_install->getErrors())
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
$this->session->process_validated['installTheme'] = true;
$this->ajaxJsonAnswer(true);
}
/**
* PROCESS : sendEmail
* Send information e-mail
*/
public function processSendEmail()
{
require_once _PS_INSTALL_MODELS_PATH_.'mail.php';
$mail = new InstallModelMail(
$this->session->use_smtp,
$this->session->smtp_server,
$this->session->smtp_login,
$this->session->smtp_password,
$this->session->smtp_port,
$this->session->smtp_encryption,
$this->session->admin_email
);
if (file_exists(_PS_INSTALL_LANGS_PATH_.$this->language->getLanguageIso().'/mail_identifiers.txt'))
$content = file_get_contents(_PS_INSTALL_LANGS_PATH_.$this->language->getLanguageIso().'/mail_identifiers.txt');
else
$content = file_get_contents(_PS_INSTALL_LANGS_PATH_.InstallLanguages::DEFAULT_ISO.'/mail_identifiers.txt');
$vars = array(
'{firstname}' => $this->session->admin_firstname,
'{lastname}' => $this->session->admin_lastname,
'{shop_name}' => $this->session->shop_name,
'{passwd}' => $this->session->admin_password,
'{email}' => $this->session->admin_email,
'{shop_url}' => Tools::getHttpHost(true).__PS_BASE_URI__,
);
$content = str_replace(array_keys($vars), array_values($vars), $content);
$mail->send(
$this->l('%s - Login information', $this->session->shop_name),
$content
);
// If last step is fine, we store the fact PrestaShop is installed
$this->session->last_step = 'configure';
$this->session->step = 'configure';
@@ -256,6 +299,8 @@ class InstallControllerHttpProcess extends InstallControllerHttp
if ($this->session->install_type == 'full')
$this->process_steps[] = array('key' => 'installFixtures', 'lang' => $this->l('Install demonstration data'));
$this->process_steps[] = array('key' => 'installTheme', 'lang' => $this->l('Install theme'));
if ($this->session->send_informations)
$this->process_steps[] = array('key' => 'sendEmail', 'lang' => $this->l('Send information e-mail'));
$this->displayTemplate('process');
}
+32
View File
@@ -155,5 +155,37 @@
'I agree to the above terms and conditions.' => 'Ich stimme den oben genannten Vertragsbedingungen zu.',
'I agree to participate in improving the solution by sending anonymous information about my configuration.' => NULL,
'If you have any questions, please visit our <a href="%1$s" target="_blank">documentation</a> and <a href="%2$s" target="_blank">community forum</a>.' => NULL,
'Test message from PrestaShop' => 'Test-Mail - Installation von PrestaShop',
'This is a test message, your server is now available to send email' => 'Dies ist eine Testnachricht, Ihr E-Mail-Server funktioniert korrekt.',
'%s - Login information' => NULL,
'An SQL error occured for entity <i>%1$s</i>: <i>%2$s</i>' => NULL,
'Cannot create image "%1$s" for entity "%2$s"' => NULL,
'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => NULL,
'Cannot create image "%s"' => NULL,
'SQL error on query <i>%s</i>' => NULL,
'Server name is not valid' => NULL,
'You must enter a database name' => NULL,
'You must enter a database login' => NULL,
'Tables prefix is invalid' => NULL,
'Wrong engine chosen for MySQL' => NULL,
'Cannot convert database data to utf-8' => NULL,
'At least one table with same prefix was already found, please change your prefix or drop your database' => NULL,
'Database Server is not found. Please verify the login, password and server fields' => NULL,
'Connection to MySQL server succeeded, but database "%s" not found' => NULL,
'Engine innoDB is not supported by your MySQL server, please use MyISAM' => NULL,
'%s file is not writable (check permissions)' => NULL,
'%s folder is not writable (check permissions)' => NULL,
'Cannot write settings file' => NULL,
'Database structure file not found' => NULL,
'Cannot create group shop' => NULL,
'Cannot create shop' => NULL,
'Cannot create shop URL' => NULL,
'File "language.xml" not found for language iso "%s"' => NULL,
'File "language.xml" not valid for language iso "%s"' => NULL,
'Cannot install language "%s"' => NULL,
'Cannot create admin account' => NULL,
'Cannot install module "%s"' => NULL,
'Fixtures class "%s" not found' => NULL,
'"%s" must be an instane of "InstallXmlLoader"' => NULL,
),
);
@@ -0,0 +1,8 @@
Hallo {firstname} {lastname},
Ihre persönlichen Login-Daten
Kennwort: {passwd}
E-Mail-Adresse: {email}
{shop_name} powered with PrestaShop™
+10
View File
@@ -0,0 +1,10 @@
Hi {firstname} {lastname},
Here is your personal login information for {shop_name}:
Password: {passwd}
E-mail address: {email}
{shop_name} - {shop_url}
{shop_url} powered by PrestaShop™
+32
View File
@@ -155,5 +155,37 @@
'I agree to the above terms and conditions.' => 'Estoy de acuerdo con los términos y condiciones.',
'I agree to participate in improving the solution by sending anonymous information about my configuration.' => NULL,
'If you have any questions, please visit our <a href="%1$s" target="_blank">documentation</a> and <a href="%2$s" target="_blank">community forum</a>.' => NULL,
'Test message from PrestaShop' => 'Instalación Prestashop - Prueba del servidor de correo',
'This is a test message, your server is now available to send email' => 'Este es un mensaje de prueba, el servidor de correo funciona correctamente.',
'%s - Login information' => NULL,
'An SQL error occured for entity <i>%1$s</i>: <i>%2$s</i>' => NULL,
'Cannot create image "%1$s" for entity "%2$s"' => NULL,
'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => NULL,
'Cannot create image "%s"' => NULL,
'SQL error on query <i>%s</i>' => NULL,
'Server name is not valid' => NULL,
'You must enter a database name' => NULL,
'You must enter a database login' => NULL,
'Tables prefix is invalid' => NULL,
'Wrong engine chosen for MySQL' => NULL,
'Cannot convert database data to utf-8' => NULL,
'At least one table with same prefix was already found, please change your prefix or drop your database' => NULL,
'Database Server is not found. Please verify the login, password and server fields' => NULL,
'Connection to MySQL server succeeded, but database "%s" not found' => NULL,
'Engine innoDB is not supported by your MySQL server, please use MyISAM' => NULL,
'%s file is not writable (check permissions)' => NULL,
'%s folder is not writable (check permissions)' => NULL,
'Cannot write settings file' => NULL,
'Database structure file not found' => NULL,
'Cannot create group shop' => NULL,
'Cannot create shop' => NULL,
'Cannot create shop URL' => NULL,
'File "language.xml" not found for language iso "%s"' => NULL,
'File "language.xml" not valid for language iso "%s"' => NULL,
'Cannot install language "%s"' => NULL,
'Cannot create admin account' => NULL,
'Cannot install module "%s"' => NULL,
'Fixtures class "%s" not found' => NULL,
'"%s" must be an instane of "InstallXmlLoader"' => NULL,
),
);
+11
View File
@@ -0,0 +1,11 @@
Hola {firstname} {lastname},
Tu información personal en {shop_name} es:
* Contraseña: {passwd}
* Email: {email}
{shop_name} - {shop_url}
{shop_url} desarrollado por PrestaShop®
+37 -5
View File
@@ -50,7 +50,7 @@ return array(
'Shoes and accessories' => 'Chaussures et accessoires',
'Sports and Entertainment' => 'Sports et loisirs',
'Travel' => 'Voyage et tourisme',
'Database is connected' => 'La base de donnée est connectée',
'Database is connected' => 'La base de données est connectée',
'A test e-mail has been sent to %s' => 'Un e-mail de test a été envoyé à %s',
'An error occurred while sending email, please verify your parameters' => 'Une erreur est survenue lors de l\'envoi de l\'e-mail, merci de vérifier vos paramètres',
'Create settings.inc file' => 'Création du fichier settings.inc',
@@ -97,9 +97,9 @@ return array(
'Re-type to confirm:' => 'Confirmation du mot de passe :',
'Receive this information by e-mail' => 'Recevez ces informations par e-mail',
'Warning: You will recieve these informations only if your e-mail configuration is correct.' => 'Attention : vous ne recevrez ces informations que si votre configuration des e-mails est correcte',
'Configure your database by filling out the following fields:' => 'Configurez la connection à votre base de donnée en remplissant les champs suivants :',
'You have to create a database, help available in <a href="langs/%1$s/README.txt" target="_blank">~/install/langs/%1$s/README.txt</a>' => 'Vous devez créer une base de donnée, de l\'aide est disponible dans le fichier <a href="langs/%1$s/README.txt" target="_blank">~/install/langs/%1$s/README.txt</a>',
'You have to create a database, help available in <a href="README.txt" target="_blank">~/install/README.txt</a>' => 'Vous devez créer une base de donnée, de l\'aide est disponible dans le fichier <a href="README.txt" target="_blank">~/install/README.txt</a>',
'Configure your database by filling out the following fields:' => 'Configurez la connection à votre base de données en remplissant les champs suivants :',
'You have to create a database, help available in <a href="langs/%1$s/README.txt" target="_blank">~/install/langs/%1$s/README.txt</a>' => 'Vous devez créer une base de données, de l\'aide est disponible dans le fichier <a href="langs/%1$s/README.txt" target="_blank">~/install/langs/%1$s/README.txt</a>',
'You have to create a database, help available in <a href="README.txt" target="_blank">~/install/README.txt</a>' => 'Vous devez créer une base de données, de l\'aide est disponible dans le fichier <a href="README.txt" target="_blank">~/install/README.txt</a>',
'Database server address:' => 'Addresse du serveur de la base :',
'If you want to use a different port, add :XX after your server address where XX is your port number.' => 'Si vous souhaitez utiliser un port différent, ajoutez :XX à l\'adresse de votre serveur, XX étant le numéro de votre port.',
'Database name:' => 'Nom de la base :',
@@ -156,6 +156,38 @@ return array(
'PrestaShop core is released under the OSL 3.0 while PrestaShop modules and themes are released under the AFL 3.0.' => 'Le coeur de PrestaShop est publié sous licence OSL 3.0 tandis que les modules et thèmes sont publiés sous licence AFL 3.0.',
'I agree to the above terms and conditions.' => 'J\'approuve les termes et conditions du contrat ci-dessus.',
'I agree to participate in improving the solution by sending anonymous information about my configuration.' => 'J\'accepte de participer à l\'amélioration de la solution en envoyant des informations anonymes sur ma configuration',
'If you have any questions, please visit our <a href="%1$s" target="_blank">documentation</a> and <a href="%2$s" target="_blank">community forum</a>.' => 'Si vous avez la moindre question, n\'hésitez pas à visiter notre <a href="%1$s" target="_blank">documentation</a> et notre <a href="%2$s" target="_blank">forum communautaire</a>.'
'If you have any questions, please visit our <a href="%1$s" target="_blank">documentation</a> and <a href="%2$s" target="_blank">community forum</a>.' => 'Si vous avez la moindre question, n\'hésitez pas à visiter notre <a href="%1$s" target="_blank">documentation</a> et notre <a href="%2$s" target="_blank">forum communautaire</a>.',
'Test message from PrestaShop' => 'Message test de PrestaShop',
'This is a test message, your server is now available to send email' => 'Ceci est un message de test, votre serveur d\'email fonctionne correctement.',
'%s - Login information' => '%s - Identifiants de connection',
'An SQL error occured for entity <i>%1$s</i>: <i>%2$s</i>' => 'Une erreur SQL est survenue pour l\'entité <i>%1$s</i> : <i>%2$s</i>',
'Cannot create image "%1$s" for entity "%2$s"' => 'Impossible de créer l\'image "%1$s" pour l\'entité "%2$s"',
'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => 'Impossible de créer l\'image "%1$s" (mauvaises permissions sur le dossier "%2$s")',
'Cannot create image "%s"' => 'Impossible de créer l\'image "%s"',
'SQL error on query <i>%s</i>' => 'Erreur SQL sur la requête <i>%s</i>',
'Server name is not valid' => 'L\'adresse du serveur est invalide',
'You must enter a database name' => 'Vous devez choisir une base de données',
'You must enter a database login' => 'Vous devez entrer un identifiant pour la base',
'Tables prefix is invalid' => 'Le préfixe des tables est invalide',
'Wrong engine chosen for MySQL' => 'Moteur pour MySQL invalide',
'Cannot convert database data to utf-8' => 'Impossible de convertir la base en utf-8',
'At least one table with same prefix was already found, please change your prefix or drop your database' => 'Au moins une table avec le même préfixe a été trouvée, merci de changer votre préfixe ou de supprimer vos tables existantes',
'Database Server is not found. Please verify the login, password and server fields' => 'Impossible de se connecter au serveur de la base de données. Vérifiez vos identifiants de connection',
'Connection to MySQL server succeeded, but database "%s" not found' => 'La connection au serveur de base de données a réussi, mais la base "%s" n\'a pas été trouvée',
'Engine innoDB is not supported by your MySQL server, please use MyISAM' => 'Le moteur innoDB n\'est pas supporté par votre serveur SQL, merci d\'utiliser MyISAM',
'%s file is not writable (check permissions)' => 'Le fichier %s ne peut être écrit (vérifiez vos permissions fichiers)',
'%s folder is not writable (check permissions)' => 'Le dossier %s ne peut être écrit (vérifiez vos permissions fichiers)',
'Cannot write settings file' => 'Impossible de générer le fichier settings',
'Database structure file not found' => 'Le fichier de structure de base de donnée n\'a pu être trouvé',
'Cannot create group shop' => 'Impossible de créer le groupe de boutique',
'Cannot create shop' => 'Impossible de créer la boutique',
'Cannot create shop URL' => 'Impossible de créer l\'URL pour la boutique',
'File "language.xml" not found for language iso "%s"' => 'Le fichier "language.xml" n\'a pas été trouvé pour l\'iso "%s"',
'File "language.xml" not valid for language iso "%s"' => 'Le fichier "language.xml" est invalide pour l\'iso "%s"',
'Cannot install language "%s"' => 'Impossible d\'installer la langue "%s"',
'Cannot create admin account' => 'Impossible de créer le compte administrateur',
'Cannot install module "%s"' => 'Impossible d\'installer le module "%s"',
'Fixtures class "%s" not found' => 'La classe "%s" pour les fixtures n\'a pas été trouvée',
'"%s" must be an instane of "InstallXmlLoader"' => '"%s" doit être une instance de "InstallXmlLoader"',
),
);
+13
View File
@@ -0,0 +1,13 @@
Bonjour {firstname} {lastname},
Voici les informations personnelles concernant votre nouvelle boutique {shop_name} :
Mot de passe : {passwd}
Adresse électronique : {email}
{shop_name} - {shop_url}
{shop_url} réalisé par PrestaShop™
+32
View File
@@ -155,5 +155,37 @@
'I agree to the above terms and conditions.' => 'Accetto i termini e le condizioni del contratto seguente.',
'I agree to participate in improving the solution by sending anonymous information about my configuration.' => NULL,
'If you have any questions, please visit our <a href="%1$s" target="_blank">documentation</a> and <a href="%2$s" target="_blank">community forum</a>.' => NULL,
'Test message from PrestaShop' => 'Installazione di Prestashop - prova del server di e-mail',
'This is a test message, your server is now available to send email' => 'Questo è un messaggio di testo. Il tuo server è adesso impostato per inviare e-mail.',
'%s - Login information' => NULL,
'An SQL error occured for entity <i>%1$s</i>: <i>%2$s</i>' => NULL,
'Cannot create image "%1$s" for entity "%2$s"' => NULL,
'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => NULL,
'Cannot create image "%s"' => NULL,
'SQL error on query <i>%s</i>' => NULL,
'Server name is not valid' => NULL,
'You must enter a database name' => NULL,
'You must enter a database login' => NULL,
'Tables prefix is invalid' => NULL,
'Wrong engine chosen for MySQL' => NULL,
'Cannot convert database data to utf-8' => NULL,
'At least one table with same prefix was already found, please change your prefix or drop your database' => NULL,
'Database Server is not found. Please verify the login, password and server fields' => NULL,
'Connection to MySQL server succeeded, but database "%s" not found' => NULL,
'Engine innoDB is not supported by your MySQL server, please use MyISAM' => NULL,
'%s file is not writable (check permissions)' => NULL,
'%s folder is not writable (check permissions)' => NULL,
'Cannot write settings file' => NULL,
'Database structure file not found' => NULL,
'Cannot create group shop' => NULL,
'Cannot create shop' => NULL,
'Cannot create shop URL' => NULL,
'File "language.xml" not found for language iso "%s"' => NULL,
'File "language.xml" not valid for language iso "%s"' => NULL,
'Cannot install language "%s"' => NULL,
'Cannot create admin account' => NULL,
'Cannot install module "%s"' => NULL,
'Fixtures class "%s" not found' => NULL,
'"%s" must be an instane of "InstallXmlLoader"' => NULL,
),
);
+12
View File
@@ -0,0 +1,12 @@
Salve {firstname} {lastname},
I dati personali di login del tuo negozio {shop_name}:
* Password: {passwd}
* Indirizzo e-mail: {email}
{shop_name} - {shop_url}
{shop_url} powered by PrestaShop™
+1 -1
View File
@@ -114,7 +114,7 @@ class InstallModelInstall extends InstallAbstractModel
if ($errors = $sql_loader->getErrors())
{
foreach ($errors as $error)
$this->setError($this->language->l('An SQL error occured: <i>%1$s</i>', $error['error']));
$this->setError($this->language->l('SQL error on query <i>%s</i>', $error['error']));
return false;
}
+37 -13
View File
@@ -28,23 +28,49 @@
class InstallModelMail extends InstallAbstractModel
{
/**
* Send a test email
* @param bool $smtp_checked
* @param string $server
* @param string $login
* @param string $password
* @param int $port
* @param string $encryption
* @param string $email
*/
public function sendTestMail($smtp_checked, $server, $login, $password, $port, $encryption, $email)
public function __construct($smtp_checked, $server, $login, $password, $port, $encryption, $email)
{
parent::__construct();
require_once(_PS_INSTALL_PATH_.'../tools/swift/Swift.php');
require_once(_PS_INSTALL_PATH_.'../tools/swift/Swift/Connection/SMTP.php');
require_once(_PS_INSTALL_PATH_.'../tools/swift/Swift/Connection/NativeMail.php');
$this->smtp_checked = $smtp_checked;
$this->server = $server;
$this->login = $login;
$this->password = $password;
$this->port = $port;
$this->encryption = $encryption;
$this->email = $email;
}
/**
* Send a mail
*
* @param string $subject
* @param string $content
* @return bool|string false is everything was fine, or error string
*/
public function send($subject, $content)
{
try
{
// Test with custom SMTP connection
if ($smtp_checked)
if ($this->smtp_checked)
{
$smtp = new Swift_Connection_SMTP($server, $port, ($encryption == "off") ? Swift_Connection_SMTP::ENC_OFF : (($encryption == "tls") ? Swift_Connection_SMTP::ENC_TLS : Swift_Connection_SMTP::ENC_SSL));
$smtp->setUsername($login);
$smtp->setpassword($password);
$smtp = new Swift_Connection_SMTP($this->server, $this->port, ($this->encryption == "off") ? Swift_Connection_SMTP::ENC_OFF : (($this->encryption == "tls") ? Swift_Connection_SMTP::ENC_TLS : Swift_Connection_SMTP::ENC_SSL));
$smtp->setUsername($this->login);
$smtp->setpassword($this->password);
$smtp->setTimeout(5);
$swift = new Swift($smtp);
}
@@ -52,22 +78,20 @@ class InstallModelMail extends InstallAbstractModel
// Test with normal PHP mail() call
$swift = new Swift(new Swift_Connection_NativeMail());
$subject = $this->language->l('Test message from PrestaShop');
$content = $this->language->l('This is a test message, your server is now available to send email');
$message = new Swift_Message($subject, $content, 'text/html');
if (@$swift->send($message, $email, 'no-reply@'.Tools::getHttpHost()))
$result = true;
if (@$swift->send($message, $this->email, 'no-reply@'.Tools::getHttpHost()))
$result = false;
else
$result = 999;
$result = 'Could not send message';
$swift->disconnect();
}
catch (Swift_Exception $e)
{
$result = $e->getCode();
$result = $e->getMessage();
}
return $result;
}
}