Browse the code
| Revision log Information on the revision | |
|---|---|
| Revision: | 332 (differences) |
| Author: | xbright |
| Log message: |
* Welcome 2010 :) |
| Change revision: | |
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/php <?php # This file is a part of CodingTeam. See <http://www.codingteam.net>. # Copyright (C) 2007-2010 CodingTeam (See AUTHORS and THANKS for details) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, version 3 only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. /* Upgrade from 0.9.1 to 0.9.2 * * This script add new SQL configuration keys to the database and update the * SQL tables schema. * * http://codingteam.net/project/codingteam/doc/HowToUpgrade */ // But where are we? $base = dirname(__FILE__); $whereis = '/scripts/miscellaneous'; $length = -mb_strlen($whereis); $basedir = mb_substr($base, 0, $length); define('CT_BASEDIR', $basedir); // Check if the configuration file exist if (!file_exists($basedir.'/inc/codingteam.cfg')) die ('There are no configuration file. CodingTeam cannot start.'); // Read the configuration and connect to the database layer $xml = simplexml_load_file($basedir.'/inc/codingteam.cfg'); $db_type = $xml->db->type; $db_hostname = $xml->db->hostname; $db_database = $xml->db->database; $db_username = $xml->db->username; $db_password = $xml->db->password; // Database connection require($basedir.'/inc/classes/db.php'); $ct_db = new Database($db_type, $db_hostname, $db_database, $db_username, $db_password); // New SQL configuration keys $config = array( array('global', 'authorize-anonymous-posts', 'true', 'Authorize content posted by anonymous.') ); foreach ($config as $key) $ct_db->insert('config', array('group' => $key[0], 'field' => $key[1], 'value' => $key[2], 'text' => $key[3])); // Update table schemas $rules = array( 'ALTER TABLE `projects_admins` ADD `powers` tinytext collate utf8_bin NOT NULL AFTER `role`', 'ALTER TABLE `projects_versions` ADD `posid` int(11) NOT NULL AFTER `status`', 'CREATE TABLE IF NOT EXISTS `projects_i18n` ( '. ' `id` int(11) NOT NULL auto_increment, '. ' `projectid` int(11) NOT NULL, '. ' `baselang` varchar(5) collate utf8_bin NOT NULL, '. ' `references` tinytext collate utf8_bin NOT NULL, '. ' `text` text collate utf8_bin NOT NULL, '. ' `is_translated` tinytext collate utf8_bin NOT NULL, '. ' `is_active` tinyint(1) NOT NULL, '. ' PRIMARY KEY (`id`) '. ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;', 'CREATE TABLE IF NOT EXISTS `projects_i18n_proposals` ( '. ' `id` int(11) NOT NULL auto_increment, '. ' `text_id` int(11) NOT NULL, '. ' `authorid` int(11) NOT NULL, '. ' `text` text collate utf8_bin NOT NULL, '. ' `type` enum(\'translation\',\'reformulation\',\'correction\') collate utf8_bin NOT NULL, '. ' `lang` varchar(5) collate utf8_bin NOT NULL, '. ' `datetime` datetime NOT NULL, '. ' PRIMARY KEY (`id`) '. ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;', 'ALTER TABLE `projects_i18n` '. ' ADD CONSTRAINT `constr_projects_projectid11` FOREIGN KEY (projectid) REFERENCES projects(id) ON DELETE CASCADE;', 'ALTER TABLE `projects_i18n_proposals` '. ' ADD CONSTRAINT `constr_projects_i18n_textid` FOREIGN KEY (text_id) REFERENCES projects_i18n(id) ON DELETE CASCADE;', ); foreach ($rules as $rule) { $rs = $ct_db->dbclass->prepare($rule); $rs->execute(); } ?>

CodingTeam