Index: /extensions/UserStat/main.inc.php
===================================================================
--- /extensions/UserStat/main.inc.php	(revision 10343)
+++ /extensions/UserStat/main.inc.php	(revision 10344)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: UserStat
-Version: 1.1.1
+Version: 1.2.0
 Description: Statistiques utilisateurs / Users statistics
 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=321
@@ -33,6 +33,6 @@
 |         |            |   . it_IT
 |         |            |
-|         |            |
-|         |            |
+| 1.2.0   | 201012     | * mantis feature:2263
+|         |            |   . compatibility with Piwigo 2.2
 |         |            |
 |         |            |
Index: /extensions/UserStat/maintain.inc.php
===================================================================
--- /extensions/UserStat/maintain.inc.php	(revision 10343)
+++ /extensions/UserStat/maintain.inc.php	(revision 10344)
@@ -16,25 +16,22 @@
 include_once('userstat_version.inc.php'); // => Don't forget to update this file !!
 
-if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+defined('USERSTAT_DIR') || define('USERSTAT_DIR' , basename(dirname(__FILE__)));
+defined('USERSTAT_PATH') || define('USERSTAT_PATH' , PHPWG_PLUGINS_PATH . USERSTAT_DIR . '/');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
 
-if(!defined('USERSTAT_DIR')) define('USERSTAT_DIR' , basename(dirname(__FILE__)));
-if(!defined('USERSTAT_PATH')) define('USERSTAT_PATH' , PHPWG_PLUGINS_PATH . USERSTAT_DIR . '/');
-
-
-global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
+global $gpcInstalled, $lang; //needed for plugin manager compatibility
 
 /* -----------------------------------------------------------------------------
-UserStat needs the Grum Plugin Classe
------------------------------------------------------------------------------ */
-$gpc_installed=false;
-$gpcNeeded="3.0.0";
+ * UserStat needs the Grum Plugin Classes
+ * -------------------------------------------------------------------------- */
+$gpcInstalled=false;
 if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
 {
   @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
-  // need GPC release greater or equal than 3.0.0
-  if(CommonPlugin::checkGPCRelease(3,0,0))
+  // need GPC release greater or equal than USERSTAT_GPC_NEEDED
+  if(CommonPlugin::checkGPCRelease(USERSTAT_GPC_NEEDED))
   {
-    @include_once("userstat_aim.class.inc.php");
-    $gpc_installed=true;
+    @include_once("userstat_install.class.inc.php");
+    $gpcInstalled=true;
   }
 }
@@ -42,6 +39,5 @@
 function gpcMsgError(&$errors)
 {
-  global $gpcNeeded;
-  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
+  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), USERSTAT_GPC_NEEDED);
   if(is_array($errors))
   {
@@ -56,17 +52,14 @@
 
 
+
 load_language('plugin.lang', USERSTAT_PATH);
 
 function plugin_install($plugin_id, $plugin_version, &$errors)
 {
-  global $prefixeTable, $gpc_installed, $gpcNeeded;
-  if($gpc_installed)
+  global $prefixeTable, $gpcInstalled;
+  if($gpcInstalled)
   {
-    $obj = new UserStat_AIM($prefixeTable, __FILE__);
-    $obj->deleteConfig();
-    $obj->initConfig();
-    $obj->my_config['installed']=USERSTAT_VERSION2;
-    $obj->saveConfig();
-    GPCCore::register($obj->getPluginName(), USERSTAT_VERSION, $gpcNeeded);
+    $obj=new UserStat_install($prefixeTable, __FILE__);
+    $result=$obj->install();
   }
   else
@@ -78,16 +71,9 @@
 function plugin_activate($plugin_id, $plugin_version, &$errors)
 {
-  global $prefixeTable, $gpc_installed, $gpcNeeded;
-  if($gpc_installed)
+  global $prefixeTable, $gpcInstalled;
+  if($gpcInstalled)
   {
-    $obj = new UserStat_AIM($prefixeTable, __FILE__);
-    $obj->initConfig();
-    $obj->loadConfig();
-    $obj->my_config['installed']=USERSTAT_VERSION2;
-    $obj->saveConfig();
-  }
-  else
-  {
-    gpcMsgError($errors);
+    $obj=new UserStat_install($prefixeTable, __FILE__);
+    $result=$obj->activate();
   }
 }
@@ -95,14 +81,20 @@
 function plugin_deactivate($plugin_id)
 {
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
+  {
+    $obj=new UserStat_install($prefixeTable, __FILE__);
+    $obj->deactivate();
+  }
 }
 
 function plugin_uninstall($plugin_id)
 {
-  global $prefixeTable, $gpc_installed;
-  if($gpc_installed)
+  global $prefixeTable, $gpcInstalled;
+  if($gpcInstalled)
   {
-    $obj = new UserStat_AIM($prefixeTable, __FILE__);
-    $obj->deleteConfig();
-    GPCCore::unregister($obj->getPluginName());
+    $obj=new UserStat_install($prefixeTable, __FILE__);
+    $result=$obj->uninstall();
   }
   else
@@ -113,4 +105,3 @@
 
 
-
 ?>
Index: /extensions/UserStat/userstat.css
===================================================================
--- /extensions/UserStat/userstat.css	(revision 10343)
+++ /extensions/UserStat/userstat.css	(revision 10344)
@@ -1,4 +1,4 @@
 
-.StatTableRow:hover { background-color:#303030; }
+.StatTableRow:hover { background-color:#303030; cursor:pointer; }
 .formtable, .formtable P { text-align:left; display:block; }
 .formtable tr { vertical-align:top; }
@@ -11,3 +11,2 @@
 div.table { margin-bottom:15px; }
 pointerHand { cursor:pointer; }
-    
Index: /extensions/UserStat/userstat_aim.class.inc.php
===================================================================
--- /extensions/UserStat/userstat_aim.class.inc.php	(revision 10343)
+++ /extensions/UserStat/userstat_aim.class.inc.php	(revision 10344)
@@ -16,23 +16,12 @@
 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
 
-include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
+include_once('userstat_root.class.inc.php');
 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
 
-class UserStat_AIM extends CommonPlugin
+class UserStat_AIM extends UserStat_root
 {
-  protected $css = null;
-
-  public function __construct($prefixeTable, $filelocation)
+  function __construct($prefixeTable, $filelocation)
   {
-    $this->setPluginName("UserStat");
-    $this->setPluginNameFiles("userstat");
     parent::__construct($prefixeTable, $filelocation);
-    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
-  }
-
-  public function __destruct()
-  {
-    unset($this->css);
-    parent::__destruct();
   }
 
@@ -42,87 +31,7 @@
   function initEvents()
   {
+    parent::initEvents();
     add_event_handler('get_admin_plugin_menu_links', array(&$this, 'pluginAdminMenu') );
   }
-
-
-  /*
-    initialization of config properties
-  */
-  function initConfig()
-  {
-    $this->config=array(
-      'UserStat_MouseOverColor' => '303030',
-      /*'AStat_BarColor_Pages' => '6666ff',
-      'AStat_BarColor_Img' => '66ff66',
-      'AStat_BarColor_IP' => 'ff6666',
-      'AStat_NpIPPerPages' => '25',
-      'AStat_NpCatPerPages' => '50',
-      'AStat_MaxBarWidth' => '400',
-      'AStat_default_period' => 'global', //global, all, year, month, day
-      'AStat_ShowThumbCat' => 'true',
-      'AStat_DefaultSortCat' => 'page', //page, picture, nbpicture
-      'AStat_ShowThumbImg' => 'true',
-      'AStat_DefaultSortImg' => 'picture',  //picture, catname
-      'AStat_NbImgPerPages' => '100',
-      'AStat_BarColor_Cat' => 'fff966',
-      'AStat_DefaultSortIP' => 'page',    //page, ip, picture
-      'AStat_SeeTimeRequests' => 'false',
-      'AStat_BlackListedIP' => '',    // ip blacklisted (separator : ",")
-      'AStat_UseBlackList' => 'false'    // if false, blacklist usage is disabled, if "invert" then result are inverted*/
-      );
-
-  }
-
-  /*
-    surchage of CommonPlugin->saveConfig function
-  */
-  function loadConfig()
-  {
-    parent::loadConfig();
-    if(!$this->css->fileExists())
-    {
-      $this->css->makeCSS($this->generate_CSS());
-    }
-  }
-
-  /*
-    surchage of CommonPlugin->saveConfig function
-  */
-  function saveConfig()
-  {
-    if(parent::saveConfig())
-    {
-      $this->css->makeCSS($this->generate_CSS());
-      return(true);
-    }
-    return(false);
-  }
-
-  /*
-    generate the css code
-  */
-  function generate_CSS()
-  {
-    $text = "
-.StatTableRow:hover { background-color:#".$this->config['UserStat_MouseOverColor']."; }
-.formtable, .formtable P { text-align:left; display:block; }
-.formtable tr { vertical-align:top; }
-.invisible { visibility:hidden; display:none; }
-.littlefont { font-size:90%; }
-table.table2.littlefont td { text-align:center;padding:0px;padding-left:3px;padding-right:3px; }
-.throw { line-height:auto; font-size:100%; }
-table.table2 tr.throw { height:26px; }
-table.table2 td.toLeft  { text-align:left; }
-div.table { margin-bottom:15px; }
-pointerHand { cursor:pointer; }
-    ";
-
-    return($text);
-  }
-
-  /* ---------------------------------------------------------------------------
-  Function needed for plugin activation
-  --------------------------------------------------------------------------- */
-
 
 
Index: /extensions/UserStat/userstat_aip.class.inc.php
===================================================================
--- /extensions/UserStat/userstat_aip.class.inc.php	(revision 10343)
+++ /extensions/UserStat/userstat_aip.class.inc.php	(revision 10344)
@@ -15,9 +15,9 @@
 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
 
-include_once('userstat_aim.class.inc.php');
+include_once('userstat_root.class.inc.php');
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
 
-class UserStat_AIP extends UserStat_AIM
+class UserStat_AIP extends UserStat_root
 {
   protected $tabsheet;
Index: /extensions/UserStat/userstat_install.class.inc.php
===================================================================
--- /extensions/UserStat/userstat_install.class.inc.php	(revision 10344)
+++ /extensions/UserStat/userstat_install.class.inc.php	(revision 10344)
@@ -0,0 +1,71 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : UserStat
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  --------------------------------------------------------------------------- */
+  include_once('userstat_version.inc.php');
+  include_once('userstat_root.class.inc.php');
+
+  class UserStat_install extends UserStat_root
+  {
+    public function __construct($prefixeTable, $filelocation)
+    {
+      parent::__construct($prefixeTable, $filelocation);
+    }
+
+    /**
+     * function for installation process
+     *
+     * @return Bool : true if install process is ok, otherwise false
+     */
+    public function install()
+    {
+      $this->initConfig();
+      $this->loadConfig();
+      $this->config['installed']=USERSTAT_VERSION2;
+      $this->config['newInstall']='y';
+      $this->saveConfig();
+
+      GPCCore::register($this->getPluginName(), USERSTAT_VERSION, USERSTAT_GPC_NEEDED);
+
+      return(true);
+    }
+
+
+    /**
+     * function for uninstall process
+     */
+    public function uninstall()
+    {
+      $this->deleteConfig();
+      GPCCore::unregister($this->getPluginName());
+    }
+
+    public function activate()
+    {
+      global $template;
+
+      $this->initConfig();
+      $this->loadConfig();
+
+      $this->config['newInstall']='n';
+      $this->config['installed']=AMM_VERSION2; //update the installed release number
+      $this->saveConfig();
+
+      GPCCore::register($this->getPluginName(), AMM_VERSION, AMM_GPC_NEEDED);
+    }
+
+    public function deactivate()
+    {
+    }
+
+  } //class
+
+?>
Index: /extensions/UserStat/userstat_root.class.inc.php
===================================================================
--- /extensions/UserStat/userstat_root.class.inc.php	(revision 10344)
+++ /extensions/UserStat/userstat_root.class.inc.php	(revision 10344)
@@ -0,0 +1,62 @@
+<?php
+/*
+ * -----------------------------------------------------------------------------
+ * Plugin Name: UserStat
+ * -----------------------------------------------------------------------------
+ * Author     : Grum
+ *   email    : grum@piwigo.org
+ *   website  : http://photos.grum.fr
+ *   PWG user : http://forum.piwigo.org/profile.php?id=3706
+ *
+ *   << May the Little SpaceFrog be with you ! >>
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * See main.inc.php for release information
+ *
+ * UserStat_install : classe to manage plugin install
+ * ---------------------------------------------------------------------------
+ */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
+
+class UserStat_root extends CommonPlugin
+{
+  protected $css;   //the css object
+
+  public function __construct($prefixeTable, $filelocation)
+  {
+    $this->setPluginName("UserStat");
+    $this->setPluginNameFiles("userstat");
+    parent::__construct($prefixeTable, $filelocation);
+    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
+  }
+
+  public function __destruct()
+  {
+    unset($this->css);
+    parent::__destruct();
+  }
+
+  /* ---------------------------------------------------------------------------
+  common AIP & PIP functions
+  --------------------------------------------------------------------------- */
+
+  /* this function initialize var $config with default values */
+  /*
+    initialization of config properties
+  */
+  function initConfig()
+  {
+    $this->config=array(
+    );
+  }
+
+}
+
+
+
+?>
Index: /extensions/UserStat/userstat_version.inc.php
===================================================================
--- /extensions/UserStat/userstat_version.inc.php	(revision 10343)
+++ /extensions/UserStat/userstat_version.inc.php	(revision 10344)
@@ -15,5 +15,6 @@
   if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-  define('USERSTAT_VERSION',  '1.1.1');
-  define('USERSTAT_VERSION2', '01.01.01');
+  define('USERSTAT_VERSION',  '1.2.0');
+  define('USERSTAT_VERSION2', '01.02.00');
+  define('USERSTAT_GPC_NEEDED', '3.5.0');
 ?>
