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

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

Version 3.2.0
Add process for update from GPC 3.1.0

File size: 2.9 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("Some plugins are dependent on Grum Plugin Classes: before uninstall, you must first uninstall the plugins dependent");
67      }
68      else
69      {
70        $result=GPCRequestBuilder::deleteTables();
71        return($result);
72      }
73    }
74
75    public function activate()
76    {
77      global $template, $user;
78
79      $this->initConfig();
80      $this->loadConfig();
81
82      /*
83       * if there is no version information available, assume the previous
84       *  installed release of the plugin is 3.1.0
85       */
86      if(!isset($this->config['installed'])) $this->config['installed']='03.01.00';
87
88      /*
89      switch($this->config['installed'])
90      {
91        case '03.01.00':
92          GPCRequestBuilder::updateTables($this->config['installed']);
93          break;
94      }
95      */
96      GPCRequestBuilder::updateTables($this->config['installed']);
97
98
99      $this->config['installed']=GPC_VERSION2; //update the installed release number
100      $this->saveConfig();
101    }
102
103    public function deactivate()
104    {
105    }
106
107  } //class
108
109?>
Note: See TracBrowser for help on using the repository browser.