* adjust the upgrade feature.
This commit is contained in:
@@ -26,14 +26,29 @@ class upgrade extends control
|
||||
/* 升级程序首页。*/
|
||||
public function index()
|
||||
{
|
||||
$this->locate(inlink('selectVersion'));
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 选择系统。*/
|
||||
public function selectVersion()
|
||||
{
|
||||
/* 处理版本号。*/
|
||||
$version = substr($this->config->installedVersion, 0, strpos($this->config->installedVersion, ' '));
|
||||
$version = str_replace('.', '_', $version);
|
||||
$this->view->header->title = $this->lang->upgrade->common . $this->lang->colon . $this->lang->upgrade->selectVersion;
|
||||
$this->view->position[] = $this->lang->upgrade->common;
|
||||
$this->view->version = $version;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 确认。*/
|
||||
public function confirm()
|
||||
{
|
||||
$this->view->header->title = $this->lang->upgrade->confirm;
|
||||
$this->view->position[] = $this->lang->upgrade->common;
|
||||
$this->view->confirm = $this->upgrade->confirm($this->post->fromVersion);
|
||||
$this->view->fromVersion = $this->post->fromVersion;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,20 @@ $lang->upgrade->result = '升级结果';
|
||||
$lang->upgrade->fail = '升级失败';
|
||||
$lang->upgrade->success = '升级成功';
|
||||
$lang->upgrade->tohome = '返回首页';
|
||||
|
||||
$lang->upgrade->warnning= '警告';
|
||||
$lang->upgrade->warnningContent = <<<EOT
|
||||
警告!升级有危险,请先备份数据库,以防万一。<br />
|
||||
备份方法:<br />
|
||||
1. 可以通过phpMyAdmin进行备份。<br />
|
||||
2. 使用mysql命令行的工具。<br />
|
||||
# mysqldump -u <span class='red'>username</span> -p <span class='red'>dbname</span> > <span class='red'>filename</span> <br />
|
||||
要将上面红色的部分分别替换成对应的用户名和禅道系统的数据库名。<br />
|
||||
比如: mysqldump -u root -p zentao >zentao.bak
|
||||
EOT;
|
||||
$lang->upgrade->selectVersion = '选择版本';
|
||||
$lang->upgrade->fromVersion = '升级版本';
|
||||
$lang->upgrade->confirm = '确认要执行的SQL语句';
|
||||
$lang->upgrade->sureExecute = '确认执行';
|
||||
|
||||
$lang->upgrade->fromVersions['0_3'] = '0.3 BETA';
|
||||
$lang->upgrade->fromVersions['0_4'] = '0.4 BETA';
|
||||
|
||||
@@ -33,18 +33,43 @@ class upgradeModel extends model
|
||||
if($fromVersion == '0_3')
|
||||
{
|
||||
$this->upgradeFrom0_3To0_4();
|
||||
$this->upgradeFrom0_4To0_5();
|
||||
}
|
||||
elseif($fromVersion == '0_4')
|
||||
{
|
||||
$this->upgradeFrom0_4To0_5();
|
||||
}
|
||||
}
|
||||
|
||||
/* 确认。*/
|
||||
public function confirm($fromVersion)
|
||||
{
|
||||
$confirmContent = '';
|
||||
if($fromVersion == '0_3')
|
||||
{
|
||||
$confirmContent .= file_get_contents($this->getUpgradeFile('0.3'));
|
||||
$confirmContent .= file_get_contents($this->getUpgradeFile('0.4'));
|
||||
}
|
||||
elseif($fromVersion == '0_4')
|
||||
{
|
||||
$confirmContent .= file_get_contents($this->getUpgradeFile('0.4'));
|
||||
}
|
||||
return str_replace('zt_', $this->config->db->prefix, $confirmContent);
|
||||
}
|
||||
|
||||
|
||||
/* 从0.3版本升级到0.4版本。*/
|
||||
private function upgradeFrom0_3To0_4()
|
||||
{
|
||||
$upgradeFile = $this->app->getAppRoot() . 'db' . $this->app->getPathFix() . 'update0.3.sql';
|
||||
$this->execSQL($upgradeFile);
|
||||
if(!$this->isError())
|
||||
{
|
||||
$this->updateVersion('0.4 beta');
|
||||
}
|
||||
$this->execSQL($this->getUpgradeFile('0.3'));
|
||||
if(!$this->isError()) $this->updateVersion('0.4 beta');
|
||||
}
|
||||
|
||||
/* 从0.4版本升级到0.5版本。*/
|
||||
private function upgradeFrom0_4To0_5()
|
||||
{
|
||||
$this->execSQL($this->getUpgradeFile('0.4'));
|
||||
if(!$this->isError()) $this->updateVersion('0.5 beta');
|
||||
}
|
||||
|
||||
/* 更新PMS的版本设置。*/
|
||||
@@ -70,6 +95,12 @@ class upgradeModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
/* 获得要更新的sql文件。*/
|
||||
private function getUpgradeFile($version)
|
||||
{
|
||||
return $this->app->getAppRoot() . 'db' . $this->app->getPathFix() . 'update' . $version . '.sql';
|
||||
}
|
||||
|
||||
/* 执行SQL。*/
|
||||
private function execSQL($sqlFile)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* The html template file of confirm method of upgrade module of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright: 2009 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package upgrade
|
||||
* @version $Id$
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.lite.html.php';?>
|
||||
<div class='yui-d0' style='margin-top:50px'>
|
||||
<form method='post' action='<?php echo inlink('execute');?>'>
|
||||
<table align='center' class='table-6 f-14px'>
|
||||
<caption><?php echo $lang->upgrade->confirm;?></caption>
|
||||
<tr>
|
||||
<td><textarea rows='20' class='area-1'><?php echo $confirm;?></textarea></td>
|
||||
<tr>
|
||||
<td class='a-center'><?php echo html::submitButton($lang->upgrade->sureExecute) . html::hidden('fromVersion', $fromVersion);?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
@@ -21,8 +21,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<?php include '../../common/header.lite.html.php';?>
|
||||
<div class='yui-d0' style='margin-top:50px'>
|
||||
<table align='center' class='table-5 f-14px'>
|
||||
<caption><?php echo $lang->upgrade->$result;?></caption>
|
||||
<tr>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* The html template file of index method of upgrade module of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright: 2009 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package upgrade
|
||||
* @version $Id$
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.lite.html.php';?>
|
||||
<div class='yui-d0' style='margin-top:50px'>
|
||||
<table align='center' class='table-5 f-14px'>
|
||||
<caption><?php echo $lang->upgrade->warnning;?></caption>
|
||||
<tr>
|
||||
<td><?php echo $lang->upgrade->warnningContent;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'><?php echo html::linkButton($lang->upgrade->common, inlink('selectVersion'));?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
@@ -21,14 +21,14 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<form method='post' action='<?php echo inlink('execute');?>'>
|
||||
<?php include '../../common/header.lite.html.php';?>
|
||||
<div class='yui-d0' style='margin-top:50px'>
|
||||
<form method='post' action='<?php echo inlink('confirm');?>'>
|
||||
<table align='center' class='table-5 f-14px'>
|
||||
<caption><?php echo $lang->upgrade->selectVersion;?></caption>
|
||||
<tr>
|
||||
<th class='w-p20 rowhead'><?php echo $lang->upgrade->fromVersion;?></th>
|
||||
<td><?php echo html::select('fromVersion', $lang->upgrade->fromVersions, '', 'class=select-3');?></td>
|
||||
<td><?php echo html::select('fromVersion', $lang->upgrade->fromVersions, $version, 'class=select-3');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'><?php echo html::submitButton($lang->upgrade->common);?></td>
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
/**
|
||||
* The install router file of ZenTaoMS.
|
||||
*
|
||||
* All request should be routed by this router.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* The upgrade router file of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* ZenTaoMS 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright: 2009 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package ZenTaoMS
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
/* 包含必须的类文件。*/
|
||||
include '../../../framework/router.class.php';
|
||||
include '../../../framework/control.class.php';
|
||||
include '../../../framework/model.class.php';
|
||||
include '../../../framework/helper.class.php';
|
||||
|
||||
/* 实例化路由对象,加载配置,连接到数据库。*/
|
||||
$app = router::createApp('pms');
|
||||
$config = $app->loadConfig('common');
|
||||
|
||||
/* 重新设置config参数,进行升级。*/
|
||||
$config->set('requestType', 'GET');
|
||||
$config->set('debug', true);
|
||||
$config->set('default.module', 'upgrade');
|
||||
|
||||
/* 连接到数据库。*/
|
||||
$dbh = $app->connectDB();
|
||||
|
||||
/* 设置客户端所使用的语言、风格。*/
|
||||
$app->setClientLang();
|
||||
$app->setClientTheme();
|
||||
|
||||
/* 加载语言文件,加载公共模块。*/
|
||||
$lang = $app->loadLang('common');
|
||||
$common = $app->loadCommon();
|
||||
|
||||
/* 加载相应的lib文件,并设置超全局变量的引用。*/
|
||||
$app->loadClass('front', $static = true);
|
||||
$app->loadClass('filter', $static = true);
|
||||
$app->setSuperVars();
|
||||
|
||||
/* 检查是否已经是最新的版本。*/
|
||||
$config->installedVersion = $common->loadModel('setting')->getVersion();
|
||||
if(version_compare($config->version, $config->installedVersion) <= 0) die(header('location: index.php'));
|
||||
|
||||
/* 处理请求,验证权限,加载相应的模块。*/
|
||||
$app->parseRequest();
|
||||
$app->loadModule();
|
||||
Reference in New Issue
Block a user