diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index b20f1e729b65e420b1927a6d7c9fb013004ac67e..4dd5a28729d7417ee5e1417b7c29b45719ffe2de 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -340,6 +340,7 @@ class Class_AdminVar extends Storm_Model_Abstract { 'DATE_LAST_FULL_INTEGRATION_USERS' => '', 'BOITE_PANIER_AUTO' => 'Ajouter automatiquement une boîte panier dans la division flottante. 0 = inactif, 1 = actif', 'EXTRA_SKIN_PATH' => 'Chemin vers les skins personnalisées, relatif à ' . Class_Profil_Skin::EXTRA_PATH, + 'ENABLE_COLLABORATIVE_BROWSING' => 'Activation de la navigation collaborative. 0 = inactif, 1 = actif', ]; return self::$_knownVars; } diff --git a/library/ZendAfi/Controller/Plugin/TogetherJS.php b/library/ZendAfi/Controller/Plugin/TogetherJS.php new file mode 100644 index 0000000000000000000000000000000000000000..95d02645e7687cf5f08f0c7901ad91a6f520a61d --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/TogetherJS.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_Controller_Plugin_TogetherJS extends Zend_Controller_Plugin_Abstract { + public function preDispatch(Zend_Controller_Request_Abstract $request) { + if (!Class_AdminVar::isModuleEnabled('ENABLE_COLLABORATIVE_BROWSING')) + return; + Class_ScriptLoader::getInstance() + ->addScript('https://togetherjs.com/togetherjs-min.js') + ->addJQueryReady('$("<button onclick=\'TogetherJS(this);return false\'>Start TogetherJS</button>") + .css("position", "absolute") + .css("top", "0") + .css("left", "0") + .appendTo("body")'); + } +} + +?> \ No newline at end of file diff --git a/library/startup.php b/library/startup.php index 6080c159156a5e764f0ba6472d548c5412ae887f..c5bcbb830436684f4ce9489c7d4a2f507775ce20 100644 --- a/library/startup.php +++ b/library/startup.php @@ -270,6 +270,7 @@ function setupFrontController($cfg) { ->registerPlugin(new ZendAfi_Controller_Plugin_SelectionBib()) ->registerPlugin(new ZendAfi_Controller_Plugin_System()) ->registerPlugin(new ZendAfi_Controller_Plugin_Popup()) + ->registerPlugin(new ZendAfi_Controller_Plugin_TogetherJS()) ->setParam('useDefaultControllerAlways', true); diff --git a/scripts/emacs/phafi-mode.el b/scripts/emacs/phafi-mode.el index b8a11f36918cfc22200edd30b17cee26c020bb05..895bf3eddc2cf8481438102beaf26d64520d4e3b 100644 --- a/scripts/emacs/phafi-mode.el +++ b/scripts/emacs/phafi-mode.el @@ -592,6 +592,7 @@ "update variables set valeur='admin' where clef='admin_login';" "update variables set valeur='admin' where clef='admin_pwd';" "update mysql.proc set definer='root@localhost';" + "update bib_admin_var set valeur='1' where clef='ENABLE_COLLABORATIVE_BROWSING';" "drop trigger datemaj_notices_update;") mysql-connection-info) diff --git a/tests/application/modules/opac/controllers/TogetherJSTest.php b/tests/application/modules/opac/controllers/TogetherJSTest.php new file mode 100644 index 0000000000000000000000000000000000000000..17e2e7068541c6d46e3c10cbf3d3156a683c24d5 --- /dev/null +++ b/tests/application/modules/opac/controllers/TogetherJSTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +abstract class TogetherJSTestCase extends AbstractControllerTestCase { + public function logAdmin() { + ZendAfi_Auth::getInstance() + ->logUser( $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'admin', + 'password' => 'pass']) + ->beAdminPortail()); + } +} + + +class TogetherJSDisabledTest extends TogetherJSTestCase { + public function setUp() { + parent::setUp(); + Class_AdminVar::newInstanceWithId('ENABLE_COLLABORATIVE_BROWSING', + ['valeur' => 0]); + } + + /** @test */ + public function onOPACIndexTogetherJSShouldNotBePresent() { + $this->dispatch('/'); + $this->assertNotXPath('//script[contains(@src, "togetherjs")]'); + } + + + /** @test */ + public function onAdminIndexTogetherJSShouldNotBePresent() { + $this->logAdmin(); + $this->dispatch('/admin'); + $this->assertNotXPath('//script[contains(@src, "togetherjs")]'); + } + + + /** @test */ + public function adminVariablesShouldListEnableCollaborativeBrowsingOption() { + $this->logAdmin(); + $this->dispatch('/admin/index/adminvar', true); + $this->assertXpathContentContains('//td', 'ENABLE_COLLABORATIVE_BROWSING'); + } +} + + + +class TogetherJSEnabledTest extends TogetherJSTestCase { + public function setUp() { + parent::setUp(); + Class_AdminVar::newInstanceWithId('ENABLE_COLLABORATIVE_BROWSING', + ['valeur' => 1]); + } + + /** @test */ + public function onOPACIndexTogetherJSShouldBePresent() { + $this->dispatch('/'); + $this->assertXPath('//script[contains(@src, "togetherjs")]'); + } + + + /** @test */ + public function onAdminIndexTogetherJSShouldBePresent() { + $this->logAdmin(); + $this->dispatch('/admin'); + $this->assertXPath('//script[contains(@src, "togetherjs")]'); + } +} + +?> diff --git a/tests/bootstrap_frontcontroller.php b/tests/bootstrap_frontcontroller.php index 285186cc34d79343962428d7a8c02e8a81495d93..51662e477de7650e4cd30255d432303cb52dd362 100644 --- a/tests/bootstrap_frontcontroller.php +++ b/tests/bootstrap_frontcontroller.php @@ -35,7 +35,8 @@ $controller = Zend_Controller_Front::getInstance() ->registerPlugin(new ZendAfi_Controller_Plugin_DefineURLs()) ->registerPlugin(new ZendAfi_Controller_Plugin_InitModule()) ->registerPlugin(new ZendAfi_Controller_Plugin_SelectionBib()) - ->registerPlugin(new ZendAfi_Controller_Plugin_System()); + ->registerPlugin(new ZendAfi_Controller_Plugin_System()) + ->registerPlugin(new ZendAfi_Controller_Plugin_TogetherJS()); $_SESSION["selection_bib"]=array("message" => 'selection bib sucks', "nb_notices" => 12345,