From 58af6a8b2ae80ce986088f7489226936a6c39b31 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Wed, 19 Oct 2016 11:38:36 +0200
Subject: [PATCH] sandbox #49081 : fix post events range on multiple
 modifications

---
 library/ZendAfi/Form/Admin/News.php           | 10 ++++++++++
 .../CmsControllerMultipleSelectionTest.php    | 19 ++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/library/ZendAfi/Form/Admin/News.php b/library/ZendAfi/Form/Admin/News.php
index bc99997f8c0..c2981eb9005 100644
--- a/library/ZendAfi/Form/Admin/News.php
+++ b/library/ZendAfi/Form/Admin/News.php
@@ -303,13 +303,23 @@ EOT;
   public function deleteUnchanged($post) {
     $post = array_filter($post,
                          function($index) use($post) {
+                                                        if ($index == 'events_debut'
+                                                            || $index == 'events_fin')
+                                                          $index = 'event_range';
+
+                                                        if ($index == 'fin' || $index == 'debut')
+                                                          $index = 'publication_range';
+
                                                         if(!isset($post[self::keepValueParamName($index)]))
                                                           return true;
                                                         return 0 == $post[self::keepValueParamName($index)];
                                                       }
                          , ARRAY_FILTER_USE_KEY);
+
+
     $post = array_filter($post,
                          function($index) {
+
                                              return false === strpos($index,self::keepValueParamName());
                                            }
                          , ARRAY_FILTER_USE_KEY);
diff --git a/tests/application/modules/admin/controllers/CmsControllerMultipleSelectionTest.php b/tests/application/modules/admin/controllers/CmsControllerMultipleSelectionTest.php
index a432561d5ce..036bf1e5d22 100644
--- a/tests/application/modules/admin/controllers/CmsControllerMultipleSelectionTest.php
+++ b/tests/application/modules/admin/controllers/CmsControllerMultipleSelectionTest.php
@@ -372,7 +372,13 @@ public function setUp() {
     $this->postDispatch('admin/cms/edit-multiple', ['titre' => 'concert',
                                                     'keepValueOf_titre' => 1,
                                                     'cacher_titre' => 0,
-                                                    'keepValueOf_cacher_titre' => 0]);
+                                                    'keepValueOf_cacher_titre' => 0,
+                                                    'events_debut' => '',
+                                                    'events_fin' => '',
+                                                    'keepValueOf_event_range' => 1,
+                                                    'debut' => '',
+                                                    'fin' => '',
+                                                    'keepValueOf_publication_range' => 1]);
   }
 
 
@@ -383,6 +389,17 @@ public function setUp() {
     $this->assertRedirect();
   }
 
+  /** @test */
+  public function eventShouldNotBeModified() {
+    $this->assertEquals('2011-03-27 21:00' , $this->concert->getEventsDebut());
+  }
+
+
+  /** @test */
+  public function publicationShouldNotBeModified() {
+    $this->assertEquals('2011-03-20 00:00' , $this->concert->getDebut());
+  }
+
 
   /** @test */
   public function shouldNotifySucces() {
-- 
GitLab