diff --git a/application/modules/admin/controllers/WidgetController.php b/application/modules/admin/controllers/WidgetController.php index 58c9d3ae93f08292406bc2fdd9595059c491004a..f5cd084f44eb91b138b43007e87b9212c11bbda5 100644 --- a/application/modules/admin/controllers/WidgetController.php +++ b/application/modules/admin/controllers/WidgetController.php @@ -66,6 +66,25 @@ class Admin_WidgetController extends ZendAfi_Controller_Action { } + public function deleteAction() { + if(!$division = $this->_getParam('division')) + return $this->_redirectClose($this->_getReferer()); + + $widget = new Class_Systeme_Widget_Widget(); + if(!$widget + ->setId($this->_getParam('id')) + ->setProfileId($this->_getParam('id_profil')) + ->load()) + return $this->_redirectClose($this->_getReferer()); + + $this->view->titre = $widget->getTitle(); + $widget->getProfile()->removeBoiteFromDiv($widget->getId(), $division)->save(); + + $this->_helper->notify($this->_('La boite %s a été supprimée', $widget->getTitle())); + return $this->_redirectClose($this->_getReferer()); + } + + public function editMenuAction() { return $this->_edit(new Class_Systeme_Widget_Menu()); } diff --git a/library/ZendAfi/View/Helper/FonctionsAdmin.php b/library/ZendAfi/View/Helper/FonctionsAdmin.php index 1e4d56300130e40af81965b2d63da9457d322c91..808f9410bc4f8d6b7dcf840cecc085ee72325e8c 100644 --- a/library/ZendAfi/View/Helper/FonctionsAdmin.php +++ b/library/ZendAfi/View/Helper/FonctionsAdmin.php @@ -121,6 +121,7 @@ class ZendAfi_View_Helper_FonctionsAdmin extends ZendAfi_View_Helper_BaseHelper 'controller' => 'widget', 'action' => 'delete', 'id' => $this->id_module, + 'division' => $this->division, 'id_profil' => $this->_getIdProfil()], null, true); diff --git a/tests/application/modules/admin/controllers/WidgetControllerTest.php b/tests/application/modules/admin/controllers/WidgetControllerTest.php index 9e80324eb25c3aa1ce2fcd5488f9e3be902019cf..c826466321340e860fff7b1e0e8024a53a8a9927 100644 --- a/tests/application/modules/admin/controllers/WidgetControllerTest.php +++ b/tests/application/modules/admin/controllers/WidgetControllerTest.php @@ -1495,14 +1495,14 @@ class WidgetControllerParentLoginDispatchTest extends WidgetControllerLoginInPar /** @test */ public function addWidgetLinkShouldUseParentProfil() { $this->dispatch('/opac/index/index/id_profil/6', true); - $this->assertXpath('//div//a[contains(@href, "admin/widget/add/after/2/id_profil/2")]'); + $this->assertXpath('//div//a[contains(@href, "admin/widget/add/after/2/division/4/id_profil/2")]'); } /** @test */ public function deleteWidgetLinkShouldUseParentProfil() { $this->dispatch('/opac/index/index/id_profil/6', true); - $this->assertXpath('//div//a[contains(@href, "admin/widget/delete/id/2/id_profil/2")]'); + $this->assertXpath('//div//a[contains(@href, "admin/widget/delete/id/2/division/4/id_profil/2")]'); } @@ -1951,4 +1951,27 @@ class WidgetControllerAddActionPostDispatchTest extends WidgetControllerWidgetCo public function currentProfilShouldHaveNbNotices() { $this->assertEquals(20, $this->_profil->getCfgAccueilAsArray()['modules'][1]['preferences']['nb_notices']); } +} + + + + +class WidgetControllerDeleteActionTest extends WidgetControllerWidgetConfigurationTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('admin/widget/delete/id/6/division/3/id_profil/5', true); + Class_Profil::clearCache(); + } + + + /** @test */ + public function shouldRedirect() { + $this->assertRedirect(); + } + + + /** @test */ + public function widgetSixShouldHaveBeenRemoved() { + $this->assertEquals([], $this->_profil->getCfgAccueilAsArray()['modules']); + } } \ No newline at end of file