source: extensions/GrumPluginClasses/gpc_install.class.inc.php @ 9020

Last change on this file since 9020 was 6975, checked in by grum, 14 years ago

Migration from version 3.1.0 to 3.2.0 implemented

File size: 3.0 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : Grum Plugin Classes - 3
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12
13  GPC_Install : classe to manage plugin install
14
15  --------------------------------------------------------------------------- */
16
17  if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
18
19  include_once('gpc_version.inc.php'); // => Don't forget to update this file !!
20  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
21  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
22  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
23
24  /* PGC class for install process */
25  class GPC_Install extends CommonPlugin
26  {
27    private $tablef;
28
29    public function __construct($prefixeTable, $filelocation)
30    {
31      $this->setPluginName("Grum Plugin Classes");
32      $this->setPluginNameFiles("gpc");
33      parent::__construct($prefixeTable, $filelocation);
34      GPCRequestBuilder::init($prefixeTable, $this->getPluginNameFiles());
35    }
36
37    public function __destruct()
38    {
39      parent::__destruct();
40    }
41
42    /*
43        function for installation process
44        return true if install process is ok, otherwise false
45    */
46    public function install()
47    {
48      $this->initConfig();
49      $this->loadConfig();
50      $this->config['installed']=GPC_VERSION2;
51      $this->saveConfig();
52
53      $result=GPCRequestBuilder::createTables();
54      return($result);
55    }
56
57
58    /*
59        function for uninstall process
60    */
61    public function uninstall()
62    {
63      $registeredPlugin=GPCCore::getRegistered();
64      if(count($registeredPlugin)>0)
65      {
66        return(l10n("Some plugins are dependent on Grum Plugin Classes: before uninstall, you must first uninstall the plugins dependent"));
67      }
68      else
69      {
70        $this->deleteConfig();
71        $result=GPCRequestBuilder::deleteTables();
72        return($result);
73      }
74    }
75
76    public function activate()
77    {
78      global $template, $user;
79
80      $this->initConfig();
81      $this->loadConfig();
82
83      /*
84       * if there is no version information available, assume the previous
85       *  installed release of the plugin is 3.1.0
86       */
87      if(!isset($this->config['installed'])) $this->config['installed']='03.01.00';
88
89      /*
90      switch($this->config['installed'])
91      {
92        case '03.01.00':
93          GPCRequestBuilder::updateTables($this->config['installed']);
94          break;
95      }
96      */
97      GPCRequestBuilder::updateTables($this->config['installed']);
98
99
100      $this->config['installed']=GPC_VERSION2; //update the installed release number
101      $this->saveConfig();
102
103      return(true);
104    }
105
106    public function deactivate()
107    {
108    }
109
110  } //class
111
112?>
Note: See TracBrowser for help on using the repository browser.