1 | <?php |
---|
2 | |
---|
3 | function plugin_install() |
---|
4 | { |
---|
5 | global $prefixeTable; |
---|
6 | $q = 'CREATE TABLE ' . $prefixeTable . 'mp_playlist ( |
---|
7 | id BIGINT NOT NULL AUTO_INCREMENT , |
---|
8 | type VARCHAR( 50 ) NOT NULL , |
---|
9 | url VARCHAR( 255 ) NOT NULL , |
---|
10 | texte TINYTEXT NOT NULL , |
---|
11 | PRIMARY KEY ( id ) |
---|
12 | ); |
---|
13 | '; |
---|
14 | pwg_query($q); |
---|
15 | $q = 'CREATE TABLE ' . $prefixeTable . 'mp_music ( |
---|
16 | id BIGINT NOT NULL AUTO_INCREMENT , |
---|
17 | pl_id BIGINT NOT NULL , |
---|
18 | rang BIGINT NOT NULL , |
---|
19 | url VARCHAR( 255 ) NOT NULL , |
---|
20 | nom VARCHAR( 255 ) NOT NULL , |
---|
21 | PRIMARY KEY ( id ) |
---|
22 | ); |
---|
23 | '; |
---|
24 | pwg_query($q); |
---|
25 | $q = ' |
---|
26 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
27 | VALUES |
---|
28 | ("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");'; |
---|
29 | pwg_query($q); |
---|
30 | |
---|
31 | $q = ' |
---|
32 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
33 | VALUES |
---|
34 | ("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");'; |
---|
35 | pwg_query($q); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | function plugin_activate() |
---|
41 | { |
---|
42 | global $prefixeTable; |
---|
43 | |
---|
44 | ///[ update from 1.2 ] |
---|
45 | $q = pwg_query('SHOW COLUMNS FROM '.$prefixeTable.'mp_playlist'); |
---|
46 | $champ = array(); |
---|
47 | while ($rep = mysql_fetch_row($q)) |
---|
48 | { |
---|
49 | array_push($champ, $rep[0]); |
---|
50 | } |
---|
51 | |
---|
52 | if (!in_array('type', $champ)) { |
---|
53 | pwg_query('ALTER TABLE '.$prefixeTable.'mp_playlist ADD type VARCHAR( 50 ) NOT NULL AFTER id '); |
---|
54 | } |
---|
55 | //ALTER TABLE `phpwebgallery_mp_playlist` ADD `type` VARCHAR( 50 ) NOT NULL AFTER `id` ; |
---|
56 | $query = ' |
---|
57 | SELECT COUNT(*) AS result FROM '.$prefixeTable.'mp_playlist |
---|
58 | WHERE type="" |
---|
59 | ;'; |
---|
60 | $data_table = pwg_db_fetch_array(pwg_query($query)); |
---|
61 | $exist = $data_table['result']; |
---|
62 | if ( $exist != 0 ) |
---|
63 | { |
---|
64 | $query = ' |
---|
65 | SELECT id FROM '.$prefixeTable.'mp_playlist |
---|
66 | WHERE type="" |
---|
67 | ;'; |
---|
68 | $result = pwg_query($query); |
---|
69 | while ($data = pwg_db_fetch_assoc($result)) |
---|
70 | { |
---|
71 | $query = ' |
---|
72 | UPDATE '.$prefixeTable.'mp_playlist |
---|
73 | SET type="local" |
---|
74 | WHERE id="'.$data['id'].'" |
---|
75 | LIMIT 1'; |
---|
76 | pwg_query($query); |
---|
77 | } |
---|
78 | } |
---|
79 | ///[\] |
---|
80 | |
---|
81 | $query = ' |
---|
82 | SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.' |
---|
83 | WHERE param IN (\'mp_lecteur\') |
---|
84 | ;'; |
---|
85 | $data_table = pwg_db_fetch_array(pwg_query($query)); |
---|
86 | $exist = $data_table['result']; |
---|
87 | if ( $exist == 0 ) |
---|
88 | { |
---|
89 | $q = ' |
---|
90 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
91 | VALUES |
---|
92 | ("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");'; |
---|
93 | pwg_query($q); |
---|
94 | } |
---|
95 | else { |
---|
96 | $query = ' |
---|
97 | SELECT value FROM '.CONFIG_TABLE.' |
---|
98 | WHERE param IN (\'mp_lecteur\') |
---|
99 | ;'; |
---|
100 | $data_conf = pwg_db_fetch_array(pwg_query($query)); |
---|
101 | $conf=explode(',', $data_conf['value']); |
---|
102 | $nbr=count($conf); |
---|
103 | |
---|
104 | if ($nbr!=11 or $conf[9]=='lecteur.css')// pour update depuis 2.1.0 |
---|
105 | { |
---|
106 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')'); |
---|
107 | pwg_query($q); |
---|
108 | $q = ' |
---|
109 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
110 | VALUES |
---|
111 | ("mp_lecteur" , "148,300,128,true,128,false,list,0,true,./template/style/default.conf.php,true" , "Lecteur config : haut tt, larg tt, haut pl, miniature, larg min, shuffle, repeat, autostart, autoscroll, style, style pour chaque thème");'; |
---|
112 | pwg_query($q); |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | $query = ' |
---|
118 | SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.' |
---|
119 | WHERE param IN (\'mp_plugin\') |
---|
120 | ;'; |
---|
121 | $data_table = pwg_db_fetch_array(pwg_query($query)); |
---|
122 | $exist = $data_table['result']; |
---|
123 | if ( $exist == 0 ) |
---|
124 | { |
---|
125 | $q = ' |
---|
126 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
127 | VALUES |
---|
128 | ("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");'; |
---|
129 | pwg_query($q); |
---|
130 | } |
---|
131 | else { |
---|
132 | $query = ' |
---|
133 | SELECT value FROM '.CONFIG_TABLE.' |
---|
134 | WHERE param IN (\'mp_plugin\') |
---|
135 | ;'; |
---|
136 | $data_conf = pwg_db_fetch_array(pwg_query($query)); |
---|
137 | $conf=explode(',', $data_conf['value']); |
---|
138 | $nbr=count($conf); |
---|
139 | |
---|
140 | if ($nbr!=5) |
---|
141 | { |
---|
142 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')'); |
---|
143 | pwg_query($q); |
---|
144 | $q = ' |
---|
145 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
146 | VALUES |
---|
147 | ("mp_plugin" , "true,false,false,260,400" , "Plugin music_player : evidence, header, footer, hauteur, largeur");'; |
---|
148 | pwg_query($q); |
---|
149 | } |
---|
150 | } |
---|
151 | $q = 'ALTER TABLE '.$prefixeTable.'mp_playlist CHANGE id id BIGINT( 4 ) NOT NULL AUTO_INCREMENT';pwg_query($q); |
---|
152 | $q = 'ALTER TABLE '.$prefixeTable.'mp_music CHANGE id id BIGINT( 4 ) NOT NULL AUTO_INCREMENT';pwg_query($q); |
---|
153 | $q = 'ALTER TABLE '.$prefixeTable.'mp_music CHANGE pl_id pl_id BIGINT( 4 ) NOT NULL';pwg_query($q); |
---|
154 | $q = 'ALTER TABLE '.$prefixeTable.'mp_music CHANGE rang rang BIGINT( 4 ) NOT NULL';pwg_query($q); |
---|
155 | |
---|
156 | }//fin active |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | function plugin_uninstall() |
---|
162 | { |
---|
163 | global $prefixeTable; |
---|
164 | |
---|
165 | $q = 'DROP TABLE ' . $prefixeTable . 'mp_playlist;'; |
---|
166 | pwg_query($q); |
---|
167 | $q = 'DROP TABLE ' . $prefixeTable . 'mp_music;'; |
---|
168 | pwg_query($q); |
---|
169 | |
---|
170 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')'); |
---|
171 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')'); |
---|
172 | }//fin uninstall |
---|
173 | |
---|
174 | |
---|
175 | ?> |
---|