diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php
index 040c9f7b4..4d286d789 100644
--- a/core/lib/Thelia/Action/Module.php
+++ b/core/lib/Thelia/Action/Module.php
@@ -22,10 +22,13 @@
/*************************************************************************************/
namespace Thelia\Action;
+use Propel\Runtime\Propel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Cache\CacheEvent;
+use Thelia\Core\Event\Module\ModuleDeleteEvent;
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
use Thelia\Core\Event\TheliaEvents;
+use Thelia\Model\Map\ModuleTableMap;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
@@ -59,6 +62,11 @@ class Module extends BaseAction implements EventSubscriberInterface
}
}
+ public function delete(ModuleDeleteEvent $event)
+ {
+
+ }
+
protected function cacheClear()
{
$cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir'));
@@ -89,7 +97,8 @@ class Module extends BaseAction implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
- TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128)
+ TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128),
+ TheliaEvents::MODULE_DELETE => array('delete', 128)
);
}
}
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index 7cc0c0f9f..9c6ead6c7 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -825,6 +825,10 @@
\d+
+
+ Thelia\Controller\Admin\ModuleController::deleteAction
+
+
diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php
index c7d020d58..2be309321 100644
--- a/core/lib/Thelia/Controller/Admin/ModuleController.php
+++ b/core/lib/Thelia/Controller/Admin/ModuleController.php
@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
+use Thelia\Core\Event\Module\ModuleDeleteEvent;
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Module\ModuleManagement;
@@ -82,4 +83,21 @@ class ModuleController extends BaseAdminController
return $response;
}
+
+ public function deleteAction()
+ {
+ if (null !== $response = $this->checkAuth("admin.module.delete")) return $response;
+
+ try {
+
+ $module_id = $this->getRequest()->get('module_id');
+
+ $deleteEvent = new ModuleDeleteEvent($module_id);
+
+ $this->dispatch(TheliaEvents::MODULE_DELETE, $deleteEvent);
+
+ } catch (\Exception $e) {
+
+ }
+ }
}
diff --git a/core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php
new file mode 100644
index 000000000..5622e3931
--- /dev/null
+++ b/core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php
@@ -0,0 +1,61 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Core\Event\Module;
+
+
+/**
+ * Class ModuleDeleteEvent
+ * @package Thelia\Core\Event\Module
+ * @author Manuel Raynaud
+ */
+class ModuleDeleteEvent extends ModuleEvent
+{
+ /**
+ * @var int module id
+ */
+ protected $module_id;
+
+ function __construct($module_id)
+ {
+ $this->module_id = $module_id;
+ }
+
+ /**
+ * @param int $module_id
+ */
+ public function setModuleId($module_id)
+ {
+ $this->module_id = $module_id;
+ }
+
+ /**
+ * @return int
+ */
+ public function getModuleId()
+ {
+ return $this->module_id;
+ }
+
+
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php
index a28c7ffb7..7c2bc17a5 100755
--- a/core/lib/Thelia/Core/Event/TheliaEvents.php
+++ b/core/lib/Thelia/Core/Event/TheliaEvents.php
@@ -665,6 +665,11 @@ final class TheliaEvents
*/
const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation';
+ /**
+ * sent when a module is deleted
+ */
+ const MODULE_DELETE = 'thelia.module.delete';
+
/**
* sent for clearing cache
*/
diff --git a/templates/admin/default/includes/module-block.html b/templates/admin/default/includes/module-block.html
index dd499393f..658557d4e 100644
--- a/templates/admin/default/includes/module-block.html
+++ b/templates/admin/default/includes/module-block.html
@@ -48,7 +48,7 @@
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"}
-
+
{/loop}
diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html
index c94ba8789..847a5ea4a 100644
--- a/templates/admin/default/modules.html
+++ b/templates/admin/default/modules.html
@@ -40,8 +40,7 @@
{* Delete module confirmation dialog *}
{capture "delete_module_dialog"}
-
-
+
{/capture}
{include
@@ -51,7 +50,7 @@
dialog_title = {intl l="Delete a module"}
dialog_message = {intl l="Do you really want to delete this module ?"}
- form_action = {url path='/admin/modules/delete'}
+ form_action = {url path='/admin/configuration/modules/delete'}
form_content = {$smarty.capture.delete_module_dialog nofilter}
}
@@ -95,6 +94,10 @@
});
});
+
+ $(".module-delete-action").click(function(){
+ $("#delete_module_id").val($(this).data("id"));
+ });
});
{/block}
\ No newline at end of file