source: extensions/lmt/lmt_install.class.inc.php @ 18869

Last change on this file since 18869 was 11032, checked in by grum, 13 years ago

fix feature:2150 - compatibility with piwigo 2.2

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : LMT
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  LMT_Install : classe to manage plugin install
13
14  --------------------------------------------------------------------------- */
15
16   include_once('lmt_version.inc.php'); // => Don't forget to update this file !!
17   include_once('lmt_root.class.inc.php');
18   include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
19   include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
20
21  /* lmt class for install process */
22  class LMT_Install extends LMT_root
23  {
24    private $tablef;
25    private $exportfile;
26
27    public function __construct($prefixeTable, $filelocation)
28    {
29      parent::__construct($prefixeTable, $filelocation);
30      $this->tablef= new GPCTables($this->tables);
31    }
32
33    public function __destruct()
34    {
35      unset($this->tablef);
36      unset($this->exportfile);
37      parent::__destruct();
38    }
39
40    /*
41        function for installation process
42        return true if install process is ok, otherwise false
43    */
44    public function install()
45    {
46      $this->initConfig();
47      $this->loadConfig();
48      $this->config['installed']=LMT_VERSION2;
49      $this->saveConfig();
50
51      $tables_def=array(
52"CREATE TABLE   `".$this->tables['images']."` (
53  `image_id` mediumint(8) unsigned NOT NULL default '0',
54  `licence_type` char(8) NOT NULL default 'cc-none',
55  `author_id` int UNSIGNED NOT NULL default '0',
56  PRIMARY KEY  (`image_id`),
57  KEY `by_licence` (`licence_type`),
58  KEY `by_author_id` (`author_id`)
59)
60ENGINE=MyISAM
61CHARACTER SET utf8 COLLATE utf8_general_ci",
62
63"CREATE TABLE `".$this->tables['licence_author']."` (
64  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
65  `text1` CHAR(25)  NOT NULL,
66  `text2` CHAR(25)  NOT NULL,
67  PRIMARY KEY (`id`)
68)
69ENGINE = MyISAM
70CHARACTER SET utf8 COLLATE utf8_general_ci",
71      );
72
73      $result=$this->tablef->create($tables_def);
74      GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED);
75
76      return($result);
77    }
78
79
80    /*
81        function for uninstall process
82    */
83    public function uninstall()
84    {
85      $this->deleteConfig();
86      $this->tablef->drop();
87      GPCCore::unregister($this->getPluginName());
88      return('');
89    }
90
91    public function activate()
92    {
93      global $template;
94
95      $this->initConfig();
96      $this->loadConfig();
97      $this->config['installed']=LMT_VERSION2;
98      $this->saveConfig();
99
100      GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED);
101      GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/lmt_rb_callback.class.inc.php');
102      return('');
103    }
104
105    public function deactivate()
106    {
107      GPCRequestBuilder::unregister($this->getPluginName());
108    }
109
110  } //class
111
112?>
Note: See TracBrowser for help on using the repository browser.