array( 'link' => 0, 'block' => 1 ), 'menubar_link' => array( 'menu' => 1, 'specials' => 0 ), 'menubar_block' => array( 'number' => 5 ) ))); // Installtion function plugin_install() { global $prefixeTable; pwg_query("CREATE TABLE `" . $prefixeTable . "contests` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) NOT NULL , `date_begin` DATE NOT NULL , `date_end` DATE NOT NULL , `visible` TINYINT(1) NOT NULL , `logo` VARCHAR( 255 ) NULL , `banner` VARCHAR( 255 ) NULL , `description` TEXT NULL , PRIMARY KEY ( `id` ) );"); pwg_query("CREATE TABLE `" . $prefixeTable . "contests_results` ( `image_id` INT NOT NULL , `contest_id` INT NOT NULL , `rank` INT NOT NULL , `author` VARCHAR( 255 ) NOT NULL , `comment` TEXT NULL, UNIQUE ( `image_id` , `contest_id` ) );"); pwg_query("INSERT INTO " . CONFIG_TABLE . "(param,value,comment) VALUES('ContestResults', '" . default_config . "', 'Parametres du plugin ContestResults');"); } // Activation function plugin_activate(){ global $conf, $prefixeTable; // compatibilité avec les versions < 1.1 (ajout d'une entrée de configuration) if (!isset($conf['ContestResults'])) { pwg_query("INSERT INTO " . CONFIG_TABLE . "(param,value,comment) VALUES('ContestResults', '" . default_config . "', 'Parametres du plugin ContestResults');"); } // compatibilité avec les versions < 1.2 (suppression option d'affichage) $field = pwg_query("SHOW COLUMNS FROM `" . $prefixeTable . "contests` LIKE 'presentation_display'"); if (pwg_db_num_rows($field)) { pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `presentation_display`, DROP `rules_display`, DROP `prices_display`, DROP `final_display`;" ); } // compatibilité avec les versions < 1.3 (suppression option status, regroupement des champs de description) $field = pwg_query("SHOW COLUMNS FROM `" . $prefixeTable . "contests` LIKE 'status'"); if (pwg_db_num_rows($field)) { pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `status`"); pwg_query("ALTER TABLE `" . $prefixeTable . "contests` ADD `description` TEXT NULL"); $contests = pwg_query("SELECT * FROM `" . $prefixeTable . "contests`"); while ($contest = pwg_db_fetch_assoc($contests)) { $new_description = array(); if (!empty($contest['presentation'])) { $new_description[] = array( 'name' => 'Presentation[lang=fr]Présentation[/lang][lang=es]Presentación[/lang][lang=lv]Prezentacija[/lang]', 'content' => $contest['presentation'], ); } if (!empty($contest['rules'])) { $new_description[] = array( 'name' => 'Rules[lang=fr]Règles[/lang][lang=es]Restricciones[/lang][lang=lv]Noteikumi[/lang]', 'content' => $contest['rules'], ); } if (!empty($contest['prices'])) { $new_description[] = array( 'name' => 'Prices[lang=fr]Prix[/lang][lang=es]Precios[/lang][lang=lv]Cenas[/lang]', 'content' => $contest['prices'], ); } if (!empty($contest['final'])) { $new_description[] = array( 'name' => 'Conclusion[lang=fr]Conclusion[/lang][lang=es]Conclusión[/lang][lang=lv]Beigsana[/lang]', 'content' => $contest['final'], ); } $new_description = base64_encode(serialize($new_description)); pwg_query("UPDATE `" . $prefixeTable . "contests` SET description = '". $new_description ."' WHERE id = ". $contest['id'] .";" ); } pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `presentation`, DROP `rules`, DROP `prices`, DROP `final`;" ); } } // Désinstallation function plugin_uninstall() { global $prefixeTable; pwg_query("DROP TABLE `" . $prefixeTable . "contests`;"); pwg_query("DROP TABLE `" . $prefixeTable . "contests_results`;"); pwg_query("DELETE FROM " . CONFIG_TABLE . " WHERE `param` = 'ContestResults';"); } ?>