r1456: We need to add default settings and custom help to the upgrade script because...
[bugdar.git] / install / upgrade11.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 define('STOP_MARK', 5);
23 define('ACTIVE_SITE', 'upgrade11.php');
24
25 require_once('./global.php');
26 require_once('./includes/functions_datastore.php');
27
28 page_start();
29
30 // ###################################################################
31
32 if ($bugsys->in['mark'] == 0)
33 {
34 ?>
35 <h1>Welcome to Bugdar</h1>
36
37 <p>This upgrade will move you from Bugdar 1.1.5 to Bugdar 1.2.0 Beta 1.</p>
38
39 <p>To begin the process, please click the button below.</p>
40 <?php
41 }
42
43 // ###################################################################
44
45 if ($bugsys->in['mark'] == 1)
46 {
47 ?>
48 <h1>Minor Database Table Changes</h1>
49
50 <p>There are a few minor changes made to Bugdar's database schema that need to be propagated.</p>
51 <?php
52
53 $db->query("ALTER TABLE " . TABLE_PREFIX . "comment ADD parselinks BOOL NULL");
54 echo "Adding comment.parselinks to add an option to parse links in comments<br />\n";
55
56 $db->query("ALTER TABLE " . TABLE_PREFIX . "user ADD columnoptions TEXT NULL");
57 echo "Adding user.columnoptions to allow for custom column sorting<br />\n";
58
59 $db->query("ALTER TABLE " . TABLE_PREFIX . "product CHANGE componentmother parentid INT UNSIGNED NULL");
60 echo "Renaming product.componentmother to product.parentid<br />\n";
61
62 $db->query("ALTER TABLE " . TABLE_PREFIX . "version ADD obsolete BOOL NULL");
63 echo "Adding version.obsolete so products cannot be filed against certain versions<br />\n";
64
65 $db->query("ALTER TABLE " . TABLE_PREFIX . "user ADD authid VARCHAR(255) NULL");
66 echo "Adding user.authid for the Authentication API<br />\n";
67
68 echo "... done<br />\n";
69 }
70
71 // ###################################################################
72
73 if ($bugsys->in['mark'] == 2)
74 {
75 ?>
76 <h1>Search Table Changes</h1>
77
78 <p>To support saved searches, a few major modifications need to be performed on the search table.</p>
79 <?php
80
81 $db->query("ALTER TABLE " . TABLE_PREFIX . "search DROP PRIMARY KEY");
82 echo "Dropping current primary key<br />\n";
83
84 $db->query("ALTER TABLE " . TABLE_PREFIX . "search ADD searchid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY");
85 echo "Adding search.searchid as a new primary key<br />\n";
86
87 $db->query("ALTER TABLE " . TABLE_PREFIX . "search ADD name VARCHAR(250) NULL");
88 echo "Adding search.name to allow naming of searches<br />\n";
89
90 echo "... done<br />\n";
91 }
92
93 // ###################################################################
94
95 if ($bugsys->in['mark'] == 3)
96 {
97 ?>
98 <h1>Custom Field Updates</h1>
99
100 <p>A change was made to the storage of custom bug field data. The data is being migrated to a different database table, but no data will be lost. This may take a few minutes. Do <em>not</em> go onto the next step if you receive any errors here.</p>
101 <?php
102 // gets all the fields
103 $fields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield");
104 while ($field = $db->fetch_array($fields))
105 {
106 // create the database field
107 $db->query("ALTER TABLE " . TABLE_PREFIX . "bug ADD custom$field[fieldid] MEDIUMTEXT NULL");
108
109 echo "Migrating custom$field[fieldid]";
110
111 // update all the data
112 $data = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill");
113 while ($custom = $db->fetch_array($data))
114 {
115 echo ".";
116 $db->query("UPDATE " . TABLE_PREFIX . "bug SET custom$field[fieldid] = '" . $db->escape_string($custom["field$field[fieldid]"]) . "' WHERE bugid = $custom[bugid]");
117 }
118 echo "done<br />\n";
119 }
120
121 echo ".... all done<br />\n";
122 }
123
124 // ###################################################################
125
126 if ($bugsys->in['mark'] == 4)
127 {
128 ?>
129 <h1>Database Table Changes</h1>
130
131 <p>A few new features require new database tables, so we're adding those now.</p>
132 <?php
133
134 $db->query("DROP TABLE " . TABLE_PREFIX . "bugvaluefill");
135 echo "Dropping the old storage system for custom field data<br />";
136
137 $db->query("
138 CREATE TABLE " . TABLE_PREFIX . "passwordreset
139 (
140 activatorid VARCHAR(250) NOT NULL,
141 userid INT NOT NULL,
142 dateline INT NOT NULL,
143 PRIMARY KEY (activatorid)
144 )
145 ");
146 echo "Creating passwordreset table to create a 'lost password' functionality<br />\n";
147
148 $db->query("
149 CREATE TABLE " . TABLE_PREFIX . "adminsession
150 (
151 sessionid VARCHAR(250) NOT NULL,
152 userid INT UNSIGNED NOT NULL,
153 dateline INT UNSIGNED NOT NULL,
154 PRIMARY KEY (sessionid)
155 )
156 ");
157 echo "Creating adminsession table to greatly improve the admin control panel security<br />\n";
158
159 $db->query("
160 CREATE TABLE " . TABLE_PREFIX . "template
161 (
162 filename VARCHAR(255) NOT NULL,
163 template TEXT NOT NULL,
164 timestamp INT(10) UNSIGNED NOT NULL,
165 PRIMARY KEY (filename)
166 )
167 ");
168 echo "Creating template table to cache templates in the database to greatly inprove speed<br />\n";
169
170 echo "... done<br />\n";
171 }
172
173 // ###################################################################
174
175 if ($bugsys->in['mark'] == 5)
176 {
177 ?>
178 <h1>Version Number Change</h1>
179
180 <p>This step finishes the upgrade by inreasing your version number.</p>
181
182 <?php
183
184 $db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '1.2.0 Beta 1' WHERE varname = 'trackerversion'");
185 $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('authmethod', 'default')");
186 $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('columnoptions', '" . $db->escape_string('a:12:{s:5:"bugid";s:1:"1";s:7:"summary";s:1:"2";s:6:"userid";s:1:"2";s:7:"product";s:1:"3";s:9:"component";s:1:"0";s:7:"version";s:1:"3";s:6:"status";s:1:"4";s:10:"resolution";s:1:"4";s:8:"priority";s:1:"5";s:8:"severity";s:1:"5";s:8:"lastpost";s:1:"6";s:5:"votes";s:1:"0";}') . "')");
187 $db->query("REPLACE INTO " . TABLE_PREFIX . "fieldhelp (keystring, title, body) VALUES ('columnorder', 'Custom Column Ordering', 'You can change the ordering and display of columns on the bug list using these settings. Any column with a position value of &quot;0&quot; will not be displayed in the list. Columns are positioned in the grid with the lowest numbered column starting at the far-left. If columns share a position number, they will be placed in the same column position.')");
188
189 build_user_help();
190 build_settings();
191
192 ?>
193
194 ... done.
195
196 <?php
197 }
198
199 // ###################################################################
200
201 page_end();
202
203 /*=====================================================================*\
204 || ###################################################################
205 || # $HeadURL$
206 || # $Id$
207 || ###################################################################
208 \*=====================================================================*/
209 ?>