diff --git a/app/bundles/ConfigBundle/Form/Type/ConfigType.php b/app/bundles/ConfigBundle/Form/Type/ConfigType.php index c23b9242f35..30a250c9fd0 100644 --- a/app/bundles/ConfigBundle/Form/Type/ConfigType.php +++ b/app/bundles/ConfigBundle/Form/Type/ConfigType.php @@ -108,6 +108,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'mautic.transport.mandrill' => 'mautic.core.config.mailer_transport.mandrill', 'mautic.transport.sendgrid' => 'mautic.core.config.mailer_transport.sendgrid', 'mautic.transport.amazon' => 'mautic.core.config.mailer_transport.amazon', + 'mautic.transport.postmark' => 'mautic.core.config.mailer_transport.postmark', 'gmail' => 'mautic.core.config.mailer_transport.gmail', 'sendmail' => 'mautic.core.config.mailer_transport.sendmail', 'smtp' => 'mautic.core.config.mailer_transport.smtp' diff --git a/app/bundles/CoreBundle/Config/parameters.php b/app/bundles/CoreBundle/Config/parameters.php index 5dae6b0e3a4..36161bb4442 100644 --- a/app/bundles/CoreBundle/Config/parameters.php +++ b/app/bundles/CoreBundle/Config/parameters.php @@ -21,6 +21,7 @@ 'mailer_from_email' => 'email@yoursite.com', 'mailer_transport' => 'mail', 'mailer_host' => '', + 'mailer_port' => null, 'mailer_user' => null, 'mailer_password' => null, 'mailer_encryption' => null, //tls or ssl, diff --git a/app/bundles/CoreBundle/Config/services/mailers.php b/app/bundles/CoreBundle/Config/services/mailers.php index 1554c702131..8770fdb3d10 100644 --- a/app/bundles/CoreBundle/Config/services/mailers.php +++ b/app/bundles/CoreBundle/Config/services/mailers.php @@ -25,4 +25,10 @@ new Definition ( 'Mautic\CoreBundle\Swiftmailer\Transport\SendgridTransport' ) +); + +$container->setDefinition('mautic.transport.postmark', + new Definition ( + 'Mautic\CoreBundle\Swiftmailer\Transport\PostmarkTransport' + ) ); \ No newline at end of file diff --git a/app/bundles/CoreBundle/Swiftmailer/Transport/PostmarkTransport.php b/app/bundles/CoreBundle/Swiftmailer/Transport/PostmarkTransport.php new file mode 100644 index 00000000000..a7741f4b5b2 --- /dev/null +++ b/app/bundles/CoreBundle/Swiftmailer/Transport/PostmarkTransport.php @@ -0,0 +1,24 @@ +<?php +/** + * @package Mautic + * @copyright 2014 Mautic Contributors. All rights reserved. + * @author Mautic + * @link http://mautic.org + * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html + */ + +namespace Mautic\CoreBundle\Swiftmailer\Transport; + +/** + * Class PostmarkTransport + */ +class PostmarkTransport extends \Swift_SmtpTransport +{ + /** + * {@inheritdoc} + */ + public function __construct($host = 'localhost', $port = 25, $security = null) + { + parent::__construct('smtp.postmarkapp.com', 587, 'tls'); + } +} diff --git a/app/bundles/CoreBundle/Translations/en_US/messages.ini b/app/bundles/CoreBundle/Translations/en_US/messages.ini index 26e89a2342c..828a625f17f 100644 --- a/app/bundles/CoreBundle/Translations/en_US/messages.ini +++ b/app/bundles/CoreBundle/Translations/en_US/messages.ini @@ -174,6 +174,7 @@ mautic.core.config.mailer_transport.gmail="Gmail" mautic.core.config.mailer_transport.mail="PHP Mail" mautic.core.config.mailer_transport.sendmail="Sendmail" mautic.core.config.mailer_transport.smtp="Other SMTP Server" +mautic.core.config.mailer_transport.postmark="Postmark" mautic.core.config.mailer_encryption.ssl="SSL" mautic.core.config.mailer_encryption.tls="TLS" @@ -193,6 +194,7 @@ mautic.config.CoreBundle.mailer_from_name="Name to Send Mail As" mautic.config.CoreBundle.mailer_from_email="E-mail Address to Send Mail From" mautic.config.CoreBundle.mailer_transport="Mail Transport" mautic.config.CoreBundle.mailer_host="Host to Send Mail From" +mautic.config.CoreBundle.mailer_port="SMTP Port" mautic.config.CoreBundle.mailer_user="Username for Account Mail is Sent From" mautic.config.CoreBundle.mailer_password="Password for Account Mail is Sent From" mautic.config.CoreBundle.mailer_encryption="Encryption Type for Mail" diff --git a/app/bundles/InstallBundle/Configurator/Form/CheckStepType.php b/app/bundles/InstallBundle/Configurator/Form/CheckStepType.php index 71fa610ea58..6eab72560e2 100644 --- a/app/bundles/InstallBundle/Configurator/Form/CheckStepType.php +++ b/app/bundles/InstallBundle/Configurator/Form/CheckStepType.php @@ -29,14 +29,15 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'mautic.install.next.step', 'type' => 'submit', 'attr' => array( - 'class' => 'btn btn-success pull-right mt-20', - 'icon' => 'fa fa-arrow-circle-right' + 'class' => 'btn btn-success pull-right btn-next', + 'icon' => 'fa fa-arrow-circle-right', + 'onclick' => 'MauticInstaller.showWaitMessage(event);' ) ) ), - 'apply_text' => '', - 'save_text' => '', - 'cancel_text' => '' + 'apply_text' => '', + 'save_text' => '', + 'cancel_text' => '' )); if (!empty($options['action'])) { diff --git a/app/bundles/InstallBundle/Configurator/Form/DoctrineStepType.php b/app/bundles/InstallBundle/Configurator/Form/DoctrineStepType.php index f4b71ed6866..cbfe7273cfd 100644 --- a/app/bundles/InstallBundle/Configurator/Form/DoctrineStepType.php +++ b/app/bundles/InstallBundle/Configurator/Form/DoctrineStepType.php @@ -31,7 +31,7 @@ public function buildForm (FormBuilderInterface $builder, array $options) 'choices' => DoctrineStep::getDrivers(), 'expanded' => false, 'multiple' => false, - 'label' => 'mautic.install.install.form.database.driver', + 'label' => 'mautic.install.form.database.driver', 'label_attr' => array('class' => 'control-label'), 'empty_value' => false, 'required' => true, @@ -41,42 +41,42 @@ public function buildForm (FormBuilderInterface $builder, array $options) )); $builder->add('host', 'text', array( - 'label' => 'mautic.install.install.form.database.host', + 'label' => 'mautic.install.form.database.host', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => true )); $builder->add('port', 'text', array( - 'label' => 'mautic.install.install.form.database.port', + 'label' => 'mautic.install.form.database.port', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => false )); $builder->add('name', 'text', array( - 'label' => 'mautic.install.install.form.database.name', + 'label' => 'mautic.install.form.database.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => true )); $builder->add('table_prefix', 'text', array( - 'label' => 'mautic.install.install.form.database.table.prefix', + 'label' => 'mautic.install.form.database.table.prefix', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => false )); $builder->add('user', 'text', array( - 'label' => 'mautic.install.install.form.database.user', + 'label' => 'mautic.install.form.database.user', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => true )); $builder->add('password', 'password', array( - 'label' => 'mautic.install.install.form.database.password', + 'label' => 'mautic.install.form.database.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array( 'class' => 'form-control', @@ -92,13 +92,19 @@ public function buildForm (FormBuilderInterface $builder, array $options) ), 'label' => 'mautic.install.form.existing_tables', 'expanded' => true, - 'empty_value' => false + 'empty_value' => false, + 'attr' => array( + 'tooltip' => 'mautic.install.form.existing_tables_descr', + 'onchange' => 'MauticInstaller.toggleBackupPrefix();' + ) )); $builder->add('backup_prefix', 'text', array( 'label' => 'mautic.install.form.backup_prefix', 'label_attr' => array('class' => 'control-label'), - 'attr' => array('class' => 'form-control'), + 'attr' => array( + 'class' => 'form-control' + ), 'required' => false )); @@ -109,8 +115,9 @@ public function buildForm (FormBuilderInterface $builder, array $options) 'label' => 'mautic.install.next.step', 'type' => 'submit', 'attr' => array( - 'class' => 'btn btn-success pull-right mt-20', - 'icon' => 'fa fa-arrow-circle-right' + 'class' => 'btn btn-success pull-right btn-next', + 'icon' => 'fa fa-arrow-circle-right', + 'onclick' => 'MauticInstaller.showWaitMessage(event);' ) ) ), diff --git a/app/bundles/InstallBundle/Configurator/Form/EmailStepType.php b/app/bundles/InstallBundle/Configurator/Form/EmailStepType.php new file mode 100644 index 00000000000..333f4e0fad8 --- /dev/null +++ b/app/bundles/InstallBundle/Configurator/Form/EmailStepType.php @@ -0,0 +1,189 @@ +<?php +/** + * @package Mautic + * @copyright 2014 Mautic Contributors. All rights reserved. + * @author Mautic + * @link http://mautic.org + * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html + */ + +namespace Mautic\InstallBundle\Configurator\Form; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; +use Symfony\Component\Form\FormBuilderInterface; + +/** + * Email Form Type. + */ +class EmailStepType extends AbstractType +{ + /** + * {@inheritdoc} + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('mailer_from_name', 'text', array( + 'label' => false, + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control', + 'placeholder' => 'mautic.install.form.email.from_name' + ), + 'required' => true + )); + + $builder->add('mailer_from_email', 'email', array( + 'label' => false, + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control', + 'preaddon' => 'fa fa-envelope', + 'placeholder' => 'mautic.install.form.email.from_address', + ), + 'required' => true + )); + + $builder->add('mailer_transport', 'choice', array( + 'choices' => array( + 'mail' => 'mautic.core.config.mailer_transport.mail', + 'mautic.transport.mandrill' => 'mautic.core.config.mailer_transport.mandrill', + 'mautic.transport.sendgrid' => 'mautic.core.config.mailer_transport.sendgrid', + 'mautic.transport.amazon' => 'mautic.core.config.mailer_transport.amazon', + 'mautic.transport.postmark' => 'mautic.core.config.mailer_transport.postmark', + 'gmail' => 'mautic.core.config.mailer_transport.gmail', + 'smtp' => 'mautic.core.config.mailer_transport.smtp', + 'sendmail' => 'mautic.core.config.mailer_transport.sendmail' + ), + 'label' => 'mautic.install.form.email.transport', + 'label_attr' => array('class' => 'control-label'), + 'empty_value' => false, + 'attr' => array( + 'class' => 'form-control', + 'tooltip' => 'mautic.install.form.email.transport_descr', + 'onchange' => 'MauticInstaller.toggleTransportDetails(this.value);' + ) + )); + + $builder->add('mailer_host', 'text', array( + 'label' => 'mautic.install.form.email.mailer_host', + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control' + ) + )); + + $builder->add('mailer_port', 'text', array( + 'label' => 'mautic.install.form.email.mailer_port', + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control' + ) + )); + + $builder->add('mailer_user', 'text', array( + 'label' => 'mautic.install.form.email.mailer_user', + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control' + ) + )); + + $builder->add('mailer_password', 'password', array( + 'label' => 'mautic.install.form.email.mailer_password', + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control', + 'preaddon' => 'fa fa-lock' + ) + )); + + $builder->add('mailer_encryption', 'button_group', array( + 'choice_list' => new ChoiceList( + array('tls', 'ssl'), + array('mautic.install.form.email.encryption_tls', 'mautic.install.form.email.encryption_ssl') + ), + 'label' => 'mautic.install.form.email.encryption', + 'expanded' => true, + 'empty_value' => 'mautic.install.form.none' + )); + + $builder->add('mailer_auth_mode', 'choice', array( + 'choice_list' => new ChoiceList( + array( + 'plain', + 'login', + 'cram-md5' + ), + array( + 'mautic.install.form.email.auth_mode_plain', + 'mautic.install.form.email.auth_mode_login', + 'mautic.install.form.email.auth_mode_cram-md5' + ) + ), + 'label' => 'mautic.install.form.email.auth_mode', + 'label_attr' => array('class' => 'control-label'), + 'empty_value' => 'mautic.install.form.none', + 'attr' => array( + 'class' => 'form-control', + 'onchange' => 'MauticInstaller.toggleAuthDetails(this.value);' + ) + )); + + $builder->add('mailer_spool_type', 'button_group', array( + 'choice_list' => new ChoiceList( + array('memory', 'file'), + array( + 'mautic.install.form.email.spool_memory', + 'mautic.install.form.email.spool_file' + ) + ), + 'label' => 'mautic.install.form.email.spool_type', + 'expanded' => true, + 'empty_value' => false, + 'attr' => array( + 'onchange' => 'MauticInstaller.toggleSpoolQueue();' + ) + )); + + $builder->add('mailer_spool_path', 'text', array( + 'label' => 'mautic.install.form.email.spool_path', + 'label_attr' => array('class' => 'control-label'), + 'attr' => array( + 'class' => 'form-control', + 'tooltip' => 'mautic.install.form.email.spool_path_descr' + ) + )); + + $builder->add('buttons', 'form_buttons', array( + 'pre_extra_buttons' => array( + array( + 'name' => 'next', + 'label' => 'mautic.install.next.step', + 'type' => 'submit', + 'attr' => array( + 'class' => 'btn btn-success pull-right btn-next', + 'icon' => 'fa fa-arrow-circle-right', + 'onclick' => 'MauticInstaller.showWaitMessage(event);' + ) + ) + ), + 'apply_text' => '', + 'save_text' => '', + 'cancel_text' => '' + )); + + + if (!empty($options['action'])) { + $builder->setAction($options['action']); + } + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'install_email_step'; + } +} diff --git a/app/bundles/InstallBundle/Configurator/Form/StatsStepType.php b/app/bundles/InstallBundle/Configurator/Form/StatsStepType.php index 951efcadf9e..bee4e6188b1 100644 --- a/app/bundles/InstallBundle/Configurator/Form/StatsStepType.php +++ b/app/bundles/InstallBundle/Configurator/Form/StatsStepType.php @@ -28,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) array(false, true), array('mautic.core.form.no', 'mautic.core.form.yes') ), - 'label' => 'mautic.install.install.form.stats.send_stats', + 'label' => 'mautic.install.form.stats.send_stats', 'expanded' => true, 'empty_value' => false )); @@ -40,16 +40,18 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'mautic.install.next.step', 'type' => 'submit', 'attr' => array( - 'class' => 'btn btn-success pull-right mt-20', - 'icon' => 'fa fa-arrow-circle-right' + 'class' => 'btn btn-success pull-right btn-next', + 'icon' => 'fa fa-arrow-circle-right', + 'onclick' => 'MauticInstaller.showWaitMessage(event);' ) ) ), - 'apply_text' => '', - 'save_text' => '', - 'cancel_text' => '' + 'apply_text' => '', + 'save_text' => '', + 'cancel_text' => '' )); + if (!empty($options['action'])) { $builder->setAction($options['action']); } diff --git a/app/bundles/InstallBundle/Configurator/Form/UserStepType.php b/app/bundles/InstallBundle/Configurator/Form/UserStepType.php index 332e2fb9bb2..89edaf98fc7 100644 --- a/app/bundles/InstallBundle/Configurator/Form/UserStepType.php +++ b/app/bundles/InstallBundle/Configurator/Form/UserStepType.php @@ -11,6 +11,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Validator\Constraints as Assert; /** * User Form Type. @@ -23,37 +24,40 @@ class UserStepType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstname', 'text', array( - 'label' => 'mautic.install.install.form.user.firstname', + 'label' => 'mautic.install.form.user.firstname', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => true )); $builder->add('lastname', 'text', array( - 'label' => 'mautic.install.install.form.user.lastname', + 'label' => 'mautic.install.form.user.lastname', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => true )); $builder->add('email', 'email', array( - 'label' => 'mautic.install.install.form.user.email', + 'label' => 'mautic.install.form.user.email', 'label_attr' => array('class' => 'control-label'), 'attr' => array( 'class' => 'form-control', 'preaddon' => 'fa fa-envelope' - ) + ), + 'required' => true )); $builder->add('username', 'text', array( - 'label' => 'mautic.install.install.form.user.username', + 'label' => 'mautic.install.form.user.username', 'label_attr' => array('class' => 'control-label'), - 'attr' => array('class' => 'form-control'), + 'attr' => array( + 'class' => 'form-control' + ), 'required' => true )); $builder->add('password', 'password', array( - 'label' => 'mautic.install.install.form.user.password', + 'label' => 'mautic.install.form.user.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array( 'class' => 'form-control', @@ -70,8 +74,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'mautic.install.next.step', 'type' => 'submit', 'attr' => array( - 'class' => 'btn btn-success pull-right mt-20', - 'icon' => 'fa fa-arrow-circle-right' + 'class' => 'btn btn-success pull-right btn-next', + 'icon' => 'fa fa-arrow-circle-right', + 'onclick' => 'MauticInstaller.showWaitMessage(event);' ) ) ), diff --git a/app/bundles/InstallBundle/Configurator/Step/DoctrineStep.php b/app/bundles/InstallBundle/Configurator/Step/DoctrineStep.php index 1265ea50c58..e946e2890b1 100644 --- a/app/bundles/InstallBundle/Configurator/Step/DoctrineStep.php +++ b/app/bundles/InstallBundle/Configurator/Step/DoctrineStep.php @@ -29,7 +29,7 @@ class DoctrineStep implements StepInterface /** * Database host * - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") */ public $host = 'localhost'; @@ -50,13 +50,13 @@ class DoctrineStep implements StepInterface /** * Database name * - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") */ public $name; /** * Database user - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") */ public $user; diff --git a/app/bundles/InstallBundle/Configurator/Step/EmailStep.php b/app/bundles/InstallBundle/Configurator/Step/EmailStep.php new file mode 100644 index 00000000000..ef66a739a5d --- /dev/null +++ b/app/bundles/InstallBundle/Configurator/Step/EmailStep.php @@ -0,0 +1,143 @@ +<?php +/** + * @package Mautic + * @copyright 2014 Mautic Contributors. All rights reserved. + * @author Mautic + * @link http://mautic.org + * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html + */ + +namespace Mautic\InstallBundle\Configurator\Step; + +use Mautic\InstallBundle\Configurator\Form\EmailStepType; +use Mautic\InstallBundle\Configurator\Form\StatsStepType; + +/** + * Email Step. + */ +class EmailStep implements StepInterface +{ + + /** + * From name for email sent from Mautic + * + * @var string + */ + var $mailer_from_name; + + /** + * From email sent from Mautic + * + * @var string + */ + var $mailer_from_email; + + /** + * Mail transport + * + * @var string + */ + var $mailer_transport = 'mail'; + + /** + * SMTP host + * + * @var string + */ + var $mailer_host; + + /** + * SMTP port + * + * @var string + */ + var $mailer_port; + + /** + * SMTP username + * + * @var string + */ + var $mailer_user; + + /** + * SMTP password + * + * @var string + */ + var $mailer_password; + + /** + * SMTP encryption + * + * @var string + */ + var $mailer_encryption; // null|tls|ssl + + /** + * SMTP auth mode + * + * @var string + */ + var $mailer_auth_mode; // null|plain|login|cram-md5 + + /** + * Spool mode + * + * @var string + */ + var $mailer_spool_type = 'memory'; // file|memory + + /** + * Spool path + * + * @var string + */ + var $mailer_spool_path = "%kernel.root_dir%/spool"; + + /** + * {@inheritdoc} + */ + public function getFormType() + { + return new EmailStepType(); + } + + /** + * {@inheritdoc} + */ + public function checkRequirements() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function checkOptionalSettings() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getTemplate() + { + return 'MauticInstallBundle:Install:email.html.php'; + } + + /** + * {@inheritdoc} + */ + public function update(StepInterface $data) + { + $parameters = array(); + + foreach ($data as $key => $value) { + $parameters[$key] = $value; + } + + return $parameters; + } +} diff --git a/app/bundles/InstallBundle/Configurator/Step/UserStep.php b/app/bundles/InstallBundle/Configurator/Step/UserStep.php index 254cdad14f2..4543bfeeb4d 100644 --- a/app/bundles/InstallBundle/Configurator/Step/UserStep.php +++ b/app/bundles/InstallBundle/Configurator/Step/UserStep.php @@ -20,36 +20,37 @@ class UserStep implements StepInterface /** * User's first name * - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") */ public $firstname; /** * User's last name * - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") */ public $lastname; /** * User's e-mail address * - * @Assert\NotBlank - * @Assert\Email + * @Assert\NotBlank(message = "mautic.install.notblank") + * @Assert\Email(message = "mautic.install.invalidemail") */ public $email; /** * User's username * - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") */ public $username; /** * User's password * - * @Assert\NotBlank + * @Assert\NotBlank(message = "mautic.install.notblank") + * @Assert\Length(min = 6, minMessage = "mautic.install.password.minlength") */ public $password; diff --git a/app/bundles/InstallBundle/Controller/InstallController.php b/app/bundles/InstallBundle/Controller/InstallController.php index 2be4d78c00d..9a4a7cfd4a8 100644 --- a/app/bundles/InstallBundle/Controller/InstallController.php +++ b/app/bundles/InstallBundle/Controller/InstallController.php @@ -21,6 +21,7 @@ use Mautic\InstallBundle\Configurator\Step\DoctrineStep; use Mautic\UserBundle\Entity\User; use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; +use Symfony\Component\Form\FormError; use Symfony\Component\Process\Exception\RuntimeException; /** @@ -92,12 +93,12 @@ public function stepAction ($index = 0) } // Post-step processing - $flashes = array(); + $flashes = array(); + $originalData = $form->getData(); + $success = true; switch ($index) { case 1: - $originalData = $form->getData(); - //let's create a dynamic details $dbParams = (array)$originalData; $dbParams['dbname'] = $dbParams['name']; @@ -120,97 +121,121 @@ public function stepAction ($index = 0) break; case 2: - $result = $this->performUserAddition($form); - if (is_array($result)) { - $flashes[] = $result; - } + $entityManager = $this->getEntityManager(); + + //ensure the username and email are unique + $existing = $entityManager->getRepository('MauticUserBundle:User')->checkUniqueUsernameEmail(array( + 'username' => $originalData->username, + 'email' => $originalData->email + )); + + if (!empty($existing)) { + $translator = $this->factory->getTranslator(); + if ($existing[0]->getEmail() == $originalData->email) { + $form['email']->addError(new FormError( + $translator->trans('mautic.user.user.email.unique', array(), 'validators') + )); + } - break; + if ($existing[0]->getUsername() == $originalData->username) { + $form['username']->addError(new FormError( + $translator->trans('mautic.user.user.username.unique', array(), 'validators') + )); + } - default: - $result = true; - } + $success = false; + } else { + $result = $this->performUserAddition($form); + if (is_array($result)) { + $flashes[] = $result; + } + } - // On a failure, the result will be an array; for success it will be a boolean - if (!empty($flashes)) { - return $this->postActionRedirect(array( - 'viewParameters' => array( - 'form' => $form->createView(), - 'index' => $index, - 'count' => $configurator->getStepCount(), - 'version' => $this->factory->getVersion(), - 'tmpl' => $tmpl, - 'majors' => $majors, - 'minors' => $minors, - 'appRoot' => $this->container->getParameter('kernel.root_dir'), - ), - 'returnUrl' => $this->generateUrl('mautic_installer_step', array('index' => $index)), - 'contentTemplate' => $step->getTemplate(), - 'flashes' => $flashes, - 'forwardController' => false - )); + break; } - $index++; - - if ($index < $configurator->getStepCount()) { - $nextStep = $configurator->getStep($index); - $action = $this->generateUrl('mautic_installer_step', array('index' => $index)); - - $form = $this->container->get('form.factory')->create($nextStep->getFormType(), $nextStep, array('action' => $action)); + if ($success) { + // On a failure, the result will be an array; for success it will be a boolean + if (!empty($flashes)) { + return $this->postActionRedirect(array( + 'viewParameters' => array( + 'form' => $form->createView(), + 'index' => $index, + 'count' => $configurator->getStepCount(), + 'version' => $this->factory->getVersion(), + 'tmpl' => $tmpl, + 'majors' => $majors, + 'minors' => $minors, + 'appRoot' => $this->container->getParameter('kernel.root_dir'), + ), + 'returnUrl' => $this->generateUrl('mautic_installer_step', array('index' => $index)), + 'contentTemplate' => $step->getTemplate(), + 'flashes' => $flashes, + 'forwardController' => false + )); + } + + $index++; + + if ($index < $configurator->getStepCount()) { + $nextStep = $configurator->getStep($index); + $action = $this->generateUrl('mautic_installer_step', array('index' => $index)); + + $form = $this->container->get('form.factory')->create($nextStep->getFormType(), $nextStep, array('action' => $action)); + + return $this->postActionRedirect(array( + 'viewParameters' => array( + 'form' => $form->createView(), + 'index' => $index, + 'count' => $configurator->getStepCount(), + 'version' => $this->factory->getVersion(), + 'tmpl' => $tmpl, + 'majors' => $majors, + 'minors' => $minors, + 'appRoot' => $this->container->getParameter('kernel.root_dir'), + ), + 'returnUrl' => $action, + 'contentTemplate' => $nextStep->getTemplate(), + 'forwardController' => false + )); + } + + /* + * Post-processing once installation is complete + */ + + // Need to generate a secret value and merge it into the config + $secret = hash('sha1', uniqid(mt_rand())); + $configurator->mergeParameters(array('secret' => $secret)); + + // Write the updated config file + try { + $configurator->write(); + } catch (RuntimeException $exception) { + $flashes[] = array( + 'type' => 'error', + 'msg' => 'mautic.installer.error.writing.configuration' + ); + } + + // Clear the cache one final time with the updated config + $this->clearCache(); return $this->postActionRedirect(array( 'viewParameters' => array( - 'form' => $form->createView(), - 'index' => $index, - 'count' => $configurator->getStepCount(), - 'version' => $this->factory->getVersion(), - 'tmpl' => $tmpl, - 'majors' => $majors, - 'minors' => $minors, - 'appRoot' => $this->container->getParameter('kernel.root_dir'), + 'welcome_url' => $this->generateUrl('mautic_dashboard_index'), + 'parameters' => $configurator->render(), + 'config_path' => $this->container->getParameter('kernel.root_dir') . '/config/local.php', + 'is_writable' => $configurator->isFileWritable(), + 'version' => $this->factory->getVersion(), + 'tmpl' => $tmpl, ), - 'returnUrl' => $action, - 'contentTemplate' => $nextStep->getTemplate(), + 'returnUrl' => $this->generateUrl('mautic_installer_final'), + 'contentTemplate' => 'MauticInstallBundle:Install:final.html.php', + 'flashes' => $flashes, 'forwardController' => false )); } - - /* - * Post-processing once installation is complete - */ - - // Need to generate a secret value and merge it into the config - $secret = hash('sha1', uniqid(mt_rand())); - $configurator->mergeParameters(array('secret' => $secret)); - - // Write the updated config file - try { - $configurator->write(); - } catch (RuntimeException $exception) { - $flashes[] = array( - 'type' => 'error', - 'msg' => 'mautic.installer.error.writing.configuration' - ); - } - - // Clear the cache one final time with the updated config - $this->clearCache(); - - return $this->postActionRedirect(array( - 'viewParameters' => array( - 'welcome_url' => $this->generateUrl('mautic_dashboard_index'), - 'parameters' => $configurator->render(), - 'config_path' => $this->container->getParameter('kernel.root_dir') . '/config/local.php', - 'is_writable' => $configurator->isFileWritable(), - 'version' => $this->factory->getVersion(), - 'tmpl' => $tmpl, - ), - 'returnUrl' => $this->generateUrl('mautic_installer_final'), - 'contentTemplate' => 'MauticInstallBundle:Install:final.html.php', - 'flashes' => $flashes, - 'forwardController' => false - )); } } @@ -575,7 +600,6 @@ private function performUserAddition ($form) $entityManager->persist($user); $entityManager->flush(); } catch (\Exception $exception) { - die(var_Dump($exception)); return array( 'type' => 'error', 'msg' => 'mautic.installer.error.creating.user', diff --git a/app/bundles/InstallBundle/MauticInstallBundle.php b/app/bundles/InstallBundle/MauticInstallBundle.php index 6e925c4cb8b..cc3d2701e0b 100644 --- a/app/bundles/InstallBundle/MauticInstallBundle.php +++ b/app/bundles/InstallBundle/MauticInstallBundle.php @@ -11,6 +11,7 @@ use Mautic\InstallBundle\Configurator\Step\CheckStep; use Mautic\InstallBundle\Configurator\Step\DoctrineStep; +use Mautic\InstallBundle\Configurator\Step\EmailStep; use Mautic\InstallBundle\Configurator\Step\StatsStep; use Mautic\InstallBundle\Configurator\Step\UserStep; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -34,6 +35,7 @@ public function boot() $configurator->addStep(new CheckStep($configurator->isFileWritable(), $this->container->getParameter('kernel.root_dir'))); $configurator->addStep(new DoctrineStep($configurator->getParameters())); $configurator->addStep(new UserStep()); + $configurator->addStep(new EmailStep()); $configurator->addStep(new StatsStep()); } } diff --git a/app/bundles/InstallBundle/Translations/en_US/messages.ini b/app/bundles/InstallBundle/Translations/en_US/messages.ini index be7694554ab..b596025df58 100644 --- a/app/bundles/InstallBundle/Translations/en_US/messages.ini +++ b/app/bundles/InstallBundle/Translations/en_US/messages.ini @@ -16,40 +16,41 @@ mautic.install.function.sessionstart="Install and enable the <strong>session</st mautic.install.function.simplexml="Install and enable the <strong>SimpleXML</strong> extension." mautic.install.function.tokengetall="Install and enable the <strong>Tokenizer</strong> extension." mautic.install.function.xml="Install and enable the <strong>XML</strong> extension." -mautic.install.install.database.introtext="To function properly, Mautic requires a connection to a database server. Use this form to provide the required details for this connection." -mautic.install.install.form.database.driver="Database Driver" -mautic.install.install.form.database.host="Database Host" -mautic.install.install.form.database.name="Database Name" -mautic.install.install.form.database.password="Database Password" -mautic.install.install.form.database.port="Database Port" -mautic.install.install.form.database.secret="Site Secret Value" -mautic.install.install.form.database.table.prefix="Database Table Prefix" -mautic.install.install.form.database.user="Database Username" -mautic.install.install.form.stats.send_stats="Send Statistics?" -mautic.install.install.form.user.email="E-mail Address" -mautic.install.install.form.user.firstname="First Name" -mautic.install.install.form.user.lastname="Last Name" -mautic.install.install.form.user.password="Admin Password" -mautic.install.install.form.user.username="Admin Username" -mautic.install.install.heading.almost.configured="Mautic is almost configured, but..." -mautic.install.install.heading.check.environment="Mautic Installation - Environment Check" -mautic.install.install.heading.configured="Mautic is now fully installed and ready for use!" -mautic.install.install.heading.database.configuration="Mautic Installation - Database Configuration" -mautic.install.install.heading.final="Mautic Installation - Final Steps" -mautic.install.install.heading.finished="Well Done!" -mautic.install.install.heading.major.problems="Major Problems that need to be fixed now" -mautic.install.install.heading.minor.problems="Some Recommendations" -mautic.install.install.heading.ready="Ready to Install!" -mautic.install.install.heading.stats.configuration="Mautic Installation - Provide Stats" -mautic.install.install.heading.user.configuration="Mautic Installation - Create Admin User" -mautic.install.install.sentence.config.not.written="Your local.php configuration file is not writeable! Here are the parameters you can copy and paste in <em>%path%</em>:" -mautic.install.install.sentence.config.written="Your local.php configuration file has been overwritten with these parameters (in <em>%path%</em>):" -mautic.install.install.sentence.major.problems="We have detected <strong>%majors%</strong> major problems. You <em>must</em> fix them before continuing:" -mautic.install.install.sentence.minor.problems="We have detected some minor problems that we <em>recommend</em> you to fix to have a better Mautic experience:" -mautic.install.install.sentence.proceed.to.mautic="Proceed to Mautic" -mautic.install.install.sentence.ready="Great! Your environment will provide an optimal Mautic experience." -mautic.install.install.stats.introtext="You can optionally provide anonymous statistics about the environment you've installed Mautic in to enable better understanding of the platforms where Mautic is used and to better understand our user's requirements. The data that will be sent includes your server's PHP version, the database driver you are using, the version of the database server, your hosting server's operating system, and the application version." -mautic.install.install.user.introtext="Create the admin user for your Mautic installation." +mautic.install.database.introtext="To function properly, Mautic requires a connection to a database server. Use this form to provide the required details for this connection." +mautic.install.form.database.driver="Database Driver" +mautic.install.form.database.host="Database Host" +mautic.install.form.database.name="Database Name" +mautic.install.form.database.password="Database Password" +mautic.install.form.database.port="Database Port" +mautic.install.form.database.secret="Site Secret Value" +mautic.install.form.database.table.prefix="Database Table Prefix" +mautic.install.form.database.user="Database Username" +mautic.install.form.stats.send_stats="Send Statistics?" +mautic.install.form.user.email="E-mail Address" +mautic.install.form.user.firstname="First Name" +mautic.install.form.user.lastname="Last Name" +mautic.install.form.user.password="Admin Password" +mautic.install.form.user.username="Admin Username" +mautic.install.heading.almost.configured="Mautic is almost configured, but..." +mautic.install.heading.check.environment="Mautic Installation - Environment Check" +mautic.install.heading.configured="Mautic is now fully installed and ready for use!" +mautic.install.heading.database.configuration="Mautic Installation - Database Configuration" +mautic.install.heading.final="Mautic Installation - Final Steps" +mautic.install.heading.finished="Well Done!" +mautic.install.heading.major.problems="Major Problems that need to be fixed now" +mautic.install.heading.minor.problems="Some Recommendations" +mautic.install.heading.ready="Ready to Install!" +mautic.install.heading.stats.configuration="Mautic Installation - Provide Stats" +mautic.install.heading.user.configuration="Mautic Installation - Administrative User" +mautic.install.heading.email.configuration="Mautic Installation - Email Configuration" +mautic.install.sentence.config.not.written="Your local.php configuration file is not writeable! Here are the parameters you can copy and paste in <em>%path%</em>:" +mautic.install.sentence.config.written="Your local.php configuration file has been overwritten with these parameters (in <em>%path%</em>):" +mautic.install.sentence.major.problems="We have detected <strong>%majors%</strong> major problems. You <em>must</em> fix them before continuing:" +mautic.install.sentence.minor.problems="We have detected some minor problems that we <em>recommend</em> you to fix to have a better Mautic experience:" +mautic.install.sentence.proceed.to.mautic="Proceed to Mautic" +mautic.install.sentence.ready="Great! Your environment will provide an optimal Mautic experience." +mautic.install.stats.introtext="You can optionally provide anonymous statistics about the environment you've installed Mautic in to enable better understanding of the platforms where Mautic is used and to better understand our user's requirements. The data that will be sent includes your server's PHP version, the database driver you are using, the version of the database server, your hosting server's operating system, and the application version." +mautic.install.user.introtext="Create the admin user for your Mautic installation." mautic.install.intl.config="The intl extension is not performing as expected. This is a common issue on PHP 5.3 64-bit Windows builds. Please check that PHP's intl extension is installed and configured properly." mautic.install.intl.icu.version="Please upgrade your intl extension to a version which uses at least ICU version 4.0." mautic.install.magic_quotes_enabled="Your server has PHP's <strong>magic_quotes_gpc</strong> option enabled, please disable this option to use Mautic." @@ -68,5 +69,36 @@ mautic.install.timezone.not.supported="Your default timezone is not supported by mautic.install.xdebug.exception.trace="Xdebug's 'show_exception_trace' option should be disabled in your PHP configuration." mautic.install.xdebug.nesting="Set <strong>xdebug.max_nesting_level</strong> to at least <strong>250</strong> in your PHP configuration to stop Xdebug's infinite recursion protection from erroneously throwing a fatal error." mautic.install.xdebug.scream="Xdebug's 'scream' option should be disabled in your PHP configuration." -mautic.install.form.existing_tables="Backup existing tables (if no, then existing tables will be dropped)?" -mautic.install.form.backup_prefix="New prefix for the backup tables" \ No newline at end of file +mautic.install.form.existing_tables="Backup existing tables?" +mautic.install.form.existing_tables_descr="If set to no, conflicting tables will be dropped." +mautic.install.form.backup_prefix="Prefix for backup tables" +mautic.install.database.installing="Verifying the details and creating the database. This may take a few seconds." +mautic.install.please.wait="Please wait" +mautic.install.form.email.from_name="Name" +mautic.install.form.email.from_address="Email" +mautic.install.form.email.mailer_host="Server" +mautic.install.form.email.mailer_port="Port" +mautic.install.form.email.mailer_user="Username" +mautic.install.form.email.mailer_password="Password" +mautic.install.form.email.encryption="Encryption" +mautic.install.form.email.encryption_tls="TLS" +mautic.install.form.email.encryption_ssl="SSL" +mautic.install.form.none="None" +mautic.install.form.email.auth_mode_plain="Plain" +mautic.install.form.email.auth_mode_login="Login" +mautic.install.form.email.auth_mode_cram-md5="CRAM-MD5" +mautic.install.form.email.auth_mode="Authentication mode" +mautic.install.form.email.spool_file="Queue" +mautic.install.form.email.spool_memory="Immediate" +mautic.install.form.email.spool_type="Email handling" +mautic.install.form.email.spool_path="Path to the queue folder" +mautic.install.form.email.spool_path_descr="Set the absolute path to where email files will be queued. It is recommended that this be located outside of your publicly accessible web root." +mautic.install.form.email.transport="Mailer transport" +mautic.install.form.email.transport_descr="Choose the transport to send mail through. Mautic is not affiliated with any of these services but simply supply their SMTP settings for convenience." +mautic.install.email.introtext="Configure how Mautic will send email." +mautic.install.email.header.emailfrom="Who should the email be sent as?" +mautic.install.email.subheader.emailfrom="Set the name and email address that email will be sent from." +mautic.install.email.header.spooler="How should email be spooled?" +mautic.install.email.subheader.spooler="Email can either be sent immediately or queued to be manually processed. Sending email immediately may cause the page to load slowly if there is a delay between the mail server and/or if there is a large number of emails to be sent. By using the queue, emails are placed in the specified folder to be processed by a cron job. The queue is recommended for large volumes of emails. Check out the documentation for more information." +mautic.install.email.header.smtp="How should email be delivered?" +mautic.install.email.subheader.smtp="Choose the mail transport to be used to send email." \ No newline at end of file diff --git a/app/bundles/InstallBundle/Translations/en_US/validators.ini b/app/bundles/InstallBundle/Translations/en_US/validators.ini new file mode 100644 index 00000000000..f2039ff3f83 --- /dev/null +++ b/app/bundles/InstallBundle/Translations/en_US/validators.ini @@ -0,0 +1,3 @@ +mautic.install.notblank="A value is required." +mautic.install.invalidemail="A valid email is required." +mautic.install.password.minlength="Must be at least 6 characters." \ No newline at end of file diff --git a/app/bundles/InstallBundle/Views/Install/base.html.php b/app/bundles/InstallBundle/Views/Install/base.html.php index 6c20aa683e8..b5666c17624 100644 --- a/app/bundles/InstallBundle/Views/Install/base.html.php +++ b/app/bundles/InstallBundle/Views/Install/base.html.php @@ -7,6 +7,23 @@ * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ +$view['assets']->addScriptDeclaration("var MauticInstaller = { + showWaitMessage: function(event) { + event.preventDefault(); + + if (mQuery('#waitMessage').length) { + mQuery('#waitMessage').removeClass('hide'); + } + + mQuery('.btn-next').prop('disabled', true); + mQuery('.btn-next').html('<i class=\"fa fa-spin fa-spinner fa-fw\"></i>{$view['translator']->trans('mautic.install.please.wait')}'); + + setTimeout(function() { + mQuery('form').submit(); + }, 10); + } +};"); + ?> <!DOCTYPE html> <html> diff --git a/app/bundles/InstallBundle/Views/Install/check.html.php b/app/bundles/InstallBundle/Views/Install/check.html.php index b52f93a3ae3..d67d1690cf3 100644 --- a/app/bundles/InstallBundle/Views/Install/check.html.php +++ b/app/bundles/InstallBundle/Views/Install/check.html.php @@ -10,68 +10,73 @@ $view->extend('MauticInstallBundle:Install:content.html.php'); } -$header = $view['translator']->trans('mautic.install.install.heading.check.environment'); -$view['slots']->set("headerTitle", $header); ?> +<h2 class="page-header"> + <?php echo $view['translator']->trans('mautic.install.heading.check.environment'); ?> +</h2> +<?php if (count($majors)) : ?> +<h4><?php echo $view['translator']->trans('mautic.install.heading.major.problems'); ?></h4> +<p><?php echo $view['translator']->trans('mautic.install.sentence.major.problems', array('%majors%' => count($majors))); ?></p> +<ul class="list-unstyled"> + <?php foreach ($majors as $message) : ?> + <?php switch ($message) : + case 'mautic.install.minimum.php.version': ?> + <li> <?php echo $view['translator']->trans($message, array('%minimum%' => '5.3.7', '%installed' => PHP_VERSION)); ?></li> + <?php break; + case 'mautic.install.cache.unwritable': ?> + <li><?php echo $view['translator']->trans('mautic.install.directory.unwritable', array('%path%' => $appRoot . '/cache')); ?></li> + <?php break; + case 'mautic.install.config.unwritable': ?> + <li><?php echo $view['translator']->trans($message, array('%path%' => $appRoot . '/config/local.php')); ?></li> + <?php break; + case 'mautic.install.logs.unwritable': ?> + <li><?php echo $view['translator']->trans('mautic.install.directory.unwritable', array('%path%' => $appRoot . '/logs')); ?></li> + <?php break; + case 'mautic.install.apc.version': ?> + <?php $minAPCverison = version_compare(PHP_VERSION, '5.4.0', '>=') ? '3.1.13' : '3.0.17'; ?> + <li><?php echo $view['translator']->trans($message, array('%minapc%' => $minAPCverison, '%currentapc%' => phpversion('apc'))); ?></li> + <?php break; + default: ?> + <li><?php echo $view['translator']->trans($message); ?></li> + <?php break; + endswitch; ?> + <?php endforeach; ?> +</ul> +<?php endif; ?> +<?php if (count($minors)) : ?> +<div class="panel panel-warning"> + <div class="panel-heading"> + <h3 class="panel-title"><?php echo $view['translator']->trans('mautic.install.heading.minor.problems'); ?></h3> + </div> + <div class="panel-body alert-warning"> + <p><?php echo $view['translator']->trans('mautic.install.sentence.minor.problems'); ?></p> + </div> + <ul class="list-group"> + <?php foreach ($minors as $message) : ?> + <?php switch ($message) : + case 'mautic.install.pcre.version': ?> + <li class="list-group-item"><?php echo $view['translator']->trans($message, array('%pcreversion%' => (float) PCRE_VERSION)); ?></li> + <?php break; + default: ?> + <li class="list-group-item"><?php echo $view['translator']->trans($message); ?></li> + <?php break; ?> + <?php endswitch; ?> + <?php endforeach; ?> + </ul> +</div> +<?php endif; ?> +<?php if (!count($majors)) : ?> +<div class="alert alert-success"> + <h4><i class="fa fa-check"></i> <?php echo $view['translator']->trans('mautic.install.heading.ready'); ?></h4> + <p><?php echo $view['translator']->trans('mautic.install.sentence.ready'); ?></p> +</div> +<?php echo $view['form']->start($form); ?> - <h2 class="page-header"> - <?php echo $header; ?> - </h2> - <?php if (count($majors)) : ?> - <h4><?php echo $view['translator']->trans('mautic.install.install.heading.major.problems'); ?></h4> - <p><?php echo $view['translator']->trans('mautic.install.install.sentence.major.problems', array('%majors%' => count($majors))); ?></p> - <ul class="list-unstyled"> - <?php foreach ($majors as $message) : ?> - <?php switch ($message) : - case 'mautic.install.minimum.php.version': ?> - <li> <?php echo $view['translator']->trans($message, array('%minimum%' => '5.3.7', '%installed' => PHP_VERSION)); ?></li> - <?php break; - case 'mautic.install.cache.unwritable': ?> - <li><?php echo $view['translator']->trans('mautic.install.directory.unwritable', array('%path%' => $appRoot . '/cache')); ?></li> - <?php break; - case 'mautic.install.config.unwritable': ?> - <li><?php echo $view['translator']->trans($message, array('%path%' => $appRoot . '/config/local.php')); ?></li> - <?php break; - case 'mautic.install.logs.unwritable': ?> - <li><?php echo $view['translator']->trans('mautic.install.directory.unwritable', array('%path%' => $appRoot . '/logs')); ?></li> - <?php break; - case 'mautic.install.apc.version': ?> - <?php $minAPCverison = version_compare(PHP_VERSION, '5.4.0', '>=') ? '3.1.13' : '3.0.17'; ?> - <li><?php echo $view['translator']->trans($message, array('%minapc%' => $minAPCverison, '%currentapc%' => phpversion('apc'))); ?></li> - <?php break; - default: ?> - <li><?php echo $view['translator']->trans($message); ?></li> - <?php break; - endswitch; ?> - <?php endforeach; ?> - </ul> - <?php endif; ?> - <?php if (count($minors)) : ?> - <div class="panel panel-warning"> - <div class="panel-heading"> - <h3 class="panel-title"><?php echo $view['translator']->trans('mautic.install.install.heading.minor.problems'); ?></h3> - </div> - <div class="panel-body alert-warning"> - <p><?php echo $view['translator']->trans('mautic.install.install.sentence.minor.problems'); ?></p> - </div> - <ul class="list-group"> - <?php foreach ($minors as $message) : ?> - <?php switch ($message) : - case 'mautic.install.pcre.version': ?> - <li class="list-group-item"><?php echo $view['translator']->trans($message, array('%pcreversion%' => (float) PCRE_VERSION)); ?></li> - <?php break; - default: ?> - <li class="list-group-item"><?php echo $view['translator']->trans($message); ?></li> - <?php break; ?> - <?php endswitch; ?> - <?php endforeach; ?> - </ul> - </div> - <?php endif; ?> - <?php if (!count($majors)) : ?> - <div class="alert alert-success"> - <h4><i class="fa fa-check"></i> <?php echo $view['translator']->trans('mautic.install.install.heading.ready'); ?></h4> - <p><?php echo $view['translator']->trans('mautic.install.install.sentence.ready'); ?></p> - </div> - <?php echo $view['form']->form($form); ?> - <?php endif; ?> +<div class="row mt-20"> + <div class="col-sm-12"> + <?php echo $view['form']->row($form['buttons']); ?> + </div> +</div> + +<?php echo $view['form']->end($form); ?> +<?php endif; ?> diff --git a/app/bundles/InstallBundle/Views/Install/doctrine.html.php b/app/bundles/InstallBundle/Views/Install/doctrine.html.php index 81e7d42b2da..81fb82b1dca 100644 --- a/app/bundles/InstallBundle/Views/Install/doctrine.html.php +++ b/app/bundles/InstallBundle/Views/Install/doctrine.html.php @@ -10,12 +10,77 @@ $view->extend('MauticInstallBundle:Install:content.html.php'); } -$header = $view['translator']->trans('mautic.install.install.heading.database.configuration'); -$view['slots']->set("headerTitle", $header); +$js = <<<JS +MauticInstaller.toggleBackupPrefix = function() { + if (mQuery('#install_doctrine_step_backup_tables_0').prop('checked')) { + mQuery('#backupPrefix').addClass('hide'); + } else { + mQuery('#backupPrefix').removeClass('hide'); + } +}; +JS; +$view['assets']->addScriptDeclaration($js); + +$view['assets']->addScriptDeclaration("var test = {};"); ?> <h2 class="page-header"> - <?php echo $header; ?> + <?php echo $view['translator']->trans('mautic.install.heading.database.configuration'); ?> </h2> -<p><?php echo $view['translator']->trans('mautic.install.install.database.introtext'); ?></p> -<?php echo $view['form']->form($form); ?> +<p><?php echo $view['translator']->trans('mautic.install.database.introtext'); ?></p> + + +<?php echo $view['form']->start($form); ?> +<?php echo $view['form']->row($form['driver']); ?> + +<div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['host']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['port']); ?> + </div> +</div> + +<div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['name']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['table_prefix']); ?> + </div> +</div> + +<div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['user']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['password']); ?> + </div> +</div> + +<div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['backup_tables']); ?> + </div> + <?php $hide = (!$form['backup_tables']->vars['data']) ? ' hide' : ''; ?> + <div class="col-sm-6<?php echo $hide; ?>" id="backupPrefix"> + <?php echo $view['form']->row($form['backup_prefix']); ?> + </div> +</div> + +<div class="row mt-20"> + <div class="col-sm-9"> + <div class="hide" id="waitMessage"> + <div class="alert alert-info"> + <strong><?php echo $view['translator']->trans('mautic.install.database.installing'); ?></strong> + </div> + </div> + </div> + <div class="col-sm-3"> + <?php echo $view['form']->row($form['buttons']); ?> + </div> +</div> + +<?php echo $view['form']->end($form); ?> \ No newline at end of file diff --git a/app/bundles/InstallBundle/Views/Install/email.html.php b/app/bundles/InstallBundle/Views/Install/email.html.php new file mode 100644 index 00000000000..41e4010d850 --- /dev/null +++ b/app/bundles/InstallBundle/Views/Install/email.html.php @@ -0,0 +1,154 @@ +<?php +/** + * @package Mautic + * @copyright 2014 Mautic Contributors. All rights reserved. + * @author Mautic + * @link http://mautic.org + * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html + */ +if ($tmpl == 'index') { + $view->extend('MauticInstallBundle:Install:content.html.php'); +} + +$js = <<<JS +MauticInstaller.toggleSpoolQueue = function() { + if (mQuery('#install_email_step_mailer_spool_type_0').prop('checked')) { + mQuery('#spoolPath').addClass('hide'); + } else { + mQuery('#spoolPath').removeClass('hide'); + } +}; + +MauticInstaller.toggleTransportDetails = function (mailer) { + if (mailer == 'smtp') { + mQuery('#smtpSettings').removeClass('hide'); + if (mQuery('#install_email_step_mailer_auth_mode').val()) { + mQuery('#authDetails').removeClass('hide'); + } else { + mQuery('#authDetails').addClass('hide'); + } + } else { + mQuery('#smtpSettings').addClass('hide'); + + if (mailer == 'mail' || mailer == 'sendmail') { + mQuery('#authDetails').addClass('hide'); + } else { + mQuery('#authDetails').removeClass('hide'); + } + } +}; + +MauticInstaller.toggleAuthDetails = function(auth) { + if (!auth) { + mQuery('#authDetails').addClass('hide'); + } else { + mQuery('#authDetails').removeClass('hide'); + } +}; +JS; +$view['assets']->addScriptDeclaration($js); + +$header = $view['translator']->trans('mautic.install.heading.email.configuration'); +?> + +<h2 class="page-header"> + <?php echo $header; ?> +</h2> + +<?php echo $view['form']->start($form); ?> + +<div class="panel panel-primary"> + <div class="panel-heading pa-10"> + <h4><?php echo $view['translator']->trans('mautic.install.email.header.emailfrom'); ?></h4> + <h6><?php echo $view['translator']->trans('mautic.install.email.subheader.emailfrom'); ?></h6> + </div> + <div class="panel-body"> + <div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['mailer_from_name']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['mailer_from_email']); ?> + </div> + </div> + </div> +</div> + +<div class="panel panel-primary"> + <div class="panel-heading pa-10"> + <h4><?php echo $view['translator']->trans('mautic.install.email.header.spooler'); ?></h4> + <h6><?php echo $view['translator']->trans('mautic.install.email.subheader.spooler'); ?></h6> + </div> + <div class="panel-body"> + <div class="row"> + <div class="col-sm-5"> + <?php echo $view['form']->row($form['mailer_spool_type']); ?> + </div> + <?php $hide = ($form['mailer_spool_type']->vars['data'] == 'queue') ? '' : ' hide'; ?> + <div class="col-sm-7<?php echo $hide; ?>" id="spoolPath"> + <?php echo $view['form']->row($form['mailer_spool_path']); ?> + </div> + </div> + </div> +</div> + +<div class="panel panel-primary"> + <div class="panel-heading pa-10"> + <h4><?php echo $view['translator']->trans('mautic.install.email.header.smtp'); ?></h4> + <h6><?php echo $view['translator']->trans('mautic.install.email.subheader.smtp'); ?></h6> + </div> + <div class="panel-body"> + <div class="row"> + <div class="col-sm-12"> + <?php echo $view['form']->row($form['mailer_transport']); ?> + </div> + </div> + <?php $hide = ($form['mailer_transport']->vars['data'] == 'smtp') ? '' : ' class="hide"'; ?> + <div id="smtpSettings"<?php echo $hide; ?>> + <div class="row"> + <div class="col-sm-9"> + <?php echo $view['form']->row($form['mailer_host']); ?> + </div> + <div class="col-sm-3"> + <?php echo $view['form']->row($form['mailer_port']); ?> + </div> + </div> + + <div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['mailer_encryption']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['mailer_auth_mode']); ?> + </div> + </div> + </div> + <?php + $authMode = $form['mailer_auth_mode']->vars['data']; + $mailer = $form['mailer_transport']->vars['data']; + $hide = (!in_array($mailer, array('mail', 'sendmail')) || ($mailer == 'smtp' && !empty($authMode))) ? '' : ' class="hide"'; + ?> + <div id="authDetails"<?php echo $hide; ?>> + <div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['mailer_user']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['mailer_password']); ?> + </div> + </div> + </div> + </div> +</div> + + +<div class="row mt-20"> + <div class="col-sm-6"> + + </div> + <div class="col-sm-6 mt-20"> + <?php echo $view['form']->row($form['buttons']); ?> + </div> +</div> + +<?php echo $view['form']->end($form); ?> diff --git a/app/bundles/InstallBundle/Views/Install/final.html.php b/app/bundles/InstallBundle/Views/Install/final.html.php index 55b0931a0f7..89865b5e0b2 100644 --- a/app/bundles/InstallBundle/Views/Install/final.html.php +++ b/app/bundles/InstallBundle/Views/Install/final.html.php @@ -10,27 +10,25 @@ $view->extend('MauticInstallBundle:Install:content.html.php'); } -$header = $view['translator']->trans('mautic.install.install.heading.final'); -$view['slots']->set("headerTitle", $header); ?> <h2 class="page-header"> - <?php echo $header; ?> + <?php echo $view['translator']->trans('mautic.install.heading.final'); ?> </h2> -<h4><?php echo $view['translator']->trans('mautic.install.install.heading.finished'); ?></h4> +<h4><?php echo $view['translator']->trans('mautic.install.heading.finished'); ?></h4> <?php if ($is_writable) : ?> - <h5><?php echo $view['translator']->trans('mautic.install.install.heading.configured'); ?></h5> + <h5><?php echo $view['translator']->trans('mautic.install.heading.configured'); ?></h5> <?php else : ?> - <h5><?php echo $view['translator']->trans('mautic.install.install.heading.almost.configured'); ?></h5> + <h5><?php echo $view['translator']->trans('mautic.install.heading.almost.configured'); ?></h5> <?php if ($is_writable) : ?> - <p><?php echo $view['translator']->trans('mautic.install.install.sentence.config.written', array('%path%' => $config_path)); ?></p> + <p><?php echo $view['translator']->trans('mautic.install.sentence.config.written', array('%path%' => $config_path)); ?></p> <?php else : ?> - <p><?php echo $view['translator']->trans('mautic.install.install.sentence.config.not.written', array('%path%' => $config_path)); ?></p> + <p><?php echo $view['translator']->trans('mautic.install.sentence.config.not.written', array('%path%' => $config_path)); ?></p> <?php endif; ?> <textarea class="form-control" rows="15"><?php echo $parameters; ?></textarea> <?php endif; ?> <?php if ($welcome_url) : ?> <a href="<?php echo $welcome_url; ?>" role="button" class="btn btn-primary pull-right mt-20"> - <?php echo $view['translator']->trans('mautic.install.install.sentence.proceed.to.mautic'); ?> + <?php echo $view['translator']->trans('mautic.install.sentence.proceed.to.mautic'); ?> </a> <?php endif; ?> diff --git a/app/bundles/InstallBundle/Views/Install/stats.html.php b/app/bundles/InstallBundle/Views/Install/stats.html.php index 38c4939df80..3060057c2df 100644 --- a/app/bundles/InstallBundle/Views/Install/stats.html.php +++ b/app/bundles/InstallBundle/Views/Install/stats.html.php @@ -10,12 +10,24 @@ $view->extend('MauticInstallBundle:Install:content.html.php'); } -$header = $view['translator']->trans('mautic.install.install.heading.stats.configuration'); +$header = $view['translator']->trans('mautic.install.heading.stats.configuration'); $view['slots']->set("headerTitle", $header); ?> <h2 class="page-header"> <?php echo $header; ?> </h2> -<p><?php echo $view['translator']->trans('mautic.install.install.stats.introtext'); ?></p> -<?php echo $view['form']->form($form); ?> +<p><?php echo $view['translator']->trans('mautic.install.stats.introtext'); ?></p> + +<?php echo $view['form']->start($form); ?> + +<div class="row mt-20"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['send_server_data']); ?> + </div> + <div class="col-sm-6 mt-20"> + <?php echo $view['form']->row($form['buttons']); ?> + </div> +</div> + +<?php echo $view['form']->end($form); ?> diff --git a/app/bundles/InstallBundle/Views/Install/user.html.php b/app/bundles/InstallBundle/Views/Install/user.html.php index 918ef2a2d33..db1cae64c16 100644 --- a/app/bundles/InstallBundle/Views/Install/user.html.php +++ b/app/bundles/InstallBundle/Views/Install/user.html.php @@ -9,13 +9,45 @@ if ($tmpl == 'index') { $view->extend('MauticInstallBundle:Install:content.html.php'); } - -$header = $view['translator']->trans('mautic.install.install.heading.user.configuration'); -$view['slots']->set("headerTitle", $header); ?> <h2 class="page-header"> - <?php echo $header; ?> + <?php echo $view['translator']->trans('mautic.install.heading.user.configuration'); ?> </h2> -<p><?php echo $view['translator']->trans('mautic.install.install.user.introtext'); ?></p> -<?php echo $view['form']->form($form); ?> +<p><?php echo $view['translator']->trans('mautic.install.user.introtext'); ?></p> + +<?php echo $view['form']->start($form); ?> + +<div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['username']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['password']); ?> + </div> +</div> + + +<div class="row"> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['firstname']); ?> + </div> + <div class="col-sm-6"> + <?php echo $view['form']->row($form['lastname']); ?> + </div> +</div> + + +<div class="row"> + <div class="col-sm-12"> + <?php echo $view['form']->row($form['email']); ?> + </div> +</div> + +<div class="row mt-20"> + <div class="col-sm-12"> + <?php echo $view['form']->row($form['buttons']); ?> + </div> +</div> + +<?php echo $view['form']->end($form); ?> \ No newline at end of file diff --git a/app/bundles/UserBundle/Entity/UserRepository.php b/app/bundles/UserBundle/Entity/UserRepository.php index eea16227151..ebef7874746 100644 --- a/app/bundles/UserBundle/Entity/UserRepository.php +++ b/app/bundles/UserBundle/Entity/UserRepository.php @@ -53,14 +53,19 @@ public function setLastActive($user) * @return array */ public function checkUniqueUsernameEmail($params) { - $identifier = (isset($params['email'])) ? $params['email'] : $params['username']; - $q = $this - ->createQueryBuilder('u') - ->where('u.username = :identifier OR u.email = :identifier') - ->setParameter("identifier", $identifier) - ->getQuery(); + $q = $this->createQueryBuilder('u'); + + if (isset($params['email'])) { + $q->where('u.username = :email OR u.email = :email') + ->setParameter("email", $params['email']); + } + + if (isset($params['username'])) { + $q->orWhere('u.username = :username OR u.email = :username') + ->setParameter("username", $params['username']); + } - return $q->getResult(); + return $q->getQuery()->getResult(); } /** diff --git a/app/config/config.php b/app/config/config.php index 76aaa3e4009..329c40c1d3d 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -132,6 +132,7 @@ function ($v) { return (!empty($v)); } $container->loadFromExtension('swiftmailer', array( 'transport' => '%mautic.mailer_transport%', 'host' => '%mautic.mailer_host%', + 'port' => '%mautic.mailer_port%', 'username' => '%mautic.mailer_user%', 'password' => '%mautic.mailer_password%', 'spool' => array(