From f4d0e7bb6d080b8dc25090b1aa7b21be70c6ec22 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 7 Mar 2021 15:21:31 +0300 Subject: * af_redditimgur: optionally import score * add pluginhost->set_array() to set many plugin settings at once --- classes/pluginhost.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 366e2b2d3..17d1e0c5f 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -469,7 +469,7 @@ class PluginHost { } } - function set(Plugin $sender, string $name, $value, bool $sync = true) { + function set(Plugin $sender, string $name, $value) { $idx = get_class($sender); if (!isset($this->storage[$idx])) @@ -477,7 +477,19 @@ class PluginHost { $this->storage[$idx][$name] = $value; - if ($sync) $this->save_data(get_class($sender)); + $this->save_data(get_class($sender)); + } + + function set_array(Plugin $sender, array $params) { + $idx = get_class($sender); + + if (!isset($this->storage[$idx])) + $this->storage[$idx] = array(); + + foreach ($params as $name => $value) + $this->storage[$idx][$name] = $value; + + $this->save_data(get_class($sender)); } function get(Plugin $sender, string $name, $default_value = false) { -- cgit v1.2.3