Commit 2ab5c88e authored by efalcy's avatar efalcy Committed by Henri-Damien LAURENT
Browse files

hotline #83907: newsletters admin : fix multiple popup when try to send one

parent 6fd61abc
Pipeline #6685 passed with stage
in 34 minutes and 53 seconds
- ticket #83907 : Newsletter : lors de l'envoie d'une newsletter, une popup apparaissait pour toutes les newsletters qui n'avaient pas fini leur envoi.
\ No newline at end of file
......@@ -23,6 +23,9 @@
class ZendAfi_Controller_Plugin_Manager_Newsletter extends ZendAfi_Controller_Plugin_Manager_Manager {
public function getActions($model) {
$existing_dispatch = $model->getDispatchIfNotEnded();
$title = ($existing_dispatch ?
$this->_("Reprendre l'envoi de la lettre d'information: %s ? ",$existing_dispatch->getTitle())
: $this->_("Envoyer la lettre d'information ?"));
return [
['url' => '/admin/newsletter/edit/id/%s',
......@@ -40,23 +43,7 @@ class ZendAfi_Controller_Plugin_Manager_Newsletter extends ZendAfi_Controller_Pl
'label' => $this->_('Effectuer un test d\'envoi')],
['url' => '/admin/newsletter/send/id/%s',
'icon' => 'mail',
'anchorOptions' => ['rel' => 'send'],
'caption' => function($model) use ($existing_dispatch)
{
Class_ScriptLoader::getInstance()->addJQueryReady("
function sendNewsletterClick(event) {
var target = $(event.target).closest('a');
var answer = confirm(\"". ($existing_dispatch ?
$this->_("Reprendre l'envoi de la lettre d'information: %s ? ",$existing_dispatch->getTitle())
: $this->_("Envoyer la lettre d'information ?"))."\");
if (answer == false) {
event.preventDefault();
return;
}
}
$(\"a[rel='send']\").click(sendNewsletterClick);
");},
'anchorOptions' => $this->_confirm($title),
'label' => ($existing_dispatch ?
$this->_('Reprendre l\'envoi en cours')
: $this->_('Envoyez la lettre d\'information'))
......
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Mail_Transport_File extends Zend_Mail_Transport_Abstract {
use Trait_Translator;
protected $_file;
public function __construct($file) {
$this->_file = $file;
}
protected function _sendMail() {
$message = $this->header . "\n" . $this->body . "\n\n";
if (false === file_put_contents($this->_file, $message, FILE_APPEND))
throw new Zend_Mail_Transport_Exception($this->_('Impossible d\'écrire le mail dans %s',
$this->_file));
}
}
......@@ -274,6 +274,11 @@ class Bokeh_Engine {
function setupMail() {
if (isset($this->_config->mail->transport->file)) {
ZendAfi_Mail::setDefaultTransport(new ZendAfi_Mail_Transport_File($this->_config->mail->transport->file));
return $this;
}
if (isset($this->_config->mail->transport->smtp)) {
ZendAfi_Mail::setDefaultTransport(new Zend_Mail_Transport_Smtp($this->_config->mail->transport->smtp->host,
$this->_config->mail->transport->smtp->toArray()));
......
......@@ -170,7 +170,7 @@ class Admin_NewsletterControllerIndexActionTest extends Admin_NewsletterControll
public function testSendNouveautesClassiqueLink() {
$this->assertXPath("//a[contains(@href, '/admin/newsletter/send/id/1')][@rel='send']");
$this->assertXPath("//a[contains(@href, '/admin/newsletter/send/id/1')]");
}
......@@ -1563,7 +1563,7 @@ class Admin_NewsletterControllerScriptTest extends Admin_NewsletterControllerTes
/** @test */
public function sendMailButtonShouldBeHere() {
$this->assertXPathContentContains('//script', 'Envoyer la lettre d\'information');
$this->assertXPath('//a[contains(@onclick, "Envoyer la lettre d\\\'information")]', $this->_response->getBody());
}
......@@ -1678,7 +1678,7 @@ class Admin_NewsletterControllerSendProgressWithErrorAnd1Of2SentTest
public function sendButtonShouldContainsReloadText() {
Class_Newsletter::find(1)->setTitre('Other title')->save();
$this->dispatch('admin/newsletter/index', true);
$this->assertXPathContentContains('//script', 'Reprendre l\'envoi de la lettre d\'information: Nouveautés classique ?', $this->_response->getBody());
$this->assertXPath('//a[contains(@onclick,"Reprendre l\\\'envoi de la lettre d\\\'information: Nouveautés classique ? ")]', $this->_response->getBody());
$this->assertXPath('//img[contains(@title,"Reprendre l\'envoi en cours")]', $this->_response->getBody());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment