From 5d9abb1e11262b5ef7c6f4695590ce5bdb257b85 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 27 Dec 2012 19:20:12 +0400 Subject: add plugin storage table to schema; add ability to clear plugin data --- classes/pluginhost.php | 24 ++++++++++++++++-------- classes/pref/prefs.php | 21 +++++++++++++++++++-- 2 files changed, 35 insertions(+), 10 deletions(-) (limited to 'classes') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index e43b39f9d..d7db7481c 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -1,9 +1,4 @@ load(join(",", $plugins), $kind); + $this->load(join(",", $plugins), $kind, $owner_uid); } function load($classlist, $kind, $owner_uid = false) { @@ -263,7 +258,7 @@ class PluginHost { if ($sync) $this->save_data(get_class($sender)); } - function get($sender, $name, $default_value) { + function get($sender, $name, $default_value = false) { $idx = get_class($sender); if (isset($this->storage[$idx][$name])) { @@ -278,5 +273,18 @@ class PluginHost { return $this->storage[$idx]; } + + function clear_data($sender) { + if ($this->owner_uid) { + $idx = get_class($sender); + + unset($this->storage[$idx]); + + db_query($this->link, "DELETE FROM ttrss_plugin_storage WHERE name = '$idx' + AND owner_uid = " . $this->owner_uid); + + $_SESSION["plugin_storage"] = $this->storage; + } + } } ?> diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 0922e43a8..bb82b355e 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -683,8 +683,9 @@ class Pref_Prefs extends Handler_Protected { $system_enabled = array_map("trim", explode(",", PLUGINS)); $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS"))); - $tmppluginhost = new PluginHost($link); - $tmppluginhost->load_all($tmppluginhost::KIND_ALL); + $tmppluginhost = new PluginHost($this->link); + $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]); + $tmppluginhost->load_data(true); foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); @@ -707,6 +708,11 @@ class Pref_Prefs extends Handler_Protected { print "" . htmlspecialchars(sprintf("%.2f", $about[0])) . ""; print "" . htmlspecialchars($about[2]) . ""; + if (count($tmppluginhost->get_all($plugin)) > 0) { + print "".__("Clear data").""; + } + print ""; } @@ -752,6 +758,10 @@ class Pref_Prefs extends Handler_Protected { print "" . htmlspecialchars(sprintf("%.2f", $about[0])) . ""; print "" . htmlspecialchars($about[2]) . ""; + if (count($tmppluginhost->get_all($plugin)) > 0) { + print "".__("Clear data").""; + } + print ""; @@ -846,5 +856,12 @@ class Pref_Prefs extends Handler_Protected { set_pref($this->link, "_ENABLED_PLUGINS", $plugins); } + + function clearplugindata() { + $name = db_escape_string($_REQUEST["name"]); + + global $pluginhost; + $pluginhost->clear_data($pluginhost->get_plugin($name)); + } } ?> -- cgit v1.2.3-54-g00ecf