From c8764a2ceb5c8eedce1ae89ae2ef437e820d91a7 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 17 Jan 2014 18:34:33 -0600 Subject: [PATCH] Allow error to be set in plugin uninstall If a plugin refuses to be uninstalled, allow it to set an error to be displayed on the management page. --- include/class.plugin.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/class.plugin.php b/include/class.plugin.php index 29dddf0f9..a9ed46ffd 100644 --- a/include/class.plugin.php +++ b/include/class.plugin.php @@ -329,16 +329,18 @@ class Plugin { * configuration for the plugin is also removed. If the plugin is * reinstalled, it will have to be reconfigured. */ - function uninstall() { - if ($this->pre_uninstall() === false) + function uninstall(&$errors) { + if ($this->pre_uninstall($errors) === false) return false; $sql = 'DELETE FROM '.PLUGIN_TABLE .' WHERE id='.db_input($this->getId()); PluginManager::clearCache(); - if (db_query($sql) && db_affected_rows()) - return $this->getConfig()->purge(); - return false; + if (!db_query($sql) || !db_affected_rows()) + return false; + + $this->getConfig()->purge(); + return true; } /** @@ -346,9 +348,8 @@ class Plugin { * * Hook function to veto the uninstallation request. Return boolean * FALSE if the uninstall operation should be aborted. - * TODO: Recommend a location to stash an error message if aborting */ - function pre_uninstall() { + function pre_uninstall(&$errors) { return true; } -- GitLab