diff --git a/VERSIONS_HOTLINE/64837 b/VERSIONS_HOTLINE/64837 new file mode 100644 index 0000000000000000000000000000000000000000..af6e0758d29f4a12f6d4b186907f2c7248e0892a --- /dev/null +++ b/VERSIONS_HOTLINE/64837 @@ -0,0 +1 @@ + - ticket #64837 : Administration : correction des droits de suppresion des boites. diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php index e1ff46101d805ceef360ecab3298cbee535cae8f..ebbbe07871febf4c2dd668f21f35e7056d51b775 100644 --- a/application/modules/admin/controllers/IndexController.php +++ b/application/modules/admin/controllers/IndexController.php @@ -158,4 +158,22 @@ class Admin_IndexController extends ZendAfi_Controller_Action { $this->_helper->notify($message); $this->_redirect('admin/index/update-skin'); } + + + public function becomeAction() { + if(!Class_Users::getIdentity()->isSuperAdmin()) { + $this->_helper->notify($this->_('Vous n\'avez pas les droits suffisants pour utiliser cette fonctionnalité.')); + return $this->_redirectToIndex(); + } + + if(!$user = Class_Users::find($this->_getParam('id', null))) { + $this->_helper->notify($this->_('Utilisateur invalide')); + return $this->_redirectToIndex(); + } + + ZendAfi_Auth::getInstance()->logUser($user); + $this->_helper->notify($this->_('Vous êtes maintenant connecté avec l\'utilisateur "%s"', + $user->getNomComplet())); + $this->_redirectToIndex(); + } } \ No newline at end of file diff --git a/application/modules/admin/views/scripts/users/index.phtml b/application/modules/admin/views/scripts/users/index.phtml index 22a26d3d9f8ea923421f4bfe4e7b0f15c0467d06..eeb3a95334023ed6be57bf458f11339a05690057 100644 --- a/application/modules/admin/views/scripts/users/index.phtml +++ b/application/modules/admin/views/scripts/users/index.phtml @@ -33,7 +33,15 @@ $map =[['url' => ['module' => 'admin', 'icon' => 'basket', 'label' => $this->_('panier(s)'), 'condition' => 'hasPaniers', - 'anchorOptions' => ['target' => '_blank']]]; + 'anchorOptions' => ['target' => '_blank']], + + ['url' => ['module' => 'admin', + 'controller' => 'index', + 'action' => 'become', + 'id' => '%s'], + 'icon' => 'users', + 'condition' => function() { return Class_Users::getIdentity()->isSuperAdmin();}, + 'label' => $this->_('Se connecter avec l\'identité')]]; $actions = function($user) use($map) { return $this->renderModelActions($user,$map); diff --git a/tests/application/modules/admin/controllers/IndexControllerTest.php b/tests/application/modules/admin/controllers/IndexControllerTest.php index 8951deba852f3f799e3994f7bc88f33ece228b04..a15a015ffcdb5de442b35af83dbdef390722690c 100644 --- a/tests/application/modules/admin/controllers/IndexControllerTest.php +++ b/tests/application/modules/admin/controllers/IndexControllerTest.php @@ -454,4 +454,35 @@ class Admin_IndexControllerAdminvarActionTest extends Admin_AbstractControllerTe public function varNewsletterUnsubscribeTextShouldBeLienPourSeDesinscrire() { $this->assertXPathContentContains('//tr[@data-adminvar="NEWSLETTER_UNSUBSCRIBE_TEXT"]//td', 'Lien pour se '); } +} + + + + +class IndexControllerBecomeActionTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Users', + ['id' => 78, + 'login' => 'test78', + 'password' => 'pwd']); + + $this->dispatch('/admin/index/become/id/78', true); + } + + + /** @test */ + public function shouldRedirect() { + $this->assertRedirect(); + } + + + /** @test */ + public function logedUserShouldBeTest78() { + $this->assertEquals(78, Class_Users::getIdentity()->getId()); + } } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/UsersControllerTest.php b/tests/application/modules/admin/controllers/UsersControllerTest.php index d65c549915a9d87fd3ad6c7bd0f66db2d544243d..474f9204ce05210dce0e546d91d9ef2105dd3d95 100644 --- a/tests/application/modules/admin/controllers/UsersControllerTest.php +++ b/tests/application/modules/admin/controllers/UsersControllerTest.php @@ -764,6 +764,7 @@ class UsersControllerReferentIndexTest extends UsersControllerWithMarcusTestCase + class UsersControllerAddActionPostTest extends UsersControllerWithMarcusTestCase { public function setUp() { parent::setUp(); @@ -1176,3 +1177,29 @@ class UsersControllerWithAdminPortalTest extends Admin_AbstractControllerTestCas $this->assertXPath('//th/a[contains(@href, "/search_order/nom/")]'); } } + + + + +class UsersControllerWithSuperAdminTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 1, + 'login' => 'tom', + 'password' => 'rom', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + + $this->dispatch('/admin/users/index', true); + } + + + /** @test */ + public function linkToBecomeTimShouldBePresent() { + $this->assertXPath('//a[contains(@href, "/admin/index/become/")]', $this->_response->getBody()); + } +} \ No newline at end of file