From 7311f67dd8636a48a7992a545ec27177bbe3cb1e Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Thu, 11 May 2017 15:39:56 +0200
Subject: [PATCH] hotline #60290 : search param should not be named as model
 attribute

---
 VERSIONS_HOTLINE/60290                              |  1 +
 .../modules/admin/controllers/CmsController.php     |  7 +++----
 .../Action/Helper/ArticleListViewMode.php           | 13 +++++++------
 3 files changed, 11 insertions(+), 10 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/60290

diff --git a/VERSIONS_HOTLINE/60290 b/VERSIONS_HOTLINE/60290
new file mode 100644
index 00000000000..6d766b2b3c8
--- /dev/null
+++ b/VERSIONS_HOTLINE/60290
@@ -0,0 +1 @@
+ - ticket #60290 : Administration des articles : correction du mauvais affichage du statut de publication
\ No newline at end of file
diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php
index 941b4081378..0b3bc852f6b 100644
--- a/application/modules/admin/controllers/CmsController.php
+++ b/application/modules/admin/controllers/CmsController.php
@@ -59,7 +59,7 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
                      }, $bibs);
 
     $search = $this->_getParam('title_search', '');
-    $status = $this->_getParam('status', '');
+    $status = $this->_getParam(ZendAfi_Controller_Action_Helper_ArticleListViewMode::STATUS_SEARCH, '');
 
     $id_bib = $this->_getParam('id_bib',
                                $this->identity->isRoleLibraryLimited()
@@ -69,7 +69,7 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
 
     $params = ['page' => $this->_getParam('page', 0),
                'search_value' => $search,
-               'status' => $status,
+               ZendAfi_Controller_Action_Helper_ArticleListViewMode::STATUS_SEARCH => $status,
                'bib' => $this->_bib,
                'id_bib' => $id_bib,
                'id_cat' => $id_cat];
@@ -95,7 +95,7 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
     if($this->_request->isPost())
       return $this->_redirectToRefererWithNewParams(['title_search' => $this->_getPost()['title_search'],
                                                      'page' => $this->_getParam('page'),
-                                                     'status' => $this->_getPost()['status']]);
+                                                     ZendAfi_Controller_Action_Helper_ArticleListViewMode::STATUS_SEARCH => $this->_getPost()[ZendAfi_Controller_Action_Helper_ArticleListViewMode::STATUS_SEARCH]]);
 
     if (Class_AdminVar::isArticlesListMode())
       return $this->_renderList();
@@ -173,4 +173,3 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
     $this->getResponse()->setBody((new Class_ArticleCategorie())->getCategoriesJson());
   }
 }
-?>
\ No newline at end of file
diff --git a/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php
index 02874402f43..7c0ca7cd59e 100644
--- a/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php
+++ b/library/ZendAfi/Controller/Action/Helper/ArticleListViewMode.php
@@ -22,6 +22,7 @@
 
 class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode {
   const STRATEGY = 'article';
+  const STATUS_SEARCH = 'status_search';
 
   protected
     $_filtred_categories_ids = [],
@@ -55,7 +56,7 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr
             'id_cat' => $this->getParam('id_cat'),
             'id_bib' => $this->getParam('id_bib'),
             'title_search' => $this->getSearch(),
-            'status' => $this->getParam('status')];
+            static::STATUS_SEARCH => $this->getStatus()];
   }
 
 
@@ -64,7 +65,7 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr
                                   'id_bib' => $this->getBibId(),
                                   'title_search' => '',
                                   'page' => '1',
-                                  'status' => ''];
+                                  static::STATUS_SEARCH => ''];
   }
 
 
@@ -364,14 +365,14 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr
   public function _getSearchForm($view) {
     $form = parent::_getSearchForm($view);
 
-    if(!Class_AdminVar::isWorkflowEnabled())
+    if (!Class_AdminVar::isWorkflowEnabled())
       return $form;
 
-    Class_ScriptLoader::getInstance()->addJQueryReady('$("form select[name=\'status\']").on("change", function() {$(this).closest("form").submit();});');
+    Class_ScriptLoader::getInstance()->addJQueryReady('$("form select[name=\''. static::STATUS_SEARCH .'\']").on("change", function() {$(this).closest("form").submit();});');
 
     $form->removeDisplayGroup('list_search_group');
     return $form->addElement('select',
-                             'status',
+                             static::STATUS_SEARCH,
                              ['multiOptions' => [0 => $this->_('Tous statuts')] + Class_Article::getKnownStatus(),
                               'value' => $this->getStatus()])
                 ->addUniqDisplayGroup('list_search_group');
@@ -379,7 +380,7 @@ class ZendAfi_Controller_Action_Helper_ArticleListViewMode extends ZendAfi_Contr
 
 
   public function getStatus() {
-    return $this->getParam('status');
+    return $this->getParam(static::STATUS_SEARCH);
   }
 
 
-- 
GitLab