Index: extensions/SocialButtons/maintain.inc.php
===================================================================
--- extensions/SocialButtons/maintain.inc.php	(revision 24757)
+++ extensions/SocialButtons/maintain.inc.php	(revision 26100)
@@ -2,31 +2,149 @@
 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
 
-defined('SOCIALBUTT_ID') or define('SOCIALBUTT_ID', basename(dirname(__FILE__)));
-include_once(PHPWG_PLUGINS_PATH . SOCIALBUTT_ID . '/include/install.inc.php');
+class SocialButtons_maintain extends PluginMaintain
+{
+  private $installed = false;
+  
+  private $default_config = array(
+    'position' => 'toolbar',
+    'on_index' => true,
+    'img_size' => 'Original',
+    'light' => false,
+    'twitter' => array(
+      'enabled' => true,
+      'size' => 'small',
+      'count' => 'bubble',
+      'via' => null,
+      ),
+    'google' => array(
+      'enabled' => true,
+      'size' => 'medium',
+      'annotation' => 'bubble',
+      ),
+    'tumblr' => array(
+      'enabled' => true,
+      'type' => 'share_1',
+      ),
+    'facebook' => array(
+      'enabled' => true,
+      'color' => 'light',
+      'layout' => 'button_count',
+      ),
+    'pinterest' => array(
+      'enabled' => true,
+      'layout' => 'horizontal',
+      ),
+    'reddit' => array(
+      'enabled' => true,
+      'type' => 'interactive',
+      'community' => null,
+      ),
+    'linkedin' => array(
+      'enabled' => true,
+      'counter' => 'right',
+      ),
+    );
 
+  function install($plugin_version, &$errors=array())
+  {
+    if (empty($conf['SocialButtons']))
+    {
+      if (isset($conf['TumblrShare']))
+      {
+        $temp = is_string($conf['TumblrShare']) ? unserialize($conf['TumblrShare']) : $conf['TumblrShare'];
+        if (!empty($temp['type']))      $this->default_config['tumblr']['type'] = $temp['type'];
+        if (!empty($temp['img_size']))  $this->default_config['img_size'] =       $temp['img_size'];
+      }
+      if (isset($conf['TweetThis']))
+      {
+        $temp = is_string($conf['TweetThis']) ? unserialize($conf['TweetThis']) : $conf['TweetThis'];
+        if (!empty($temp['type']))  $this->default_config['twitter']['size'] =  $temp['size'];
+        if (!empty($temp['count'])) $this->default_config['twitter']['count'] = $temp['count'] ? 'bubble' : 'none';
+        if (!empty($temp['via']))   $this->default_config['twitter']['via'] =   $temp['via'];
+      }
+      if (isset($conf['GooglePlusOne']))
+      {
+        $temp = is_string($conf['GooglePlusOne']) ? unserialize($conf['GooglePlusOne']) : $conf['GooglePlusOne'];
+        if (!empty($temp['size']))        $this->default_config['google']['size'] =       $temp['size'];
+        if (!empty($temp['annotation']))  $this->default_config['google']['annotation'] = $temp['annotation'];
+      }
+      
+      $conf['SocialButtons'] = serialize($this->default_config);
+      conf_update_param('SocialButtons', $conf['SocialButtons']);
+    }
+    else
+    {
+      $new_conf = is_string($conf['SocialButtons']) ? unserialize($conf['SocialButtons']) : $conf['SocialButtons'];
+      
+      if (empty($new_conf['pinterest']))
+      {
+        $new_conf['pinterest'] = array(
+          'enabled' => true,
+          'layout' => 'horizontal',
+          );
+      }
+      
+      if (empty($new_conf['reddit']))
+      {
+        $new_conf['reddit'] = array(
+          'enabled' => false,
+          'type' => 'interactive',
+          'community' => null,
+          );
+      }
+      
+      if (empty($new_conf['linkedin']))
+      {
+        $new_conf['linkedin'] = array(
+          'enabled' => false,
+          'counter' => 'right',
+          );
+      }
+      
+      if (!isset($new_conf['on_index']))
+      {
+        $new_conf['on_index'] = true;
+      }
+      
+      if ($new_conf['facebook']['layout'] == 'none')
+      {
+        $new_conf['facebook']['layout'] = 'button_count';
+      }
+      
+      if (!isset($new_conf['light']))
+      {
+        $new_conf['light'] = false;
+      }
+      
+      if (!isset($new_conf['img_size']))
+      {
+        $new_conf['img_size'] = isset($new_conf['tumblr']['img_size']) ? $new_conf['tumblr']['img_size'] : 'Original';
+        unset($new_conf['tumblr']['img_size'], $new_conf['pinterest']['img_size']);
+      }
+      
+      $conf['SocialButtons'] = serialize($new_conf);
+      conf_update_param('SocialButtons', $conf['SocialButtons']);
+    }
 
-function plugin_install() 
-{
-  socialbutt_install();
-  define('socialbutt_installed', true);
-}
+    $this->installed = true;
+  }
 
+  function activate($plugin_version, &$errors=array())
+  {
+    if (!$this->installed)
+    {
+      $this->install($plugin_version, $errors);
+    }
+  }
 
-function plugin_activate()
-{
-  if (!defined('socialbutt_installed'))
+  function deactivate()
   {
-    socialbutt_install();
+  }
+
+  function uninstall()
+  {
+    conf_delete_param('SocialButtons');
   }
 }
 
-
-function plugin_uninstall() 
-{
-  global $conf;
-  
-  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "SocialButtons";');
-  unset($conf['SocialButtons']);
-}
-
 ?>
