Skip to content

Commit

Permalink
Add rough functions to PluginCleaningController.php
Browse files Browse the repository at this point in the history
- #11
  • Loading branch information
aljawaid committed May 8, 2023
1 parent 1763b0b commit 3988c97
Showing 1 changed file with 108 additions and 1 deletion.
109 changes: 108 additions & 1 deletion Controller/PluginCleaningController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,119 @@

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'),
'job_number' => $this->request->getStringParam('job_number'),
'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')));
}
}

0 comments on commit 3988c97

Please sign in to comment.