<?php
/*=====================================================================*\
|| ###################################################################
|| # Bugdar
|| # Copyright (c)2004-2009 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version 2 of the License.
|| #
|| # 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 General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/
define('STOP_MARK', 5);
define('ACTIVE_SITE', 'upgrade11.php');
require_once('./global.php');
require_once('./includes/functions_datastore.php');
page_start();
// ###################################################################
if ($input->in['mark'] == 0)
{
?>
<h1>Welcome to Bugdar</h1>
<p>This upgrade will move you from Bugdar 1.1.5 to Bugdar 1.2.0 Beta 1.</p>
<p>To begin the process, please click the button below.</p>
<?php
}
// ###################################################################
if ($input->in['mark'] == 1)
{
?>
<h1>Minor Database Table Changes</h1>
<p>There are a few minor changes made to Bugdar's database schema that need to be propagated.</p>
<?php
$db->query("ALTER TABLE " . TABLE_PREFIX . "comment ADD parselinks BOOL NULL");
echo "Adding comment.parselinks to add an option to parse links in comments<br />\n";
$db->query("ALTER TABLE " . TABLE_PREFIX . "user ADD columnoptions TEXT NULL");
echo "Adding user.columnoptions to allow for custom column sorting<br />\n";
$db->query("ALTER TABLE " . TABLE_PREFIX . "product CHANGE componentmother parentid INT UNSIGNED NULL");
echo "Renaming product.componentmother to product.parentid<br />\n";
$db->query("ALTER TABLE " . TABLE_PREFIX . "version ADD obsolete BOOL NULL");
echo "Adding version.obsolete so products cannot be filed against certain versions<br />\n";
$db->query("ALTER TABLE " . TABLE_PREFIX . "user ADD authid VARCHAR(255) NULL");
echo "Adding user.authid for the Authentication API<br />\n";
echo "... done<br />\n";
}
// ###################################################################
if ($input->in['mark'] == 2)
{
?>
<h1>Search Table Changes</h1>
<p>To support saved searches, a few major modifications need to be performed on the search table.</p>
<?php
$db->query("ALTER TABLE " . TABLE_PREFIX . "search DROP PRIMARY KEY");
echo "Dropping current primary key<br />\n";
$db->query("ALTER TABLE " . TABLE_PREFIX . "search ADD searchid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY");
echo "Adding search.searchid as a new primary key<br />\n";
$db->query("ALTER TABLE " . TABLE_PREFIX . "search ADD name VARCHAR(250) NULL");
echo "Adding search.name to allow naming of searches<br />\n";
$db->query("DELETE FROM " . TABLE_PREFIX . "search");
echo "Clearing out all the old searches<br />\n";
echo "... done<br />\n";
}
// ###################################################################
if ($input->in['mark'] == 3)
{
?>
<h1>Custom Field Updates</h1>
<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>
<?php
// gets all the fields
$fields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield");
foreach ($fields as $field)
{
// create the database field
$db->query("ALTER TABLE " . TABLE_PREFIX . "bug ADD custom$field[fieldid] MEDIUMTEXT NULL");
echo "Migrating custom$field[fieldid]";
// update all the data
$data = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill");
foreach ($data as $custom)
{
echo ".";
$db->query("UPDATE " . TABLE_PREFIX . "bug SET custom$field[fieldid] = '" . $db->escape_string($custom["field$field[fieldid]"]) . "' WHERE bugid = $custom[bugid]");
}
echo "done<br />\n";
}
echo ".... all done<br />\n";
}
// ###################################################################
if ($input->in['mark'] == 4)
{
?>
<h1>Database Table Changes</h1>
<p>A few new features require new database tables, so we're adding those now.</p>
<?php
$db->query("DROP TABLE " . TABLE_PREFIX . "bugvaluefill");
echo "Dropping the old storage system for custom field data<br />";
$db->query("
CREATE TABLE " . TABLE_PREFIX . "passwordreset
(
activatorid VARCHAR(250) NOT NULL,
userid INT NOT NULL,
dateline INT NOT NULL,
PRIMARY KEY (activatorid)
)
");
echo "Creating passwordreset table to create a 'lost password' functionality<br />\n";
$db->query("
CREATE TABLE " . TABLE_PREFIX . "adminsession
(
sessionid VARCHAR(250) NOT NULL,
userid INT UNSIGNED NOT NULL,
dateline INT UNSIGNED NOT NULL,
PRIMARY KEY (sessionid)
)
");
echo "Creating adminsession table to greatly improve the admin control panel security<br />\n";
$db->query("
CREATE TABLE " . TABLE_PREFIX . "template
(
filename VARCHAR(255) NOT NULL,
template TEXT NOT NULL,
timestamp INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (filename)
)
");
echo "Creating template table to cache templates in the database to greatly inprove speed<br />\n";
echo "... done<br />\n";
}
// ###################################################################
if ($input->in['mark'] == 5)
{
?>
<h1>Version Number Change</h1>
<p>This step finishes the upgrade by inreasing your version number.</p>
<?php
$db->query("UPDATE " . TABLE_PREFIX . "setting SET value = '1.2.0 Beta 1' WHERE varname = 'trackerversion'");
$db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES ('authmethod', 'default')");
$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:8:"reporter";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";}') . "')");
$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 "0" 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.')");
build_user_help();
build_settings();
?>
... done.
<?php
}
// ###################################################################
page_end();
?>