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 | |
---|
20 | /* lmt class for install process */ |
---|
21 | class LMT_Install extends LMT_root |
---|
22 | { |
---|
23 | private $tablef; |
---|
24 | private $exportfile; |
---|
25 | |
---|
26 | public function __construct($prefixeTable, $filelocation) |
---|
27 | { |
---|
28 | parent::__construct($prefixeTable, $filelocation); |
---|
29 | $this->tablef= new GPCTables($this->tables); |
---|
30 | $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql'; |
---|
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 | ) |
---|
60 | ENGINE=MyISAM |
---|
61 | CHARACTER 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 | ) |
---|
69 | ENGINE = MyISAM |
---|
70 | CHARACTER SET utf8 COLLATE utf8_general_ci", |
---|
71 | ); |
---|
72 | |
---|
73 | //if present, try to import backup |
---|
74 | //if backup file |
---|
75 | $import=$this->tablef->import($this->exportfile); |
---|
76 | if($import['errors']<0) |
---|
77 | { |
---|
78 | $result=$this->tablef->create($tables_def); |
---|
79 | return($result); |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | return(true); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | /* |
---|
89 | function for uninstall process |
---|
90 | */ |
---|
91 | public function uninstall() |
---|
92 | { |
---|
93 | $this->tablef->export($this->exportfile); |
---|
94 | $this->deleteConfig(); |
---|
95 | $this->tablef->drop(); |
---|
96 | return(''); |
---|
97 | } |
---|
98 | |
---|
99 | public function activate() |
---|
100 | { |
---|
101 | global $template; |
---|
102 | |
---|
103 | $this->initConfig(); |
---|
104 | $this->loadConfig(); |
---|
105 | $this->config['installed']=LMT_VERSION2; |
---|
106 | $this->saveConfig(); |
---|
107 | return(''); |
---|
108 | } |
---|
109 | |
---|
110 | public function deactivate() |
---|
111 | { |
---|
112 | } |
---|
113 | |
---|
114 | } //class |
---|
115 | |
---|
116 | ?> |
---|