From ad7dc3cd92d3edf014495fd18dc9125a85596ee3 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Mon, 30 Jan 2017 15:48:48 +0100
Subject: [PATCH] hotline #54764 first commit

---
 VERSIONS_HOTLINE/54764                        |  1 +
 .../cosmo/controllers/AnnexeController.php    | 28 +++++++++++
 .../controllers/AnnexeControllerTest.php      | 47 +++++++++++++++++++
 .../Plugin/ResourceDefinition/Annexe.php      | 38 +++++++++++++++
 4 files changed, 114 insertions(+)
 create mode 100644 VERSIONS_HOTLINE/54764
 create mode 100644 cosmogramme/cosmozend/application/modules/cosmo/controllers/AnnexeController.php
 create mode 100644 cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php
 create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/Annexe.php

diff --git a/VERSIONS_HOTLINE/54764 b/VERSIONS_HOTLINE/54764
new file mode 100644
index 00000000000..6d99df70cfb
--- /dev/null
+++ b/VERSIONS_HOTLINE/54764
@@ -0,0 +1 @@
+ - ticket #54764 : Problème de filtre sur les bibliothèques de Chambéry
\ No newline at end of file
diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/AnnexeController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/AnnexeController.php
new file mode 100644
index 00000000000..d518d731498
--- /dev/null
+++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/AnnexeController.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Copyright (c) 2012-2017, 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 Cosmo_AnnexeController extends ZendAfi_Controller_Action {
+  public function getPlugins() {
+    return ['ZendAfi_Controller_Plugin_ResourceDefinition_Annexe'];
+  }
+}
+?>
\ No newline at end of file
diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php
new file mode 100644
index 00000000000..fee00b8c083
--- /dev/null
+++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/AnnexeControllerTest.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Copyright (c) 2012-2017, 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 AnnexeControllerTest extends CosmoControllerTestCase {
+
+  public function setUp() {
+    parent::setUp();
+
+    $this->fixture('Class_Bib',
+                   ['id' => 56,
+                    'libelle' => 'Médiathèque Annecy']);
+
+    $this->fixture('Class_CodifAnnexe',
+                   ['id' => 98,
+                    'libelle' => 'Annexe Annecy',
+                    'code' => 'ACY-01',
+                    'id_bib' => 56]);
+
+    $this->dispatch('/cosmo/annexe/index', true);
+  }
+
+
+  /** @test */
+  public function annexeAnnecyShouldBeInTable() {
+    $this->assertXPathContentContains('//div//td', 'Annexe Annecy');
+  }
+}
+?>
\ No newline at end of file
diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Annexe.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Annexe.php
new file mode 100644
index 00000000000..d8706b1a05d
--- /dev/null
+++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Annexe.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Copyright (c) 2012-2017, 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_Controller_Plugin_ResourceDefinition_Annexe extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract {
+
+  public function getDefinitions() {
+    return ['model' => ['class' => 'Class_CodifAnnexe',
+                        'name' => 'annexe',
+                        'order' => 'libelle',
+                        'model_id' => 'id_annexe'],
+
+            'messages' => ['successful_save' => $this->_('L\'annexe "%s" a été modifée'),
+                           'successful_add' => $this->_('L\'annexe "%s" a été ajoutée'),
+                           'successful_delete' => $this->_('L\'annexe "%s" a été suppriméee')],
+
+            'form_class_name' => 'ZendAfi_Form_Admin_Annexe'];
+  }
+}
+?>
\ No newline at end of file
-- 
GitLab