source: extensions/ContestResults/include/compatibility.inc.php @ 9975

Last change on this file since 9975 was 9975, checked in by mistic100, 13 years ago
  • many corrections
File size: 2.8 KB
Line 
1<?php
2
3// compatibilité avec les versions < 1.1 (ajout d'une entrée de configuration)
4if (!isset($conf['ContestResults'])) {
5        pwg_query("INSERT INTO " . CONFIG_TABLE . "(param,value,comment) VALUES('ContestResults', '" . default_config . "', 'Parametres du plugin ContestResults');");
6}
7
8// compatibilité avec les versions < 1.2 (suppression option d'affichage)
9$field = pwg_query("SHOW COLUMNS FROM `" . $prefixeTable . "contests` LIKE 'presentation_display'");
10if (pwg_db_num_rows($field)) {
11        pwg_query("ALTER TABLE `" . $prefixeTable . "contests`
12                DROP `presentation_display`,
13                DROP `rules_display`,
14                DROP `prices_display`,
15                DROP `final_display`;"
16        );
17}
18
19// compatibilité avec les versions < 1.3.a (suppression option status, regroupement des champs de description)
20$field = pwg_query("SHOW COLUMNS FROM `" . $prefixeTable . "contests` LIKE 'status'");
21if (pwg_db_num_rows($field)) {
22        pwg_query("ALTER TABLE `" . $prefixeTable . "contests` DROP `status`");
23        pwg_query("ALTER TABLE `" . $prefixeTable . "contests` ADD `description` TEXT NULL");
24       
25        $contests = pwg_query("SELECT * FROM `" . $prefixeTable . "contests`");
26        while ($contest = pwg_db_fetch_assoc($contests)) {
27                $new_description = array();
28                if (!empty($contest['presentation'])) {
29                        $new_description[] = array(
30                                'name' => 'Presentation[lang=fr]Présentation[/lang][lang=es]Presentación[/lang][lang=lv]Prezentacija[/lang]',
31                                'content' => $contest['presentation'],
32                        );
33                }
34                if (!empty($contest['rules'])) {
35                        $new_description[] = array(
36                                'name' => 'Rules[lang=fr]Règles[/lang][lang=es]Restricciones[/lang][lang=lv]Noteikumi[/lang]',
37                                'content' => $contest['rules'],
38                        );
39                }
40                if (!empty($contest['prices'])) {
41                        $new_description[] = array(
42                                'name' => 'Prices[lang=fr]Prix[/lang][lang=es]Precios[/lang][lang=lv]Cenas[/lang]',
43                                'content' => $contest['prices'],
44                        );
45                }
46                if (!empty($contest['final'])) {
47                        $new_description[] = array(
48                                'name' => 'Conclusion[lang=fr]Conclusion[/lang][lang=es]Conclusión[/lang][lang=lv]Beigsana[/lang]',
49                                'content' => $contest['final'],
50                        );
51                }
52       
53                $new_description = base64_encode(serialize($new_description));
54                pwg_query("UPDATE `" . $prefixeTable . "contests`
55                        SET description = '". $new_description ."'
56                        WHERE id = ". $contest['id'] .";"
57                );
58        }
59       
60        pwg_query("ALTER TABLE `" . $prefixeTable . "contests`
61                DROP `presentation`,
62                DROP `rules`,
63                DROP `prices`,
64                DROP `final`;"
65        );
66}
67
68// compatibilité avec les versions < 1.3.b (ajout d'un paramètre de config)
69$conf['ContestResults'] = unserialize($conf['ContestResults']);
70if (!isset($conf['ContestResults']['truncate_summary'])) {
71        $conf['ContestResults']['truncate_summary'] = 350;
72        $conf['ContestResults']['menubar_bloc']['display_days'] = true;
73        pwg_query("UPDATE " . CONFIG_TABLE . " SET value='" . serialize($conf['ContestResults']) . "' WHERE param = 'ContestResults';");
74}
75
76?>
Note: See TracBrowser for help on using the repository browser.