Ignore:
Timestamp:
Apr 12, 2011, 11:46:45 PM (10 years ago)
Author:
grum
Message:

bug:2263
Compatibility with piwigo 2.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserStat/maintain.inc.php

    r5549 r10344  
    1616include_once('userstat_version.inc.php'); // => Don't forget to update this file !!
    1717
    18 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
     18defined('USERSTAT_DIR') || define('USERSTAT_DIR' , basename(dirname(__FILE__)));
     19defined('USERSTAT_PATH') || define('USERSTAT_PATH' , PHPWG_PLUGINS_PATH . USERSTAT_DIR . '/');
     20include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
    1921
    20 if(!defined('USERSTAT_DIR')) define('USERSTAT_DIR' , basename(dirname(__FILE__)));
    21 if(!defined('USERSTAT_PATH')) define('USERSTAT_PATH' , PHPWG_PLUGINS_PATH . USERSTAT_DIR . '/');
    22 
    23 
    24 global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
     22global $gpcInstalled, $lang; //needed for plugin manager compatibility
    2523
    2624/* -----------------------------------------------------------------------------
    27 UserStat needs the Grum Plugin Classe
    28 ----------------------------------------------------------------------------- */
    29 $gpc_installed=false;
    30 $gpcNeeded="3.0.0";
     25 * UserStat needs the Grum Plugin Classes
     26 * -------------------------------------------------------------------------- */
     27$gpcInstalled=false;
    3128if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
    3229{
    3330  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    34   // need GPC release greater or equal than 3.0.0
    35   if(CommonPlugin::checkGPCRelease(3,0,0))
     31  // need GPC release greater or equal than USERSTAT_GPC_NEEDED
     32  if(CommonPlugin::checkGPCRelease(USERSTAT_GPC_NEEDED))
    3633  {
    37     @include_once("userstat_aim.class.inc.php");
    38     $gpc_installed=true;
     34    @include_once("userstat_install.class.inc.php");
     35    $gpcInstalled=true;
    3936  }
    4037}
     
    4239function gpcMsgError(&$errors)
    4340{
    44   global $gpcNeeded;
    45   $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
     41  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), USERSTAT_GPC_NEEDED);
    4642  if(is_array($errors))
    4743  {
     
    5652
    5753
     54
    5855load_language('plugin.lang', USERSTAT_PATH);
    5956
    6057function plugin_install($plugin_id, $plugin_version, &$errors)
    6158{
    62   global $prefixeTable, $gpc_installed, $gpcNeeded;
    63   if($gpc_installed)
     59  global $prefixeTable, $gpcInstalled;
     60  if($gpcInstalled)
    6461  {
    65     $obj = new UserStat_AIM($prefixeTable, __FILE__);
    66     $obj->deleteConfig();
    67     $obj->initConfig();
    68     $obj->my_config['installed']=USERSTAT_VERSION2;
    69     $obj->saveConfig();
    70     GPCCore::register($obj->getPluginName(), USERSTAT_VERSION, $gpcNeeded);
     62    $obj=new UserStat_install($prefixeTable, __FILE__);
     63    $result=$obj->install();
    7164  }
    7265  else
     
    7871function plugin_activate($plugin_id, $plugin_version, &$errors)
    7972{
    80   global $prefixeTable, $gpc_installed, $gpcNeeded;
    81   if($gpc_installed)
     73  global $prefixeTable, $gpcInstalled;
     74  if($gpcInstalled)
    8275  {
    83     $obj = new UserStat_AIM($prefixeTable, __FILE__);
    84     $obj->initConfig();
    85     $obj->loadConfig();
    86     $obj->my_config['installed']=USERSTAT_VERSION2;
    87     $obj->saveConfig();
    88   }
    89   else
    90   {
    91     gpcMsgError($errors);
     76    $obj=new UserStat_install($prefixeTable, __FILE__);
     77    $result=$obj->activate();
    9278  }
    9379}
     
    9581function plugin_deactivate($plugin_id)
    9682{
     83  global $prefixeTable, $gpcInstalled;
     84
     85  if($gpcInstalled)
     86  {
     87    $obj=new UserStat_install($prefixeTable, __FILE__);
     88    $obj->deactivate();
     89  }
    9790}
    9891
    9992function plugin_uninstall($plugin_id)
    10093{
    101   global $prefixeTable, $gpc_installed;
    102   if($gpc_installed)
     94  global $prefixeTable, $gpcInstalled;
     95  if($gpcInstalled)
    10396  {
    104     $obj = new UserStat_AIM($prefixeTable, __FILE__);
    105     $obj->deleteConfig();
    106     GPCCore::unregister($obj->getPluginName());
     97    $obj=new UserStat_install($prefixeTable, __FILE__);
     98    $result=$obj->uninstall();
    10799  }
    108100  else
     
    113105
    114106
    115 
    116107?>
Note: See TracChangeset for help on using the changeset viewer.