[9590] | 1 | <?php |
---|
| 2 | |
---|
| 3 | function plugin_install() |
---|
| 4 | { |
---|
[12578] | 5 | global $prefixeTable; |
---|
[22762] | 6 | $q = 'CREATE TABLE IF NOT EXISTS ' . $prefixeTable . 'mp_playlist ( |
---|
[12578] | 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); |
---|
[22762] | 15 | $q = 'CREATE TABLE IF NOT EXISTS ' . $prefixeTable . 'mp_music ( |
---|
[12578] | 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); |
---|
[9590] | 30 | |
---|
[12578] | 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); |
---|
[9590] | 36 | } |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | function plugin_activate() |
---|
| 41 | { |
---|
[12578] | 42 | global $prefixeTable; |
---|
[9590] | 43 | |
---|
| 44 | ///[ update from 1.2 ] |
---|
[12578] | 45 | $q = pwg_query('SHOW COLUMNS FROM '.$prefixeTable.'mp_playlist'); |
---|
| 46 | $champ = array(); |
---|
[22762] | 47 | while ($rep = pwg_db_fetch_row($q)) |
---|
[12578] | 48 | { |
---|
| 49 | array_push($champ, $rep[0]); |
---|
| 50 | } |
---|
[9590] | 51 | |
---|
[12578] | 52 | if (!in_array('type', $champ)) { |
---|
| 53 | pwg_query('ALTER TABLE '.$prefixeTable.'mp_playlist ADD type VARCHAR( 50 ) NOT NULL AFTER id '); |
---|
| 54 | } |
---|
[9590] | 55 | //ALTER TABLE `phpwebgallery_mp_playlist` ADD `type` VARCHAR( 50 ) NOT NULL AFTER `id` ; |
---|
[12578] | 56 | $query = ' |
---|
| 57 | SELECT COUNT(*) AS result FROM '.$prefixeTable.'mp_playlist |
---|
| 58 | WHERE type="" |
---|
| 59 | ;'; |
---|
[21048] | 60 | $data_table = pwg_db_fetch_array(pwg_query($query)); |
---|
[12578] | 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); |
---|
[21048] | 69 | while ($data = pwg_db_fetch_assoc($result)) |
---|
[12578] | 70 | { |
---|
[9590] | 71 | $query = ' |
---|
[12578] | 72 | UPDATE '.$prefixeTable.'mp_playlist |
---|
| 73 | SET type="local" |
---|
| 74 | WHERE id="'.$data['id'].'" |
---|
| 75 | LIMIT 1'; |
---|
| 76 | pwg_query($query); |
---|
| 77 | } |
---|
| 78 | } |
---|
[9590] | 79 | ///[\] |
---|
| 80 | |
---|
[12578] | 81 | $query = ' |
---|
[9590] | 82 | SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.' |
---|
[12578] | 83 | WHERE param IN (\'mp_lecteur\') |
---|
[9590] | 84 | ;'; |
---|
[21048] | 85 | $data_table = pwg_db_fetch_array(pwg_query($query)); |
---|
[12578] | 86 | $exist = $data_table['result']; |
---|
| 87 | if ( $exist == 0 ) |
---|
| 88 | { |
---|
| 89 | $q = ' |
---|
[9590] | 90 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
[12578] | 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 = ' |
---|
[9590] | 97 | SELECT value FROM '.CONFIG_TABLE.' |
---|
[12578] | 98 | WHERE param IN (\'mp_lecteur\') |
---|
[9590] | 99 | ;'; |
---|
[21048] | 100 | $data_conf = pwg_db_fetch_array(pwg_query($query)); |
---|
[12578] | 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 | { |
---|
[9590] | 106 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_lecteur\')'); |
---|
| 107 | pwg_query($q); |
---|
[12578] | 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");'; |
---|
[9590] | 112 | pwg_query($q); |
---|
| 113 | } |
---|
[12578] | 114 | } |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | $query = ' |
---|
| 118 | SELECT COUNT(*) AS result FROM '.CONFIG_TABLE.' |
---|
| 119 | WHERE param IN (\'mp_plugin\') |
---|
| 120 | ;'; |
---|
[21048] | 121 | $data_table = pwg_db_fetch_array(pwg_query($query)); |
---|
[12578] | 122 | $exist = $data_table['result']; |
---|
| 123 | if ( $exist == 0 ) |
---|
| 124 | { |
---|
[9590] | 125 | $q = ' |
---|
[12578] | 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");'; |
---|
[9590] | 129 | pwg_query($q); |
---|
| 130 | } |
---|
[12578] | 131 | else { |
---|
| 132 | $query = ' |
---|
| 133 | SELECT value FROM '.CONFIG_TABLE.' |
---|
| 134 | WHERE param IN (\'mp_plugin\') |
---|
| 135 | ;'; |
---|
[21048] | 136 | $data_conf = pwg_db_fetch_array(pwg_query($query)); |
---|
[12578] | 137 | $conf=explode(',', $data_conf['value']); |
---|
| 138 | $nbr=count($conf); |
---|
| 139 | |
---|
| 140 | if ($nbr!=5) |
---|
| 141 | { |
---|
[9590] | 142 | pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'mp_plugin\')'); |
---|
| 143 | pwg_query($q); |
---|
| 144 | $q = ' |
---|
[12578] | 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");'; |
---|
[9590] | 148 | pwg_query($q); |
---|
[12578] | 149 | } |
---|
| 150 | } |
---|
[12583] | 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); |
---|
[12578] | 155 | |
---|
[9590] | 156 | }//fin active |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | function plugin_uninstall() |
---|
| 162 | { |
---|
[12578] | 163 | global $prefixeTable; |
---|
| 164 | |
---|
[9590] | 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 | |
---|
[3329] | 175 | ?> |
---|