diff --git a/VERSIONS_HOTLINE/49590 b/VERSIONS_HOTLINE/49590 new file mode 100644 index 0000000000000000000000000000000000000000..cba3474c4cd7523d8374997c5282b3dfca4b4def --- /dev/null +++ b/VERSIONS_HOTLINE/49590 @@ -0,0 +1 @@ + - ticket #49590 : Pas de Confirmation d'envoi de newsletter \ No newline at end of file diff --git a/application/modules/admin/controllers/NewsletterController.php b/application/modules/admin/controllers/NewsletterController.php index 08c7e239fb23c1adec4f904d59aec3b62305e563..99e5a7c2a1a3fd6d89e968b610f5d5b163d73c83 100644 --- a/application/modules/admin/controllers/NewsletterController.php +++ b/application/modules/admin/controllers/NewsletterController.php @@ -44,7 +44,23 @@ class Admin_NewsletterController extends ZendAfi_Controller_Action { return $this->view->tag('span', $this->view->boutonIco("picto=users", "bulle=" . $this->_('Inscrits')) . $model->getNumberOfUsers(), ['style' => 'white-space:nowrap']); }], ['action' => 'sendtest', 'content' => $this->view->boutonIco('type=test')], - ['action' => 'send', 'content' => $this->view->boutonIco('type=mail')], + ['action' => 'send', + 'content' => function($model) { + Class_ScriptLoader::getInstance()->addJQueryReady(" +function sendNewsletterClick(event) { + var target = $(event.target).closest('a'); + var answer = confirm(\"".$this->_("Envoyer la lettre d'information ?")."\"); + if (answer == false) { + event.preventDefault(); + return; + } +} + + $(\"a[rel='send']\").click(sendNewsletterClick); +"); + + + return $this->view->boutonIco('type=mail');}], ['action' => 'duplicate', 'content' => $this->view->boutonIco('type=duplicate')], ['action' => 'delete', 'content' => $this->view->boutonIco('type=del')], ], diff --git a/application/modules/admin/views/scripts/newsletter/_newsletter_list_item.phtml b/application/modules/admin/views/scripts/newsletter/_newsletter_list_item.phtml deleted file mode 100644 index 9f07a3179d63cab9ced4686444deba5e81d134b5..0000000000000000000000000000000000000000 --- a/application/modules/admin/views/scripts/newsletter/_newsletter_list_item.phtml +++ /dev/null @@ -1,17 +0,0 @@ -<li> - <span class='titre'> - <?php - echo $this->tagAnchor($this->url(array('action' => 'edit', - 'id' => $this->newsletter->getId())), - htmlentities($this->newsletter->getTitre(), ENT_QUOTES, 'UTF-8')); - - foreach(array('delete' => 'Supprimer', 'send' => 'Envoyer') - as $action => $label) { - echo ' - '; - echo $this->tagAnchor($this->url(array('action' => $action, - 'id' => $this->newsletter->getId())), - $label); - } - ?> - </span> -</li> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/newsletter/_newsletter_row.phtml b/application/modules/admin/views/scripts/newsletter/_newsletter_row.phtml deleted file mode 100644 index 7c30af706f590243259be68956d72b02e306b8ec..0000000000000000000000000000000000000000 --- a/application/modules/admin/views/scripts/newsletter/_newsletter_row.phtml +++ /dev/null @@ -1,20 +0,0 @@ -<tr class="<?php echo $this->item_class ?>"> - <td><?php echo htmlentities($this->newsletter->getTitre(), ENT_QUOTES, 'UTF-8'); ?></td> - <td><?php echo $this->tagProgressBarForNewsletter($this->newsletter);?></td> - <?php - foreach(['edit' => $this->boutonIco("type=edit"), - 'delete' => $this->boutonIco("type=del"), - 'preview' => $this->boutonIco("type=show"), - 'duplicate' => $this->boutonIco("type=duplicate"), - 'edit-subscribers' => $this->boutonIco("picto=users", "bulle=Membres").$this->newsletter->getNumberOfUsers(), - 'sendtest' => $this->boutonIco("type=test"), - 'send' => $this->boutonIco("type=mail")] - as $action => $view) { - echo "<td rel='$action'>"; - echo $this->tagAnchor($this->url(['action' => $action, - 'id' => $this->newsletter->getId()]), - $view); - echo '</td>'; - } - ?> -</tr> diff --git a/application/modules/admin/views/scripts/newsletter/index.phtml b/application/modules/admin/views/scripts/newsletter/index.phtml index 3148679ac513c80a5a1ad8f7a701846849910e3c..cfb7cc73d7b2500d5fd26007523eca43d66d6236 100644 --- a/application/modules/admin/views/scripts/newsletter/index.phtml +++ b/application/modules/admin/views/scripts/newsletter/index.phtml @@ -15,18 +15,3 @@ echo $this->tagModelTable($this->newsletters, if (isset($this->subview)) echo $this->tag('div', $this->subview, ['class' => 'subview']); ?> - -<script type="text/javascript"> -function sendNewsletterClick(event) { - var target = $(event.target).closest('a'); - var answer = confirm("<?php echo $this->_("Envoyer la lettre d'information ?"); ?>"); - if (answer == false) { - event.preventDefault(); - return; - } -} - -$(document).ready(function() { - $("td[rel='send'] a").click(sendNewsletterClick); -}); -</script> diff --git a/library/ZendAfi/View/Helper/TagModelTable.php b/library/ZendAfi/View/Helper/TagModelTable.php index 37df6e4812d0cd359b604816f212f7ab5db3ef10..dff917e01e6fa956d419a1415749f05d122ea617 100644 --- a/library/ZendAfi/View/Helper/TagModelTable.php +++ b/library/ZendAfi/View/Helper/TagModelTable.php @@ -200,7 +200,7 @@ class ZendAfi_View_Helper_TagModelTable extends ZendAfi_View_Helper_BaseHelper { $content = $action['content']; $url = $this->view->url(['action' => $action['action'], 'id' => $model->getId()]); - $attribs = ['href' => $url]; + $attribs = ['href' => $url, 'rel' => $action['action']]; if (isset($_SERVER['REQUEST_URI']) && false !== strpos($_SERVER['REQUEST_URI'], $url)) $attribs['class'] = 'selected'; diff --git a/tests/application/modules/admin/controllers/NewsletterControllerTest.php b/tests/application/modules/admin/controllers/NewsletterControllerTest.php index b0d4e91b162d1a5178ebcd1a446d56fa2a3b420d..ebacdf3e58ed75f70b4f34988917fd4e269a4637 100644 --- a/tests/application/modules/admin/controllers/NewsletterControllerTest.php +++ b/tests/application/modules/admin/controllers/NewsletterControllerTest.php @@ -160,7 +160,7 @@ class Admin_NewsletterControllerIndexActionTest extends Admin_NewsletterControll public function testSendNouveautesClassiqueLink() { - $this->assertXPath("//a[@href='/admin/newsletter/send/id/1']"); + $this->assertXPath("//a[@href='/admin/newsletter/send/id/1'][@rel='send']", $this->_response->getBody()); }