system_settings_table); $lastVersion = DBUtil::getOneResultKey($query, 'value'); $currentVersion = $default->systemVersion; $upgrades = describeUpgrade($lastVersion, $currentVersion); $ret = "\n"; $ret .= "\n"; foreach ($upgrades as $upgrade) { $ret .= sprintf("\n", htmlspecialchars($upgrade->getDescriptor()), htmlspecialchars($upgrade->getDescription()), $upgrade->isAlreadyApplied() ? "Yes" : "No" ); } $ret .= '
CodeDescriptionApplied
%s%s%s
'; return $ret; } function showResult($res) { if (PEAR::isError($res)) { if (is_a($res, 'Upgrade_Already_Applied')) { return 'Already applied'; } return sprintf('%s', htmlspecialchars($res->toString())); } if ($res === true) { return 'Success'; } if ($res === false) { return 'Failure'; } return $res; } $GLOBALS['row'] = 1; function performAllUpgrades () { global $default; $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); $lastVersion = DBUtil::getOneResultKey($query, 'value'); $currentVersion = $default->systemVersion; $upgrades = describeUpgrade($lastVersion, $currentVersion); foreach ($upgrades as $upgrade) { if (($GLOBALS['row'] % 2) == 1) { $class = "odd"; } else { $class = "even"; } printf('
%s
' . "\n", $class, htmlspecialchars($upgrade->getDescription())); $GLOBALS['row']++; ob_flush(); flush(); $res = $upgrade->performUpgrade(); printf('
%s
', showResult($res)); print '
' . "\n"; ob_flush(); flush(); print "
\n"; if (PEAR::isError($res)) { if (!is_a($res, 'Upgrade_Already_Applied')) { break; } else { $res = true; } } if ($res === false) { $res = PEAR::raiseError("Upgrade returned false"); break; } } return $res; } function failWritablePath($name, $path) { if (!is_writable($path)) { sprintf("The path for setting %s, which is set to %s, can not be written to. Correct this situation before continuing.", $name, $path); exit(1); } } failWritablePath('Log directory', $default->logDirectory); failWritablePath('Document directory', $default->documentRoot); if (PEAR::isError($loggingSupport)) { print '

Logging support is not currently working. Check post-installation checkup.

'; exit(1); } if (PEAR::isError($dbSupport)) { print '

Database support is not currently working. Check post-installation checkup.

'; exit(1); } if ($_REQUEST["go"] === "Upgrade") { $performingUpgrade = true; } else { $upgradeTable = generateUpgradeTable(); } ?> KnowledgeTree Upgrade

KnowledgeTree Upgrades

The table below describes the upgrades that need to occur to upgrade your KnowledgeTree installation to $default->systemVersion. Click on the button below the table to perform the upgrades.

"; $upgradeTable = generateUpgradeTable(); print $upgradeTable; print '
'; print ''; } else { print "

The table below describes the upgrades that have occurred to upgrade your KnowledgeTree installation to $default->systemVersion. "; $res = performAllUpgrades(); if (PEAR::isError($res)) { print 'Upgrade failed.' . "\n"; } else { $sUrl = generateLink(""); print sprintf('Upgrade succeeded. Now try log in and use the system.', $sUrl) . "\n"; } print ''; } ?>