[31051] | 1 | <?php |
---|
| 2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | class sharethis_maintain extends PluginMaintain { |
---|
[31136] | 5 | |
---|
[31051] | 6 | private $default_conf = array( |
---|
| 7 | 'facebook' => false, |
---|
| 8 | 'pinterest' => false, |
---|
| 9 | 'twitter' => false, |
---|
[31136] | 10 | 'googleplus' => false, |
---|
| 11 | 'tumblr' => false |
---|
[31051] | 12 | ); |
---|
| 13 | |
---|
| 14 | function __construct($plugin_id) { |
---|
| 15 | parent::__construct($plugin_id); // always call parent constructor |
---|
| 16 | } |
---|
| 17 | |
---|
[31136] | 18 | /**** Plugin installation */ |
---|
[31051] | 19 | function install($plugin_version, &$errors=array()) { |
---|
| 20 | global $conf; |
---|
| 21 | |
---|
| 22 | // add config parameter |
---|
| 23 | if (empty($conf['sharethis'])): |
---|
| 24 | conf_update_param('sharethis', $this->default_conf, true); |
---|
| 25 | else: |
---|
| 26 | $old_conf = safe_unserialize($conf['sharethis']); |
---|
| 27 | |
---|
[31136] | 28 | foreach ($this->default_conf as $key => $value): |
---|
| 29 | if (array_key_exists($key, $old_conf)): |
---|
| 30 | else: |
---|
| 31 | $old_conf[$key] = $value; |
---|
| 32 | endif; |
---|
| 33 | endforeach; |
---|
[31051] | 34 | |
---|
| 35 | conf_update_param('sharethis', $old_conf, true); |
---|
| 36 | endif; |
---|
| 37 | } |
---|
| 38 | |
---|
[31136] | 39 | /**** Plugin activation */ |
---|
| 40 | function activate($plugin_version, &$errors=array()) { } |
---|
[31051] | 41 | |
---|
[31136] | 42 | /**** Plugin deactivation */ |
---|
| 43 | function deactivate() { } |
---|
[31051] | 44 | |
---|
[31136] | 45 | /**** Plugin (auto)update */ |
---|
[31051] | 46 | function update($old_version, $new_version, &$errors=array()) { |
---|
| 47 | $this->install($new_version, $errors); |
---|
| 48 | } |
---|
| 49 | |
---|
[31136] | 50 | /**** Plugin uninstallation */ |
---|
[31051] | 51 | function uninstall() { |
---|
| 52 | // delete configuration |
---|
| 53 | conf_delete_param('sharethis'); |
---|
| 54 | } |
---|
| 55 | } |
---|