diff --git a/Controller/PluginCleaningController.php b/Controller/PluginCleaningController.php index bda37ae..bb68326 100644 --- a/Controller/PluginCleaningController.php +++ b/Controller/PluginCleaningController.php @@ -14,7 +14,7 @@ class PluginCleaningController extends BaseController { - public function confirmRemoval() + public function confirmDeletePlugin() { $this->response->html($this->template->render('contentCleaner:config/modals/plugin_remove', array( 'plugin_job_name' => $this->request->getStringParam('plugin_job_name'), @@ -22,4 +22,111 @@ public function confirmRemoval() 'plugin_name' => $this->request->getStringParam('plugin_name'), ))); } + + public function deletePlugin($plugin_name) + { + $this->checkCSRFParam(); + + $plugin_name = $this->request->getStringParam('plugin_name'); + + if ($this->pluginCleaningModel->deletePlugin($plugin_name)) { + $this->flash->success(t('Deep cleaning complete - plugin removed successfully')); + } else { + $this->flash->failure(t('Cleaning failed')); + } + + $this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner'))); + } + + public function confirmDeletePluginTables() + { + $this->response->html($this->template->render('contentCleaner:config/modals/purge_plugin_schemas', array( + 'job' => $this->request->getStringParam('job'), + ))); + } + + public function deletePluginTables() + { + // DELETE PLUGIN TABLES + + $plugin_table = $this->request->getStringParam('plugin_table'); + $this->checkCSRFParam(); + + if ($this->applicationCleaningModel->delete($table)) { + $this->flash->success(t('Plugin tables were deleted successfully')); + } else { + $this->flash->failure(t('Cleaning failed')); + } + + $this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner'))); + } + + public function confirmDeleteCoreTableColumns() + { + $this->response->html($this->template->render('contentCleaner:config/modals/purge_plugin_schemas', array( + 'job' => $this->request->getStringParam('job'), + ))); + } + + public function deleteCoreTableColumns() + { + // DELETE CORE COLUMNS CREATED BY THE PLUGIN + + $table = $this->request->getStringParam('table'); + $values = $this->request->getRawFormValues(); + + if (!empty($values)) { + foreach ($values as $key => $val) { + if ($this->applicationCleaningModel->deleteColumn($table, $key)) { + $this->flash->success(t('Cleaning complete - Database column deleted successfully')); + } else { + $this->flash->failure(t('Cleaning failed')); + } + } + } else { + $this->flash->failure(t('No columns were selected')); + } + + $this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner'))); + } + + public function confirmDeleteCoreTableEntries() + { + $this->response->html($this->template->render('contentCleaner:config/modals/purge_plugin_schemas', array( + 'job' => $this->request->getStringParam('job'), + ))); + } + + public function deleteCoreTableEntries() + { + // DELETE THE PLUGIN SCHEMA ENTRY FOR THE PLUGIN + + if ($this->applicationCleaningModel->purgeUninstalledPluginSchemas()) { + $this->flash->success(t('Purge complete - Plugin schema data successfully removed')); + } else { + $this->flash->failure(t('Purge failed - Might not be anything to purge')); + } + + $this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner'))); + } + + public function confirmDeletePluginSchemaEntry() + { + $this->response->html($this->template->render('contentCleaner:config/modals/purge_plugin_schemas', array( + 'job' => $this->request->getStringParam('job'), + ))); + } + + public function deletePluginSchemaEntry() + { + // DELETE THE PLUGIN SCHEMA ENTRY FOR THE PLUGIN + + if ($this->applicationCleaningModel->purgeUninstalledPluginSchemas()) { + $this->flash->success(t('Purge complete - Plugin schema data successfully removed')); + } else { + $this->flash->failure(t('Purge failed - Might not be anything to purge')); + } + + $this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner'))); + } }