From a0492527032bed9c71c53e151fbc1a37b82a0745 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Tue, 25 Sep 2012 15:28:04 +0000
Subject: [PATCH] =?UTF-8?q?Si=20ArteVOD=20actif=20et=20pas=20bib=20num?=
 =?UTF-8?q?=C3=A9rique,=20bib=20num=C3=A9rique=20en=20lecture=20seule?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../admin/controllers/AlbumController.php     | 35 +++++++++++--------
 .../admin/views/scripts/album/index.phtml     | 11 +++---
 .../View/Helper/Admin/MenuGaucheAdmin.php     | 17 ++++-----
 .../admin/controllers/AlbumControllerTest.php | 30 ++++++++++++++++
 4 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php
index 84e51d5531c..91dbbbc9050 100644
--- a/application/modules/admin/controllers/AlbumController.php
+++ b/application/modules/admin/controllers/AlbumController.php
@@ -517,20 +517,27 @@ class Admin_AlbumController extends Zend_Controller_Action {
 
 
 	protected function _getTreeViewContainerActions() {
-		return array(array('url' => $this->_getUrlForAction('add_categorie_to'),
-											 'icon' => 'ico/add_cat.gif',
-											 'label' => 'Ajouter une sous-catégorie'),
-			           array('url' => $this->_getUrlForAction('add_album_to'),
-											 'icon' => 'ico/add_news.gif',
-											 'label' => 'Ajouter un album'),
-			           array('url' => $this->_getUrlForAction('edit_categorie'),
-											 'icon' => 'ico/edit.gif',
-											 'label' => 'Modifier la catégorie'),
-			           array('url' => $this->_getUrlForAction('delete_categorie'),
-											 'icon' => 'ico/del.gif',
-											 'label' => 'Supprimer la catégorie',
-									     'condition' => 'hasNoChild',
-											 'anchorOptions' => array('onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')")));
+		$actions = Class_AdminVar::isBibNumEnabled() 
+			? [['url' => $this->_getUrlForAction('add_categorie_to'),
+					'icon' => 'ico/add_cat.gif',
+					'label' => 'Ajouter une sous-catégorie'],
+
+				 ['url' => $this->_getUrlForAction('add_album_to'),
+					'icon' => 'ico/add_news.gif',
+					'label' => 'Ajouter un album']]
+
+			: [];
+
+		return array_merge($actions, 
+											 [['url' => $this->_getUrlForAction('edit_categorie'),
+												 'icon' => 'ico/edit.gif',
+												 'label' => 'Modifier la catégorie'],
+
+												['url' => $this->_getUrlForAction('delete_categorie'),
+												 'icon' => 'ico/del.gif',
+												 'label' => 'Supprimer la catégorie',
+												 'condition' => 'hasNoChild',
+												 'anchorOptions' => ['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]]]);
 	}
 
 
diff --git a/application/modules/admin/views/scripts/album/index.phtml b/application/modules/admin/views/scripts/album/index.phtml
index ae152bb9b7e..c8bc39cdfcb 100644
--- a/application/modules/admin/views/scripts/album/index.phtml
+++ b/application/modules/admin/views/scripts/album/index.phtml
@@ -1,9 +1,10 @@
 <?php
-echo $this->bouton('id=add_category',
-									 'picto=add.gif',
-									 'texte=' . $this->traduire('Ajouter une collection'),
-									 'url=' . $this->url(array('action' => 'add_categorie',
-																					 'id' => null))
+if (Class_AdminVar::isBibNumEnabled())
+	echo $this->bouton('id=add_category',
+										 'picto=add.gif',
+										 'texte=' . $this->traduire('Ajouter une collection'),
+										 'url=' . $this->url(array('action' => 'add_categorie',
+																							 'id' => null))
 );
 
 ?>
diff --git a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php
index 2b3a908f23d..f8806c0dcab 100644
--- a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php
+++ b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php
@@ -67,17 +67,18 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdmin extends ZendAfi_View_Helper_Base
 		$menu_modules .= $this->closeBoite();
 
 		$menu_bibnum = '';
-		if (Class_AdminVar::isBibNumEnabled()) {
-			$menu_bibnum .= $this->openBoite($this->translate()->_("Bibliothèque numérique"));
+		$menu_bibnum .= $this->openBoite($this->translate()->_("Bibliothèque numérique"));
+		if (Class_AdminVar::isBibNumEnabled() || Class_AdminVar::isArteVODEnabled()) {
 			$menu_bibnum .= $this->addMenu("collections_16.png",		$this->translate()->_("Collections"),						"/admin/album",								 $acl_admins);
-			$menu_bibnum .= $this->addMenu("epub_16.png",						$this->translate()->_("Catalogues OPDS"),				"/admin/opds",								 $acl_admins);
-			$menu_bibnum .= $this->addMenu("oai_16.png",						$this->translate()->_("Entrepôts OAI"),					"/admin/oai",									 $acl_admins);
 			$menu_bibnum .= $this->addMenu("artevod_16.png",				$this->translate()->_("Arte VOD"),							"/admin/harvest/arte-vod-browse",	$acl_admins);
-			$menu_bibnum .= $this->addMenu("ead_16.png",						$this->translate()->_("Import EAD"),						"/admin/album/import_ead",		 $acl_admins);
-			$menu_bibnum .= $this->addMenu('frbr_16.png', $this->translate()->_('Notices liées'), '/admin/frbr-link', $acl_admins);
-			$menu_bibnum .= $this->closeBoite();
+			if (Class_AdminVar::isBibNumEnabled()) {
+				$menu_bibnum .= $this->addMenu("epub_16.png",						$this->translate()->_("Catalogues OPDS"),				"/admin/opds",								 $acl_admins);
+				$menu_bibnum .= $this->addMenu("oai_16.png",						$this->translate()->_("Entrepôts OAI"),					"/admin/oai",									 $acl_admins);
+				$menu_bibnum .= $this->addMenu("ead_16.png",						$this->translate()->_("Import EAD"),						"/admin/album/import_ead",		 $acl_admins);
+			} 
 		}
-
+		$menu_bibnum .= $this->addMenu('frbr_16.png', $this->translate()->_('Notices liées'), '/admin/frbr-link', $acl_admins);
+		$menu_bibnum .= $this->closeBoite();
 
 		$menu_page	= $this->openBoite($this->translate()->_("Mise en page"));
 		$menu_page .= $this->addMenu("profils_16.png",			$this->translate()->_("Profils"),									"/admin/profil",				 $acl_admins);
diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php
index 0f3df3bbf21..4d500e86feb 100644
--- a/tests/application/modules/admin/controllers/AlbumControllerTest.php
+++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php
@@ -297,6 +297,36 @@ class Admin_AlbumControllerIndexTest extends Admin_AlbumControllerTestCase {
 
 
 
+class Admin_AlbumControllerWithoutBibNumTest extends Admin_AlbumControllerTestCase {
+	public function setUp() {
+		parent::setUp();
+		Class_AdminVar::newInstanceWithId('BIBNUM')->setValeur('0');
+		$this->dispatch('/admin/album', true);
+	}
+
+
+	/** @test */
+	public function buttonAddAlbumShouldNotBeVisible() {
+
+		$this->assertNotXPath("//div[contains(@onclick, '/admin/album/add_categorie')]");
+	}
+
+
+	/** @test */
+	public function noAjouteAlbumLinkShouldBeVisible() {
+		$this->assertNotXPath("//a[contains(@href, 'add_album_to')]");
+	}
+
+
+	/** @test */
+	public function noAddCategorieToLinkShouldBeVisible() {
+		$this->assertNotXPath("//a[contains(@href, 'add_categorie_to')]");
+	}
+}
+
+
+
+
 class Admin_AlbumControllerAddCategorieToFavorisTest extends Admin_AlbumControllerTestCase {
 	public function setUp() {
 		parent::setUp();
-- 
GitLab