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 | @include_once('lmt_root.class.inc.php'); |
---|
16 | @include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/tables.class.inc.php'); |
---|
17 | |
---|
18 | |
---|
19 | /* lmt class for install process */ |
---|
20 | class LMT_Install extends LMT_root |
---|
21 | { |
---|
22 | private $tablef; |
---|
23 | private $exportfile; |
---|
24 | |
---|
25 | public function LMT_Install($prefixeTable, $filelocation) |
---|
26 | { |
---|
27 | parent::__construct($prefixeTable, $filelocation); |
---|
28 | $this->tablef= new manage_tables($this->tables); |
---|
29 | $this->exportfile=dirname($this->filelocation).'/'.$this->plugin_name_files.'.sql'; |
---|
30 | } |
---|
31 | |
---|
32 | /* |
---|
33 | function for installation process |
---|
34 | return true if install process is ok, otherwise false |
---|
35 | */ |
---|
36 | public function install() |
---|
37 | { |
---|
38 | $tables_def=array( |
---|
39 | "CREATE TABLE `".$this->tables['images']."` ( |
---|
40 | `image_id` mediumint(8) unsigned NOT NULL default '0', |
---|
41 | `licence_type` char(8) NOT NULL default 'cc-none', |
---|
42 | `author_id` int UNSIGNED NOT NULL default '0', |
---|
43 | PRIMARY KEY (`image_id`), |
---|
44 | KEY `by_licence` (`licence_type`), |
---|
45 | KEY `by_author_id` (`author_id`) |
---|
46 | ) |
---|
47 | ENGINE=MyISAM |
---|
48 | CHARACTER SET utf8 COLLATE utf8_general_ci", |
---|
49 | |
---|
50 | "CREATE TABLE `".$this->tables['licence_author']."` ( |
---|
51 | `id` int UNSIGNED NOT NULL AUTO_INCREMENT, |
---|
52 | `text1` CHAR(25) NOT NULL, |
---|
53 | `text2` CHAR(25) NOT NULL, |
---|
54 | PRIMARY KEY (`id`) |
---|
55 | ) |
---|
56 | ENGINE = MyISAM |
---|
57 | CHARACTER SET utf8 COLLATE utf8_general_ci", |
---|
58 | ); |
---|
59 | |
---|
60 | //if present, try to import backup |
---|
61 | //if backup file |
---|
62 | $import=$this->tablef->import($this->exportfile); |
---|
63 | if($import['errors']<0) |
---|
64 | { |
---|
65 | $result=$this->tablef->create_tables($tables_def); |
---|
66 | return($result); |
---|
67 | } |
---|
68 | else |
---|
69 | { |
---|
70 | return(true); |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | /* |
---|
76 | function for uninstall process |
---|
77 | */ |
---|
78 | public function uninstall() |
---|
79 | { |
---|
80 | $this->tablef->export($this->exportfile); |
---|
81 | $this->delete_config(); |
---|
82 | $this->tablef->drop_tables(); |
---|
83 | return(''); |
---|
84 | } |
---|
85 | |
---|
86 | public function activate() |
---|
87 | { |
---|
88 | global $template; |
---|
89 | |
---|
90 | $this->init_config(); |
---|
91 | $this->load_config(); |
---|
92 | $this->save_config(); |
---|
93 | return(''); |
---|
94 | } |
---|
95 | |
---|
96 | public function deactivate() |
---|
97 | { |
---|
98 | } |
---|
99 | |
---|
100 | } //class |
---|
101 | |
---|
102 | ?> |
---|