@@ -27,49 +27,49 @@ |
||
| 27 | 27 | |
| 28 | 28 | class SettingsInstaller extends PluginInstaller_Plugin { |
| 29 | 29 | |
| 30 | - public function install(Plugin $plugin, array $install_json): bool { |
|
| 31 | - if (isset($install_json['set-settings'])) { |
|
| 32 | - $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 30 | + public function install(Plugin $plugin, array $install_json): bool { |
|
| 31 | + if (isset($install_json['set-settings'])) { |
|
| 32 | + $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 33 | 33 | |
| 34 | - foreach ($install_json['set-settings'] as $key=>$value) { |
|
| 35 | - if (Settings::contains($key)) { |
|
| 36 | - //backup old value |
|
| 37 | - $old_value = Settings::get($key); |
|
| 38 | - $prefs->put($key, $old_value); |
|
| 39 | - } else { |
|
| 40 | - $prefs->put($key, null); |
|
| 41 | - } |
|
| 34 | + foreach ($install_json['set-settings'] as $key=>$value) { |
|
| 35 | + if (Settings::contains($key)) { |
|
| 36 | + //backup old value |
|
| 37 | + $old_value = Settings::get($key); |
|
| 38 | + $prefs->put($key, $old_value); |
|
| 39 | + } else { |
|
| 40 | + $prefs->put($key, null); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - //set new value |
|
| 44 | - Settings::set($key, $value); |
|
| 45 | - } |
|
| 43 | + //set new value |
|
| 44 | + Settings::set($key, $value); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $prefs->save(); |
|
| 48 | - } |
|
| 47 | + $prefs->save(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return true; |
|
| 51 | - } |
|
| 50 | + return true; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function uninstall(Plugin $plugin, array $install_json): bool { |
|
| 54 | - //restore old values |
|
| 53 | + public function uninstall(Plugin $plugin, array $install_json): bool { |
|
| 54 | + //restore old values |
|
| 55 | 55 | |
| 56 | - $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 56 | + $prefs = new Preferences("plugin_" . $plugin->getName() . "_uninstall"); |
|
| 57 | 57 | |
| 58 | - foreach ($prefs->listAll() as $key=>$value) { |
|
| 59 | - if ($value != null) { |
|
| 60 | - Settings::set($key, $value); |
|
| 61 | - } |
|
| 62 | - } |
|
| 58 | + foreach ($prefs->listAll() as $key=>$value) { |
|
| 59 | + if ($value != null) { |
|
| 60 | + Settings::set($key, $value); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - //clear preferences |
|
| 65 | - $prefs->clearAll(); |
|
| 64 | + //clear preferences |
|
| 65 | + $prefs->clearAll(); |
|
| 66 | 66 | |
| 67 | - return true; |
|
| 68 | - } |
|
| 67 | + return true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function upgrade(Plugin $plugin, array $install_json): bool { |
|
| 71 | - return $this->install($plugin, $install_json); |
|
| 72 | - } |
|
| 70 | + public function upgrade(Plugin $plugin, array $install_json): bool { |
|
| 71 | + return $this->install($plugin, $install_json); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |