diff options
author | Andrew Dolgov <[email protected]> | 2012-12-27 19:20:12 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-12-27 19:20:36 +0400 |
commit | 5d9abb1e11262b5ef7c6f4695590ce5bdb257b85 (patch) | |
tree | b87b628efa00e479eb37a635827b802a61a26746 /classes/pluginhost.php | |
parent | d8a1d2a25b2247e5a63f5b0ab7f0bd9423a217e5 (diff) |
add plugin storage table to schema; add ability to clear plugin data
Diffstat (limited to 'classes/pluginhost.php')
-rw-r--r-- | classes/pluginhost.php | 24 |
1 files changed, 16 insertions, 8 deletions
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 @@ <?php -/* create table ttrss_plugin_storage - (id serial not null primary key, name varchar(100) not null, - owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, - content text not null) - not in schema yet -*/ class PluginHost { private $link; private $hooks = array(); @@ -81,9 +76,9 @@ class PluginHost { return array(); } } - function load_all($kind) { + function load_all($kind, $owner_uid = false) { $plugins = array_map("basename", glob("plugins/*")); - $this->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; + } + } } ?> |