Changeset 6976


Ignore:
Timestamp:
09/20/10 00:43:52 (9 years ago)
Author:
grum
Message:

Migration from version 1.0.1 to 1.0.2 implemented

Location:
extensions/ColorStat
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/ColorStat/admin/plugin_admin.php

    r5961 r6976  
    1414if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } 
    1515 
    16 global $prefixeTable; 
     16global $prefixeTable, $template; 
    1717load_language('plugin.lang', CSTAT_PATH); 
    1818 
    1919$main_plugin_object = get_plugin_data($plugin_id); 
    2020 
    21 /* 
    22  * if the plugin is newly installed, display a special configuration page 
    23  * otherwise, display normal page 
    24  */ 
    2521 
    26 $config=Array(); 
    27 GPCCore::loadConfig('cstat', $config); 
     22if(CommonPlugin::checkGPCRelease(3,2,0)) 
     23{ 
     24  $config=Array(); 
     25  GPCCore::loadConfig('cstat', $config); 
    2826 
    29 if($config['newInstall']=='n') 
    30 { 
    31   include(CSTAT_PATH."cstat_aip.class.inc.php"); 
    32   $plugin_aip = new CStat_AIP($prefixeTable, $main_plugin_object->getFileLocation()); 
     27  if(!isset($config['installed'])) $config['installed']='01.00.01'; 
     28  if($config['installed']!=CSTAT_VERSION2) 
     29  { 
     30    /* the plugin was updated without being deactivated 
     31     * deactivate + activate the plugin to process the database upgrade 
     32     */ 
     33    include(CSTAT_PATH."cstat_install.class.inc.php"); 
     34    $cstat=new CStat_Install($prefixeTable, dirname(__FILE__)); 
     35    $cstat->deactivate(); 
     36    $cstat->activate(); 
     37    $template->delete_compiled_templates(); 
     38    $config['newInstall']='n'; 
     39  } 
     40 
     41  /* 
     42   * if the plugin is newly installed, display a special configuration page 
     43   * otherwise, display normal page 
     44   */ 
     45  if($config['newInstall']=='n') 
     46  { 
     47    include(CSTAT_PATH."cstat_aip.class.inc.php"); 
     48    $plugin_ai = new CStat_AIP($prefixeTable, $main_plugin_object->getFileLocation()); 
     49  } 
     50  else 
     51  { 
     52    include(CSTAT_PATH."cstat_aip_install.class.inc.php"); 
     53    $plugin_ai = new CStat_AIPInstall($prefixeTable, $main_plugin_object->getFileLocation()); 
     54  } 
    3355} 
    3456else 
    3557{ 
    36   include(CSTAT_PATH."cstat_aip_install.class.inc.php"); 
    37   $plugin_aip = new CStat_AIPInstall($prefixeTable, $main_plugin_object->getFileLocation()); 
     58  /* 
     59   * plugin was upgraded, but GPC was not 
     60   * display a page to inform user to upgrade GPC 
     61   */ 
     62  include(CSTAT_PATH."cstat_aip_release.class.inc.php"); 
     63  $plugin_ai = new CStat_AIPRelease($prefixeTable, $main_plugin_object->getFileLocation()); 
    3864} 
    3965 
    40 $plugin_aip->manage(); 
     66$plugin_ai->manage(); 
     67 
     68 
     69 
    4170?> 
  • extensions/ColorStat/cstat_install.class.inc.php

    r6176 r6976  
    9090 
    9191      $result=$this->tablef->create($tables_def); 
     92 
     93      GPCCore::register($this->getPluginName(), CSTAT_VERSION, CSTAT_GPC_NEEDED); 
     94 
    9295      return($result); 
    9396    } 
     
    99102    public function uninstall() 
    100103    { 
     104      GPCCore::unregister($this->getPluginName()); 
     105 
    101106      $this->deleteConfig(); 
    102107      $this->tablef->drop(); 
     
    109114 
    110115      $this->initConfig(); 
    111       //$this->loadConfig(); //don't keep the previous config : we need to start with default values 
     116      $this->loadConfig(); 
    112117      $this->config['installed']=CSTAT_VERSION2; 
    113       $this->config['newInstall']='y'; 
    114118      $this->saveConfig(); 
    115  
     119/* 
    116120      pwg_query("DELETE FROM ".$this->tables['color_table']); 
    117121      pwg_query("DELETE FROM ".$this->tables['images_colors']); 
     
    128132                    FROM ".IMAGES_TABLE." 
    129133                    WHERE id NOT IN (SELECT image_id FROM ".$this->tables['images'].")"); 
     134*/ 
     135      GPCCore::register($this->getPluginName(), CSTAT_VERSION, CSTAT_GPC_NEEDED); 
     136      GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/cstat_rb_callback.class.inc.php'); 
    130137 
    131138      return(''); 
     
    134141    public function deactivate() 
    135142    { 
     143      GPCRequestBuilder::unregister($this->getPluginName()); 
    136144    } 
    137145 
  • extensions/ColorStat/cstat_version.inc.php

    r6893 r6976  
    1717  define('CSTAT_VERSION',  '1.0.2'); 
    1818  define('CSTAT_VERSION2', '01.00.02'); 
     19  define('CSTAT_GPC_NEEDED', '3.2.0'); 
    1920?> 
  • extensions/ColorStat/language/en_UK/plugin.lang.php

    r6210 r6976  
    108108$lang['cstat_colors_on_image']='Colors associated with the image'; 
    109109 
     110// new keys from release 1.0.2 
     111$lang['cstat_gpc_not_up_to_date']="Version %s of plugin <i>Grum Plugin Classes</i> is required. 
     112Actually, the version %s is installed : thanks to upgrade the <i>Grum Plugin Classes plugin</i>."; 
     113 
     114 
    110115?> 
  • extensions/ColorStat/language/fr_FR/plugin.lang.php

    r6210 r6976  
    111111$lang['cstat_colors_on_image']='Couleurs associées à l\'image'; 
    112112 
     113// new keys from release 1.0.2 
     114$lang['cstat_gpc_not_up_to_date']="Il est nécessaire que le plugin <i>Grum Plugin Classes</i> version %s soit installé. 
     115Actuellement, la version %s est installée : merci de procéder à la mise à jour de version du plugin <i>Grum Plugin Classes</i>."; 
     116 
     117 
    113118?> 
  • extensions/ColorStat/maintain.inc.php

    r6893 r6976  
    2020//ini_set('display_errors', true); 
    2121 
    22 global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility 
     22global $gpcInstalled, $lang; //needed for plugin manager compatibility 
    2323 
    24 /* ----------------------------------------------------------------------------- 
    25 ColorStat needs the Grum Plugin Classe 
    26 ----------------------------------------------------------------------------- */ 
    27 $gpc_installed=false; 
    28 $gpcNeeded="3.2.0"; 
     24/* 
     25 * ----------------------------------------------------------------------------- 
     26 * ColorStat needs the Grum Plugin Classes 
     27 * ----------------------------------------------------------------------------- 
     28 */ 
     29$gpcInstalled=false; 
    2930if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php')) 
    3031{ 
     
    3435  { 
    3536    include_once('cstat_install.class.inc.php'); 
    36     $gpc_installed=true; 
     37    $gpcInstalled=true; 
    3738  } 
    3839} 
     
    4041function gpcMsgError(&$errors) 
    4142{ 
    42   global $gpcNeeded; 
    43   $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded); 
     43  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), CSTAT_GPC_NEEDED); 
    4444  if(is_array($errors)) 
    4545  { 
     
    6161function plugin_install($plugin_id, $plugin_version, &$errors) 
    6262{ 
    63   global $prefixeTable, $gpc_installed, $gpcNeeded; 
     63  global $prefixeTable, $gpcInstalled; 
    6464 
    65   if($gpc_installed) 
     65  if($gpcInstalled) 
    6666  { 
    67     $obj = new CStat_Install($prefixeTable, __FILE__); 
    68     $result=$obj->install(); 
    69     if(!$result) 
     67    $cstat = new CStat_Install($prefixeTable, __FILE__); 
     68    if(!$cstat->install()) 
    7069    { 
    7170      array_push($errors, "error"); 
    7271    } 
    73     GPCCore::register($obj->getPluginName(), CSTAT_VERSION, $gpcNeeded); 
    74     GPCRequestBuilder::register($obj->getPluginName(), dirname($obj->getFileLocation()).'/cstat_rb_callback.class.inc.php'); 
    7572  } 
    7673  else 
     
    8279function plugin_activate($plugin_id, $plugin_version, &$errors) 
    8380{ 
    84   global $prefixeTable, $gpc_installed; 
     81  global $prefixeTable, $gpcInstalled; 
    8582 
    86   if($gpc_installed) 
     83  if($gpcInstalled) 
    8784  { 
    88     $obj = new CStat_Install($prefixeTable, __FILE__); 
    89     $result=$obj->activate(); 
     85    $cstat = new CStat_Install($prefixeTable, __FILE__); 
     86    $result=$cstat->activate(); 
    9087    if($result===false or $result!='') 
    9188    { 
     
    108105function plugin_deactivate($plugin_id) 
    109106{ 
     107  global $prefixeTable, $gpcInstalled; 
     108 
     109  if($gpcInstalled) 
     110  { 
     111    $cstat = new CStat_Install($prefixeTable, __FILE__); 
     112    $cstat->deactivate(); 
     113  } 
    110114} 
    111115 
    112116function plugin_uninstall($plugin_id) 
    113117{ 
    114   global $prefixeTable, $gpc_installed; 
     118  global $prefixeTable, $gpcInstalled; 
    115119 
    116   if($gpc_installed) 
     120  if($gpcInstalled) 
    117121  { 
    118     $obj = new CStat_Install($prefixeTable, __FILE__); 
    119     $obj->uninstall(); 
    120     GPCRequestBuilder::unregister($obj->getPluginName()); 
    121     GPCCore::unregister($obj->getPluginName()); 
     122    $cstat = new CStat_Install($prefixeTable, __FILE__); 
     123    $cstat->uninstall(); 
    122124  } 
    123125  else 
Note: See TracChangeset for help on using the changeset viewer.