diff --git a/VERSIONS_WIP/41303 b/VERSIONS_WIP/41303 new file mode 100644 index 0000000000000000000000000000000000000000..620581633f3c54993694b66dff44612d125a641d --- /dev/null +++ b/VERSIONS_WIP/41303 @@ -0,0 +1 @@ +- #41303 : ajout d'une option pour activer / désactiver globalement la gestion des favoris bibliothèques \ No newline at end of file diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 322ebeedbdb385c51efd05dee281199f10fed09f..00e0e0a28a35f4a48a5759507400d9100f187e40 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -208,7 +208,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { ], 'album' => $this->_getAlbumVars(), 'users' => ['NDAYS_EXPIRY_NOTICE' => Class_AdminVar_Meta::newDefault($this->_('Prévenir l\'utilisateur xx jour(s) avant l\'expiration de son abonnement (par défaut 30 jours).'), ['value' => 30]), - 'DISABLE_SUGGESTIONS' => Class_AdminVar_Meta::newOnOff($this->_('Désactivation des suggestions d\'achats'))->bePrivate()], + 'DISABLE_SUGGESTIONS' => Class_AdminVar_Meta::newOnOff($this->_('Désactivation des suggestions d\'achats'))->bePrivate(), + 'ENABLE_BOOKMARKABLE_LIBRARIES' => Class_AdminVar_Meta::newOnOff($this->_('Les utilisateurs peuvent sélectionner des bibliothèques favorites pour leurs recherche'), ['value' => 1])], 'redmine' => ['REDMINE_SERVER_URL' => Class_Adminvar_Meta::newDefault($this->_('Url du serveur redmine'))->bePrivate(), 'REDMINE_PROXY_URL' => Class_Adminvar_Meta::newDefault($this->_('Url du proxy Redmine'))->bePrivate(), 'REDMINE_PROJECT_ID' => Class_Adminvar_Meta::newDefault($this->_('Identifiant du project Redmine'))->bePrivate()], @@ -452,7 +453,7 @@ class Class_AdminVarLoader extends Storm_Model_Loader { * @return bool */ public function isModuleEnabled($name) { - if (!$value = Class_AdminVar::get($name)) { + if (!$value = Class_AdminVar::getValueOrDefault($name)) { return false; } diff --git a/library/Class/User/Settings.php b/library/Class/User/Settings.php index 48a0cf94b1ae49c72a54740e6f140123658d5d56..8368d29a7e1935d4cc30411ffd08e9aa54ff88f0 100644 --- a/library/Class/User/Settings.php +++ b/library/Class/User/Settings.php @@ -40,9 +40,12 @@ class Class_User_Settings { public static function isBookmarkLibraryReady() { - return Class_Profil::getCurrentProfil()->isItemAnnexDisplay() - ? 1 < Class_CodifAnnexe::countBy([]) - : 1 < Class_Bib::countBy([]); + return + Class_AdminVar::isModuleEnabled('ENABLE_BOOKMARKABLE_LIBRARIES') + && + (Class_Profil::getCurrentProfil()->isItemAnnexDisplay() + ? 1 < Class_CodifAnnexe::countBy([]) + : 1 < Class_Bib::countBy([])); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php b/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php index 884005e5a32694d2ff1898341958783faec30a9e..79bc263ca6f9be0b64570e7241fd22a39e4f4c3a 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php @@ -24,6 +24,10 @@ abstract class AbstractAbonneControllerFicheTest extends AbstractControllerTestC public function setUp() { parent::setUp(); + + $this->fixture('Class_Bib', ['id' => 1]); + $this->fixture('Class_Bib', ['id' => 2]); + $this->marcus = $this->fixture('Class_Users', ['id' => 10, 'login' => 'MC', @@ -149,27 +153,30 @@ class AbonneControllerFicheNobodyLoggedTest extends AbstractAbonneControllerFich -class AbonneControllerFicheAsAdminDisableSuggestTest extends AbstractAbonneControllerFicheTest { +class AbonneControllerFicheAsAdminDisableSuggestAndBookmarkableLibrariesTest extends AbstractAbonneControllerFicheTest { public function setUp() { parent::setUp(); - $this->fixture('Class_AdminVar', - ['id' => 'DISABLE_SUGGESTIONS', - 'valeur' => '1']); - $this->marcus->beAdminPortail(); + Class_AdminVar::set('DISABLE_SUGGESTIONS', 1); + Class_AdminVar::set('ENABLE_BOOKMARKABLE_LIBRARIES', 0); $this->dispatch('/abonne/fiche', true); } /** @test */ public function linkToSuggestionAchatShouldNotBePresent() { - $this->assertNotXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]', - 'Suggérer un achat', $this->_response->getBody()); + $this->assertNotXPath('//a[contains(@href, "/abonne/suggestion-achat")]'); + } + + /** @test */ + public function linkToSettingsShouldNotBePresent() { + $this->assertNotXPath('//a[contains(@href, "/abonne/settings")]'); } } -class AbonneControllerFicheActionWithLoggedUserTest extends AbstractControllerTestCase { + +class AbonneControllerFicheActionWithLoggedUserTest extends AbstractAbonneControllerFicheTest { public function setUp() { parent::setUp(); $this->dispatch('/abonne/fiche', true); @@ -178,12 +185,12 @@ class AbonneControllerFicheActionWithLoggedUserTest extends AbstractControllerTe /** @test */ public function settingsLinkShouldBePopup() { - $this->assertXPath('//div//a[2][@data-popup="true"]', $this->_response->getBody()); + $this->assertXPath('//div//a[contains(@href, "/abonne/settings")][@data-popup="true"]', $this->_response->getBody()); } /** @test */ - public function settingsLinkWithImageShouldBePopup() { - $this->assertXPath('//div//a[@data-popup="true"]/img[contains(@src, "abonnes/settings")]'); + public function settingsLinkShouldContainsImage() { + $this->assertXPath('//div//a[contains(@href, "/abonne/settings")]/img[contains(@src, "abonnes/settings")]'); } }