* adjust the convert feature.
This commit is contained in:
@@ -144,8 +144,7 @@ $lang->user->menu->browse = array('link' => '用户管理|company|browse|', 'f
|
||||
|
||||
/* 后台管理菜单设置。*/
|
||||
$lang->admin->menu->browseCompany = array('link' => '公司管理|admin|browsecompany', 'subModule' => 'company');
|
||||
//$lang->admin->menu->convert = array('link' => '从其他系统导入|convert|index', 'subModule' => 'convert');
|
||||
$lang->admin->menu->upgrade = array('link' => '升级|upgrade|index', 'subModule' => 'upgrade');
|
||||
$lang->admin->menu->convert = array('link' => '从其他系统导入|convert|index', 'subModule' => 'convert');
|
||||
$lang->admin->menu->createCompany = array('link' => '新增公司|company|create', 'float' => 'right');
|
||||
$lang->convert->menu = $lang->admin->menu;
|
||||
$lang->upgrade->menu = $lang->admin->menu;
|
||||
|
||||
@@ -68,8 +68,8 @@ class convert extends control
|
||||
{
|
||||
$checkFunc = 'check' . $this->post->source;
|
||||
$this->view->header->title = $this->lang->convert->checkConfig;
|
||||
$this->view->source = $this->post->source;
|
||||
$this->view->checkResult = $this->fetch('convert', $checkFunc, "version={$this->post->version}");
|
||||
$this->view->source = $this->post->source;
|
||||
$this->view->checkResult = $this->fetch('convert', $checkFunc, "version={$this->post->version}");
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -78,12 +78,21 @@ class convert extends control
|
||||
{
|
||||
helper::import('./converter/bugfree.php');
|
||||
$converter = new bugfreeConvertModel();
|
||||
$checkResult['connectDB'] = $converter->connectDB();
|
||||
$checkResult['checkTables'] = $converter->checkTables();
|
||||
$checkResult['checkRoot'] = $converter->checkRoot();
|
||||
a($checkResult);
|
||||
$this->view->source = 'bugfree';
|
||||
$this->view->version = $version;
|
||||
|
||||
/* 分别检查数据库、表和安装路径。*/
|
||||
$checkResult['db'] = $converter->connectDB();
|
||||
if(is_object($checkResult['db'])) $checkResult['table'] = $converter->checkTables();
|
||||
$checkResult['root'] = $converter->checkRoot();
|
||||
|
||||
/* 计算检查结果。*/
|
||||
$result = 'pass';
|
||||
if(!is_object($checkResult['db']) or !$checkResult['table'] or !$checkResult['root']) $result = 'fail';
|
||||
|
||||
/* 赋值。*/
|
||||
$this->view->version = $version;
|
||||
$this->view->source = 'bugfree';
|
||||
$this->view->result = $result;
|
||||
$this->view->checkResult = $checkResult;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -91,7 +100,11 @@ class convert extends control
|
||||
public function execute()
|
||||
{
|
||||
$convertFunc = 'convert' . $this->post->source;
|
||||
$this->$convertFunc($this->post->version);
|
||||
$this->view->header->title = $this->lang->convert->execute;
|
||||
$this->view->source = $this->post->source;
|
||||
$this->view->executeResult = $this->fetch('convert', $convertFunc, "version={$this->post->version}");
|
||||
$this->display();
|
||||
|
||||
}
|
||||
|
||||
/* 转换BugFree。*/
|
||||
|
||||
@@ -1,47 +1,56 @@
|
||||
<?php
|
||||
class bugfreeConvertModel extends convertModel
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
parent::connectDB();
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>Tables<65><73>*/
|
||||
public function checkTables()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD>鰲װ·<D7B0><C2B7><EFBFBD><EFBFBD>*/
|
||||
public function checkInstallRoot()
|
||||
public function checkRoot()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ִ<><D6B4>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>*/
|
||||
public function execute()
|
||||
{
|
||||
$this->clear();
|
||||
$this->convertUser();
|
||||
}
|
||||
|
||||
public function convertUser()
|
||||
{
|
||||
$sql = "SELECT * FROM BugUser";
|
||||
$result = mysql_query($sql, $myLink);
|
||||
while($user = mysql_fetch_assoc($result))
|
||||
/* <20><>ѯ<EFBFBD><D1AF>ǰϵͳ<CFB5>д<EFBFBD><D0B4>ڵ<EFBFBD><DAB5>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
$activeUsers = $this->dao
|
||||
->dbh($this->sourceDBH)
|
||||
->select("{$this->app->company->id} AS company, username AS account, userpassword AS password, realname, email")
|
||||
->from('BugUser')->fetchAll('account');
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>*/
|
||||
$allUsers = $this->dao->select("distinct(username) AS account")->from('BugHistory')->fetchPairs();
|
||||
|
||||
/* <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ߡ<EFBFBD>*/
|
||||
foreach($allUsers as $key => $account)
|
||||
{
|
||||
extract($user);
|
||||
$sql = "INSERT INTO zt_user(company, id, account, password, realname, email) values('$companyID', $UserID, '$UserName', '$UserPassword', '$RealName', '$Email')";
|
||||
mysql_query($sql) or die(mysql_error());
|
||||
}
|
||||
$sql = "SELECT OpenedBy AS UserName FROM BugInfo GROUP BY OpenedBy";
|
||||
$result = mysql_query($sql, $myLink);
|
||||
while($user = mysql_fetch_assoc($result))
|
||||
{
|
||||
extract($user);
|
||||
$sql = "SELECT * FROM zt_user WHERE account = '$UserName'";
|
||||
if(!mysql_fetch_row(mysql_query($sql)))
|
||||
if(isset($activeUsers[$account]))
|
||||
{
|
||||
$sql = "INSERT INTO zt_user(company, account) values('$companyID', '$UserName')";
|
||||
mysql_query($sql) or die(mysql_error());
|
||||
$allUsers[$key] = $activeUsers[$account];
|
||||
}
|
||||
else
|
||||
{
|
||||
$allUsers[$key] = array('company' => $this->app->company->id, 'account' => $account, 'status' => 'delete');
|
||||
}
|
||||
}
|
||||
$sql = "INSERT INTO zt_user(company, account) values('$companyID', 'liyp')";
|
||||
mysql_query($sql) or die(mysql_error());
|
||||
|
||||
foreach($activeUsers as $account => $user) if(!isset($allUsers[$account])) $allUsers[$account] = $user;
|
||||
foreach($allUsers as $user) $this->dao->dbh($this->dbh)->insert(TABLE_USER)->data($user)->exec();
|
||||
}
|
||||
|
||||
public function convertProject()
|
||||
|
||||
@@ -56,8 +56,10 @@ $lang->convert->dbName = '%s使用的库';
|
||||
$lang->convert->dbPrefix = '%s表前缀';
|
||||
$lang->convert->installRoot= '%s安装的根目录';
|
||||
|
||||
$lang->convert->errorConnectDB = '数据库连接失败 ';
|
||||
$lang->convert->errorCreateDB = '数据库创建失败';
|
||||
$lang->convert->errorCreateTable = '创建表失败';
|
||||
$lang->convert->checkDB = '数据库';
|
||||
$lang->convert->checkTable = '表';
|
||||
$lang->convert->checkRoot = '安装路径';
|
||||
|
||||
$lang->convert->success = "安装成功!请删除convert.php,登录禅道管理系统,设置用户及分组!";
|
||||
$lang->convert->execute = '执行转换';
|
||||
|
||||
$lang->convert->errorConnectDB = '数据库连接失败 ';
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
<tr>
|
||||
<th><?php echo $lang->convert->dbHost;?></th>
|
||||
<td><?php echo html::input('dbHost', 'localhost');?></td>
|
||||
<th class='rowhead'><?php echo $lang->convert->checkDB;?></th>
|
||||
<td><?php is_object($checkResult['db']) ? printf($lang->convert->ok) : printf($lang->convert->fail);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->checkTable;?></th>
|
||||
<td><?php $checkResult['table'] === true ? printf($lang->convert->ok) : printf($lang->convert->fail);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->convert->checkRoot;?></th>
|
||||
<td><?php $checkResult['root'] === true ? printf($lang->convert->ok) : printf($lang->convert->fail);?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'>
|
||||
<?php
|
||||
if($result == 'pass')
|
||||
{
|
||||
echo html::hidden('source', $source) . html::hidden('version', $version) . html::submitButton($lang->convert->execute);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo html::commonButton($lang->goback, 'onclick=history.back();');
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php echo html::hidden('source', $source) . html::hidden('version', $version);?>
|
||||
|
||||
@@ -23,13 +23,18 @@
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<form method='post' action='<?php echo inlink('execute');?>'>
|
||||
<table align='center' class='table-5 f-14px'>
|
||||
<caption><?php echo $lang->convert->checkConfig . $lang->colon . strtoupper($source);?></caption>
|
||||
<?php echo $checkResult;?>
|
||||
<tr>
|
||||
<td colspan='2' class='a-center'><?php echo html::submitButton();?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo html::hidden('dbHost', $this->post->dbHost);
|
||||
echo html::hidden('dbPort', $this->post->dbPort);
|
||||
echo html::hidden('dbUser', $this->post->dbUser);
|
||||
echo html::hidden('dbPassword', $this->post->dbPassword);
|
||||
echo html::hidden('dbName', $this->post->dbName);
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
|
||||
32
trunk/module/convert/view/execute.html.php
Normal file
32
trunk/module/convert/view/execute.html.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* The html template file of execute method of convert 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 convert
|
||||
* @version $Id$
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<table align='center' class='table-5 f-14px'>
|
||||
<caption><?php echo $lang->convert->execute . $lang->colon . strtoupper($source);?></caption>
|
||||
<?php echo $executeResult;?>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
Reference in New Issue
Block a user