diff --git a/VERSIONS_WIP/135599 b/VERSIONS_WIP/135599 new file mode 100644 index 0000000000000000000000000000000000000000..8a7733f7bb04feefeeaa38ee86657e3b38a6bfdf --- /dev/null +++ b/VERSIONS_WIP/135599 @@ -0,0 +1 @@ + - fonctionnalité #135599 : Portail : L'ip publique du client est affiché en data-public-ip de la balise body. \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/View.php b/library/ZendAfi/Controller/Action/Helper/View.php index 00ce8955065d7226f4bd133768ddbc2a8bf57445..7fe2a0b0701f978a59c282f7188f913df4168888 100644 --- a/library/ZendAfi/Controller/Action/Helper/View.php +++ b/library/ZendAfi/Controller/Action/Helper/View.php @@ -46,7 +46,11 @@ class ZendAfi_Controller_Action_Helper_View extends Zend_View { } - public function setModuleControllerActionNames($module, $controller, $action) { + public function setRequest($request) { + $module = $request->getModuleName(); + $controller = $request->getControllerName(); + $action = $request->getActionName(); + $template = Class_Template::current()->getId(); $profile_id = Class_Profil::getCurrentProfil()->getId(); @@ -63,6 +67,7 @@ class ZendAfi_Controller_Action_Helper_View extends Zend_View { 'data-logged' => $logged, 'data-profile-id' => $profile_id, 'data-template' => $template, + 'data-public-ip' => (new Class_RemoteClient($request))->getIpAddress(), 'data-module' => $module, 'data-controller' => $controller, 'data-action' => $action]; diff --git a/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php b/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php index c8050fd431593a34a1ffdb430802f2d9a1de115d..4a3754e2ef4ba8d143e7f1893e4a9823c489d853 100644 --- a/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php +++ b/library/ZendAfi/Controller/Action/Helper/ViewRenderer.php @@ -47,10 +47,7 @@ class ZendAfi_Controller_Action_Helper_ViewRenderer extends Zend_Controller_Acti public function preDispatch() { $this->_initializeHelperPaths(); - $request = $this->getRequest(); - $this->view->setModuleControllerActionNames($request->getModuleName(), - $request->getControllerName(), - $request->getActionName()); + $this->view->setRequest($this->getRequest()); $this->view->profil = Class_Profil::getCurrentProfil(); diff --git a/tests/scenarios/Templates/TemplatesIndexTest.php b/tests/scenarios/Templates/TemplatesIndexTest.php index b7c3b0844f85b2e40ab8a5f786660d1ed55541cb..a6a71fa8f93b9fed36cdcf18be4c05244375a3f4 100644 --- a/tests/scenarios/Templates/TemplatesIndexTest.php +++ b/tests/scenarios/Templates/TemplatesIndexTest.php @@ -42,4 +42,20 @@ class TemplatesIndexTest extends TemplatesIntonationTestCase { public function pageShouldBeHTML5valid() { $this->assertHTML5(); } -} \ No newline at end of file +} + + + +class TemplatesIndexBodyIpAddressTest extends TemplatesIntonationTestCase { + public function setUp() { + parent::setUp(); + $_SERVER['REMOTE_ADDR'] = '10.0.0.1'; + $this->dispatch('/index'); + } + + + /** @test */ + public function withNoUserLoggedTagBodyAttributeDataPublicIpShouldBE10_0_0_1() { + $this->assertXPath('//body[@data-public-ip="10.0.0.1"]'); + } +}