diff --git a/trunk/module/common/lang/zh-cn.php b/trunk/module/common/lang/zh-cn.php index 90ee44f049..84ddc8923b 100644 --- a/trunk/module/common/lang/zh-cn.php +++ b/trunk/module/common/lang/zh-cn.php @@ -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; diff --git a/trunk/module/convert/control.php b/trunk/module/convert/control.php index f3267a1735..1ed348eb49 100644 --- a/trunk/module/convert/control.php +++ b/trunk/module/convert/control.php @@ -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。*/ diff --git a/trunk/module/convert/converter/bugfree.php b/trunk/module/convert/converter/bugfree.php index d75d8186c3..2bd1580883 100644 --- a/trunk/module/convert/converter/bugfree.php +++ b/trunk/module/convert/converter/bugfree.php @@ -1,47 +1,56 @@ clear(); + $this->convertUser(); } public function convertUser() { - $sql = "SELECT * FROM BugUser"; - $result = mysql_query($sql, $myLink); - while($user = mysql_fetch_assoc($result)) + /* ѯǰϵͳдڵû*/ + $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'); + + /* ֹû*/ + $allUsers = $this->dao->select("distinct(username) AS account")->from('BugHistory')->fetchPairs(); + + /* ϲߡ*/ + 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() diff --git a/trunk/module/convert/lang/zh-cn.php b/trunk/module/convert/lang/zh-cn.php index fdd23d956e..e5ae2bccdc 100644 --- a/trunk/module/convert/lang/zh-cn.php +++ b/trunk/module/convert/lang/zh-cn.php @@ -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 = '数据库连接失败 '; diff --git a/trunk/module/convert/view/checkbugfree.html.php b/trunk/module/convert/view/checkbugfree.html.php index 127732937a..3f63e6753d 100644 --- a/trunk/module/convert/view/checkbugfree.html.php +++ b/trunk/module/convert/view/checkbugfree.html.php @@ -1,5 +1,26 @@ - convert->dbHost;?> - + convert->checkDB;?> + convert->ok) : printf($lang->convert->fail);?> + + + convert->checkTable;?> + convert->ok) : printf($lang->convert->fail);?> + + + convert->checkRoot;?> + convert->ok) : printf($lang->convert->fail);?> + + + + convert->execute); + } + else + { + echo html::commonButton($lang->goback, 'onclick=history.back();'); + } +?> + - diff --git a/trunk/module/convert/view/checkconfig.html.php b/trunk/module/convert/view/checkconfig.html.php index 5a6975d780..288df2b680 100644 --- a/trunk/module/convert/view/checkconfig.html.php +++ b/trunk/module/convert/view/checkconfig.html.php @@ -23,13 +23,18 @@ ?>
+
'> - - -
convert->checkConfig . $lang->colon . strtoupper($source);?>
+ 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); + ?>
diff --git a/trunk/module/convert/view/execute.html.php b/trunk/module/convert/view/execute.html.php new file mode 100644 index 0000000000..d6cfd2ffa7 --- /dev/null +++ b/trunk/module/convert/view/execute.html.php @@ -0,0 +1,32 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package convert + * @version $Id$ + */ +?> + +
+ + + +
convert->execute . $lang->colon . strtoupper($source);?>
+ +
+