diff --git a/application/modules/admin/views/scripts/users/manage-double-user.phtml b/application/modules/admin/views/scripts/users/manage-double-user.phtml index ca6fc9e512602a2755a3e6f8fbfd9897818d01a8..2155c59c0614485fd276358abd0d3d5debaf3697 100644 --- a/application/modules/admin/views/scripts/users/manage-double-user.phtml +++ b/application/modules/admin/views/scripts/users/manage-double-user.phtml @@ -22,12 +22,6 @@ $description = (new Class_TableDescription('double-users')) ? $this->_('Non') : $this->_('Oui'); }) - ->addColumn($this->_('Enrichissements'), function($model) - { - return (new Class_User_Datas($model))->hasDatas() - ? $this->_('Oui') - : $this->_('Non'); - }) ->addRowAction(function ($model) { $id_users = (new Storm_Model_Collection($this->users)) diff --git a/library/Class/User/DbDoubleFinder.php b/library/Class/User/DbDoubleFinder.php index 63d13aa0e5f94f28acfff364e8b40e102c3ed4d4..31bd02ac67617329c7d298a5f639d7d0e7d1ea8c 100644 --- a/library/Class/User/DbDoubleFinder.php +++ b/library/Class/User/DbDoubleFinder.php @@ -79,6 +79,11 @@ class Class_User_DbDoubleFinder { } + public function hasDoubleFor($user) { + return 1 < count($this->findDoubleFor($user)); + } + + public function findDoubleFor($user) { return $this->_findDoubleWithParams($user->getIdabon(), $user->getLogin(), diff --git a/library/ZendAfi/Controller/Plugin/Manager/User.php b/library/ZendAfi/Controller/Plugin/Manager/User.php index 0f587642a82551a1debb7ceef4127b4baed41156..40fd1f0d35f295c02cada011f1291acf45c05961 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/User.php +++ b/library/ZendAfi/Controller/Plugin/Manager/User.php @@ -23,36 +23,48 @@ class ZendAfi_Controller_Plugin_Manager_User extends ZendAfi_Controller_Plugin_Manager_Manager { public function getActions($model) { return [['url' => ['module' => 'admin', - 'controller' => 'users', - 'action' => 'edit', - 'id' => '%s'], - 'icon' => 'edit', - 'label' => $this->_('modifier')], - - ['url' => ['module' => 'admin', - 'controller' => 'users', - 'action' => 'delete', - 'id' => '%s'], - 'icon' => 'delete', - 'label' => $this->_('supprimer')], - - ['url' => ['module' => 'opac', - 'controller' => 'blog', - 'action' => 'viewauteur', - 'id' => '%s'], - 'icon' => 'star', - 'label' => $this->_('avi(s)'), - 'condition' => 'hasAvis', - 'anchorOptions' => ['target' => '_blank']], - - ['url' => ['module' => 'opac', - 'controller' => 'panier', - 'action' => 'viewauteur', - 'id' => '%s'], - 'icon' => 'basket', - 'label' => $this->_('panier(s)'), - 'condition' => 'hasPaniers', - 'anchorOptions' => ['target' => '_blank']]]; + 'controller' => 'users', + 'action' => 'edit', + 'id' => '%s'], + 'icon' => 'edit', + 'label' => $this->_('modifier')], + + ['url' => ['module' => 'admin', + 'controller' => 'users', + 'action' => 'delete', + 'id' => '%s'], + 'icon' => 'delete', + 'label' => $this->_('supprimer')], + + ['url' => ['module' => 'opac', + 'controller' => 'blog', + 'action' => 'viewauteur', + 'id' => '%s'], + 'icon' => 'star', + 'label' => $this->_('avi(s)'), + 'condition' => 'hasAvis', + 'anchorOptions' => ['target' => '_blank']], + + ['url' => ['module' => 'opac', + 'controller' => 'panier', + 'action' => 'viewauteur', + 'id' => '%s'], + 'icon' => 'basket', + 'label' => $this->_('panier(s)'), + 'condition' => 'hasPaniers', + 'anchorOptions' => ['target' => '_blank']], + + ['url' => ['module' => 'admin', + 'controller' => 'users', + 'action' => 'manage-double-user', + 'id_user' => '%s'], + 'icon' => 'help', + 'label' => $this->_('Doublons'), + 'condition' => function ($model) { + return (new Class_User_DbDoubleFinder())->hasDoubleFor($model); + } + ] + ]; } diff --git a/tests/application/modules/admin/controllers/UsersControllerTest.php b/tests/application/modules/admin/controllers/UsersControllerTest.php index 2038bb45394356657b9afe9231ebceaf078bc29e..e0ff513f7a80ab8bbadd95c826875a0d847b5808 100644 --- a/tests/application/modules/admin/controllers/UsersControllerTest.php +++ b/tests/application/modules/admin/controllers/UsersControllerTest.php @@ -1694,4 +1694,38 @@ class UsersControllerForceDeleteDoubleTest extends UsersControllerDoubleTestCase public function user655ShouldBeDeleted() { $this->assertNull(Class_Users::find(655)); } -} \ No newline at end of file +} + + + +class UsersControllerIndexWithDoubleTest extends UsersControllerDoubleTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/users/index', true); + } + + + /** @test */ + public function buttonManageDoubleShouldBePresent() { + $this->assertXpath('//button[contains(@onclick, "/admin/users/manage-double")]'); + } + + + /** @test */ + public function linkToManageDoubleOfUserId25ShouldBePresent() { + $this->assertXpath('//td//a[contains(@href, "/admin/users/manage-double-user/id_user/25")]'); + } + + + /** @test */ + public function idUser123ShouldBePresent() { + $this->assertXPath('//td//a[contains(@href, "/admin/users/edit/id/123")]'); + } + + + /** @test */ + public function idUser123ShouldNotHaveLinkToManageDouble() { + $this->assertNotXPath('//td//a[contains(@href, "/admin/users/manage-double-user/id_user/123")]'); + } +}