Skip to content

Commit

Permalink
FIX: deletePluginTables()
Browse files Browse the repository at this point in the history
- #12
- #13
- thanks @alfredbuehler
  • Loading branch information
aljawaid committed May 12, 2023
1 parent c2d4b12 commit 76545b0
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions Controller/PluginCleaningController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

/**
* Plugin ContentCleaner
*
* Class PluginCleaningController
* @author aljawaid
* @author alfredbuehler Alfred Bühler
*/

class PluginCleaningController extends BaseController
Expand Down Expand Up @@ -38,33 +40,49 @@ public function deletePlugin($plugin_name)
$this->response->redirect($this->helper->url->to('ContentCleanerController', 'show', array('plugin' => 'ContentCleaner')));
}

/**
* Confirm Deletion of Plugin Tables (Modal)
*
* @author aljawaid
*/
public function confirmDeletePluginTables()
{
$this->response->html($this->template->render('contentCleaner:config/modals/plugin_deep_clean', array(
'plugin_job_name' => $this->request->getStringParam('plugin_job_name'),
)));
}

/**
* Delete Plugin Tables
*
* @author alfredbuehler Alfred Bühler
*/
public function deletePluginTables()
{
// DELETE PLUGIN TABLES

$this->checkCSRFParam();

// PULL VARIABLE FROM BUTTON
// Pull variable from button
$plugin_job_name = $this->request->getStringParam('plugin_job_name');
$plugin_tables = [];

// MATCH VARIABLE TO JSON CONTENT
// Match variable to json content if the plugin name matches
foreach ($this->helper->pluginCleaningHelper->getDeletablePlugins() as $plugin) {
if ($plugin['plugin_title'] == $plugin_job_name) {
if (isset($plugin['plugin_tables'])) {
return $table;
}
if ($plugin['plugin_title'] === $plugin_job_name && isset($plugin['plugin_tables'])) {
$plugin_tables = $plugin['plugin_tables'];
break;
}
}

// Delete the plugin tables
$success = true;
foreach ($plugin_tables as $table) {
if (!$this->applicationCleaningModel->delete($table)) {
$success = false;
break;
}
}

// DELETE PLUGIN TABLES
if ($this->applicationCleaningModel->delete($table)) {
if ($success) {
$this->flash->success(t('DEEP CLEANING COMPLETE: Plugin tables were deleted successfully'));
} else {
$this->flash->failure(t('DEEP CLEANING FAILED: Plugin tables could not be deleted'));
Expand Down

0 comments on commit 76545b0

Please sign in to comment.