Skip to content
Snippets Groups Projects
Commit 176108ed authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #47256 keep connection in front

parent d9d4feb7
Branches
Tags
5 merge requests!1803Master,!1797Master,!1793Master,!1792Stable,!1791Hotline#47256 deconnexion
- ticket #47256 : Ajout du heartbeat en front office lorsque l'on est connecté avec un compte ayant les droits d'accès au back office
\ No newline at end of file
......@@ -33,10 +33,7 @@
echo $this->headScript();
echo $this->headLink();
echo $this->heartbeat();
?>
<script>
(function heartbeat() {
$.get('<?php echo BASE_URL ?>/admin/index/heartbeat', function() {setTimeout(heartbeat, 60000);});
})();
</script>
</head>
......@@ -112,5 +112,6 @@
$head_scripts->renderJavaScripts();
$script_loader->renderJavaScripts();
echo $this->heartbeat();
?>
</head>
<?php
/**
* Copyright (c) 2012-2014, 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_View_Helper_Heartbeat extends ZendAfi_View_Helper_BaseHelper {
public function heartbeat() {
return Class_Users::isCurrentUserCanAccesBackend()
? $this->_tag('script',
sprintf('(function heartbeat() {$.get("%s", function() {setTimeout(heartbeat, 60000);}); })();',
$this->view->absoluteUrl(['module' => 'admin',
'controller' => 'index',
'action' => 'heartbeat'], null, true)))
: '';
}
}
?>
\ No newline at end of file
......@@ -465,3 +465,28 @@ class IndexControllerInspectorGadgetTest extends AbstractControllerTestCase {
$this->assertEquals([], $calls);
}
}
class IndexControllerHeartBeatTest extends Admin_AbstractControllerTestCase {
/** @test */
public function indexAsAdminShouldContainsHeartbeatScript() {
$this->dispatch('/opac/index/index', true);
$this->assertXPathContentContains('//script', '/admin/index/heartbeat');
}
/** @test */
public function indexAdAbonneShouldNotContainsHeartbeatScript() {
ZendAfi_Auth::getInstance()->logUser($this->fixture('Class_Users',
['id' => 2,
'login' => 'abonne',
'password' => 'year',
'id_site' => 1,
'idabon' => 789465,
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]));
$this->dispatch('/opac/index/index', true);
$this->assertNotXPathContentContains('//script', '/admin/index/heartbeat');
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment