2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
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.
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
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 \*=====================================================================*/
22 define('STOP_MARK', 7);
23 define('ACTIVE_SITE', 'upgrade2.php');
25 require_once('./global.php');
29 // ###################################################################
31 if ($bugsys->in
['mark'] == 0)
34 <h1
>Welcome to Bugdar
</h1
>
36 <p
>This upgrade will take from Bugdar
1.0.1 to Bugdar
1.1.0 Beta
1.</p
>
38 <p
>The following steps will make changes to your database schema so that you can run Bugdar
1.1.0 Beta
1. Please note that this upgrade requires the clearing of any stored searches
; we apologize
for this inconvenience
.</p
>
40 <p
>To begin the process
, please click the button below
.</p
>
44 // ###################################################################
46 if ($bugsys->in
['mark'] == 1)
49 <h1
>Major Table Changes
</h1
>
51 <p
>Major table additions
and deletions are being performed on your database
.</p
>
55 CREATE TABLE " . TABLE_PREFIX
. "useremail
57 userid int unsigned not null,
58 relation int unsigned not null,
59 mask int unsigned not null
63 echo "Adding the useremail table to store email preferences<br />\n";
65 $db->query("DROP TABLE " . TABLE_PREFIX
. "dependency");
67 echo "Dropping the unused dependency table (this was never used and was from a 1.0.0 pre-release version, so data has been lost)<br />\n";
70 // ###################################################################
72 if ($bugsys->in
['mark'] == 2)
75 <h1
>User Table Changes
</h1
>
77 <p
>Changes are now being done on the user table
.</p
>
80 $db->query("ALTER TABLE " . TABLE_PREFIX
. "user ADD usedst BOOL NOT NULL");
82 echo "Adding user.usedst, a daylight savings time option<br />\n";
84 $db->query("ALTER TABLE " . TABLE_PREFIX
. "user ADD hidestatuses mediumtext NOT NULL");
86 echo "Adding user.hidestatuses to allow users to opt to not display certain statuses<br />\n";
88 $db->query("ALTER TABLE " . TABLE_PREFIX
. "user ADD defaultsortkey varchar(50) NULL");
89 $db->query("ALTER TABLE " . TABLE_PREFIX
. "user ADD defaultsortas varchar(10) NULL");
91 echo "Adding user.defaultsortkey and user.defaultsortas for bug list sorting options<br />\n";
94 // ###################################################################
96 if ($bugsys->in
['mark'] == 3)
99 <h1
>Minor Table Changes
</h1
>
101 <p
>Minor
, miscellaneous modifications are now being performed on database tables
.</p
>
104 $db->query("DELETE FROM " . TABLE_PREFIX
. "search");
106 echo "Clearing the search table because new features make changes to the way data is stored in this table<br />\n";
108 $db->query("ALTER TABLE " . TABLE_PREFIX
. "search ADD resultcount INT(10) NULL");
110 echo "Adding search.resultcount as an internal counter for search features<br />\n";
112 $db->query("ALTER TABLE " . TABLE_PREFIX
. "bug CHANGE productid product INT(10) UNSIGNED NOT NULL DEFAULT '0'");
114 echo "Renaming bug.productid to bug.product<br />\n";
116 $db->query("ALTER TABLE " . TABLE_PREFIX
. "bug CHANGE componentid component INT(10) UNSIGNED NOT NULL DEFAULT '0'");
118 echo "Renaming bug.componentid to bug.component<br />\n";
120 $db->query("ALTER TABLE " . TABLE_PREFIX
. "bug CHANGE versionid version INT(10) UNSIGNED NOT NULL DEFAULT '0'");
122 echo "Renaming bug.versionid to bug.version<br />\n";
125 // ###################################################################
127 if ($bugsys->in
['mark'] == 4)
130 <h1
>Caching User Data in Bug Table
</h1
>
132 <p
>To decrease load times
and complex queries
, user information is now stored in the bug table
. This step will add additional fields
for this data
and then will populate those same fields
.</p
>
135 $db->query("ALTER TABLE " . TABLE_PREFIX
. "bug ADD username varchar(255) NOT NULL");
136 $db->query("ALTER TABLE " . TABLE_PREFIX
. "bug ADD lastpostbyname varchar(255) NOT NULL");
137 $db->query("ALTER TABLE " . TABLE_PREFIX
. "bug ADD hiddenlastpostbyname varchar(255) NOT NULL");
139 echo "Adding bug.username, bug.lastpostbyname, and bug.hiddenlastpostbyname to store cached user name data<br />\n";
141 echo "Caching bug data";
144 $users = $db->query("SELECT userid, displayname FROM " . TABLE_PREFIX
. "user");
145 while ($user = $db->fetch_array($users))
147 $userlist["$user[userid]"] = $user['displayname'];
150 $bugs = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bug");
151 while ($bug = $db->fetch_array($bugs))
154 UPDATE " . TABLE_PREFIX
. "bug
155 SET username = '" . $db->escape_string($userlist["$bug[userid]"]) . "',
156 lastpostbyname = '" . $db->escape_string($userlist["$bug[lastpostby]"]) . "',
157 hiddenlastpostbyname = '" . $db->escape_string($userlist["$bug[hiddenlastpostby]"]) . "'
158 WHERE bugid = $bug[bugid]
163 echo " done<br />\n";
166 // ###################################################################
168 if ($bugsys->in
['mark'] == 5)
171 <h1
>Updating Old History Items
</h1
>
173 <p
>In Bugdar
1.1.0, the bug history feature has been improved significantly
. To bring old history messages up to date
, processing has to be done
. Please wait
while historical records are updated
.</p
>
176 echo "Updating historical records";
178 $history = $db->query("SELECT * FROM " . TABLE_PREFIX
. "history");
179 while ($log = $db->fetch_array($history))
182 if (preg_match('#custom_field([0-9]+?)#i', $log['field'], $matches))
184 $db->query("UPDATE " . TABLE_PREFIX
. "history SET field = 'custom.field{$matches[1]}' WHERE historyid = $log[historyid]");
186 else if (preg_match('#comment ([0-9]+?) (hidden|text)#i', $log['field'], $matches))
188 $db->query("UPDATE " . TABLE_PREFIX
. "history SET field = 'comment.{$matches[2]}', commentid = {$matches[1]} WHERE historyid = $log[historyid]");
190 else if ($log['attachmentid'] != 0)
192 $db->query("UPDATE " . TABLE_PREFIX
. "history SET field = 'attachment.{$log['field']}' WHERE historyid = $log[historyid]");
194 else if (!preg_match('#^(comment|attachment)?\.#', $log['field']))
196 foreach (array('original', 'changed') AS $array)
198 if (preg_match('# \(id: ([0-9]+?)\)$#i', $log["$array"], $matches))
200 $db->query("UPDATE
" . TABLE_PREFIX . "history SET
$array = {$matches
[1]} WHERE historyid
= $log[historyid
]");
202 else if (preg_match('#user ?id:? ([0-9]+?)#i', $log["$array"], $matches))
204 $db->query("UPDATE " . TABLE_PREFIX
. "history SET $array = {$matches[1]} WHERE historyid = $log[historyid]");
206 $db->query("UPDATE " . TABLE_PREFIX
. "history SET field = '.{$log['field']}' WHERE historyid = $log[historyid]");
212 echo " done<br />\n";
215 // ###################################################################
217 if ($bugsys->in
['mark'] == 6)
220 <h1
>Adding User Email Options
</h1
>
222 <p
>In Bugdar
1.1.0, users can receive email notifications on various bug events
. We are now setting the
default email settings
for all users
.</p
>
225 echo "Setting email options";
227 $users = $db->query("SELECT userid FROM " . TABLE_PREFIX
. "user");
228 while ($user = $db->fetch_array($users))
231 INSERT INTO " . TABLE_PREFIX
. "useremail
232 (userid, mask, relation)
234 ($user[userid], 32, 0),
235 ($user[userid], 320, 1),
236 ($user[userid], 1984, 2),
237 ($user[userid], 64, 4),
238 ($user[userid], 64, 8),
239 ($user[userid], 256, 16
245 echo " done<br />\n";
248 // ###################################################################
250 if ($bugsys->in
['mark'] == 7)
253 <h1
>Version Number Change
</h1
>
255 <p
>This step finishes the upgrade by inreasing your version number
and then updating other settings
.</p
>
259 require_once('./includes/settings.php');
261 $db->query("UPDATE " . TABLE_PREFIX
. "setting SET value = '1.1.0 Beta 1' WHERE varname = 'trackerversion'");
263 $db->query("INSERT INTO " . TABLE_PREFIX
. "setting (varname, value) VALUES ('syndicateditems', '" . $settings['general']['syndicateditems'][1] . "')");
264 $db->query("INSERT INTO " . TABLE_PREFIX
. "setting (varname, value) VALUES ('hidestatuses', '" . $settings['display']['hidestatuses'][1] . "')");
265 $db->query("INSERT INTO " . TABLE_PREFIX
. "setting (varname, value) VALUES ('defaultsortkey', '" . $settings['display']['defaultsortkey'][1] . "')");
266 $db->query("INSERT INTO " . TABLE_PREFIX
. "setting (varname, value) VALUES ('defaultsortas', '" . $settings['display']['defaultsortas'][1] . "')");
277 // ###################################################################
281 /*=====================================================================*\
282 || ###################################################################
285 || ###################################################################
286 \*=====================================================================*/