Ignore:
Timestamp:
Apr 1, 2010, 9:06:01 PM (11 years ago)
Author:
grum
Message:

Update the plugin for compatibility with Piwigo 2.1

File:
1 edited

Legend:

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

    r5433 r5549  
    1414//ini_set('display_errors', true);
    1515
     16include_once('userstat_version.inc.php'); // => Don't forget to update this file !!
     17
    1618if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1719
     
    2022
    2123
    22 global $gpc_installed, $lang; //needed for plugin manager compatibility
     24global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
    2325
    2426/* -----------------------------------------------------------------------------
     
    2628----------------------------------------------------------------------------- */
    2729$gpc_installed=false;
    28 if(file_exists(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php'))
     30$gpcNeeded="3.0.0";
     31if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
    2932{
    30   @include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/main.inc.php');
    31   // need GPC release greater or equal than 2.0.5
    32   if(checkGPCRelease(2,0,5))
     33  @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))
    3336  {
    3437    @include_once("userstat_aim.class.inc.php");
     
    3942function gpcMsgError(&$errors)
    4043{
    41   array_push($errors, sprintf(l10n('us_gpc2_not_installed'), "2.0.5"));
     44  global $gpcNeeded;
     45  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
     46  if(is_array($errors))
     47  {
     48    array_push($errors, $msg);
     49  }
     50  else
     51  {
     52    $errors=Array($msg);
     53  }
    4254}
    4355// -----------------------------------------------------------------------------
     
    4860function plugin_install($plugin_id, $plugin_version, &$errors)
    4961{
    50   global $prefixeTable, $gpc_installed;
     62  global $prefixeTable, $gpc_installed, $gpcNeeded;
    5163  if($gpc_installed)
    5264  {
    5365    $obj = new UserStat_AIM($prefixeTable, __FILE__);
    54     $obj->delete_config();
    55     $obj->init_config();
    56     $obj->save_config();
     66    $obj->deleteConfig();
     67    $obj->initConfig();
     68    $obj->my_config['installed']=USERSTAT_VERSION2;
     69    $obj->saveConfig();
     70    GPCCore::register($obj->getPluginName(), USERSTAT_VERSION, $gpcNeeded);
    5771  }
    5872  else
     
    6478function plugin_activate($plugin_id, $plugin_version, &$errors)
    6579{
    66   global $prefixeTable, $gpc_installed;
     80  global $prefixeTable, $gpc_installed, $gpcNeeded;
    6781  if($gpc_installed)
    6882  {
    6983    $obj = new UserStat_AIM($prefixeTable, __FILE__);
    70     $obj->init_config();
    71     $obj->load_config();
    72     $obj->save_config();
     84    $obj->initConfig();
     85    $obj->loadConfig();
     86    $obj->my_config['installed']=USERSTAT_VERSION2;
     87    $obj->saveConfig();
    7388  }
    7489  else
     
    88103  {
    89104    $obj = new UserStat_AIM($prefixeTable, __FILE__);
    90     $obj->delete_config();
     105    $obj->deleteConfig();
     106    GPCCore::unregister($obj->getPluginName());
    91107  }
    92108  else
Note: See TracChangeset for help on using the changeset viewer.