* finish task#808.

This commit is contained in:
chencongzhi520@gmail.com
2012-06-07 07:23:15 +00:00
parent 55b02649cb
commit 73de3bff2e
9 changed files with 131 additions and 1 deletions
+1 -1
View File
@@ -305,7 +305,7 @@ INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(5, 1, 2, 'dev2', 'e10adc3949ba59abbe56e057f20f883e', '开发乙', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 1, '192.168.0.8', 1338864116, '0');
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(6, 1, 2, 'dev3', 'e10adc3949ba59abbe56e057f20f883e', '开发丙', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 1, '192.168.0.8', 1338864187, '0');
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(7, 1, 3, 'tester1', 'e10adc3949ba59abbe56e057f20f883e', '测试甲', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 3, '192.168.0.8', 1338865739, '0');
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(8, 1, 0, 'tester2', 'e10adc3949ba59abbe56e057f20f883e', '测试乙', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 2, '192.168.0.8', 1338865450, '0');
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(8, 1, 3, 'tester2', 'e10adc3949ba59abbe56e057f20f883e', '测试乙', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 2, '192.168.0.8', 1338865450, '0');
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(9, 1, 3, 'tester3', 'e10adc3949ba59abbe56e057f20f883e', '测试丙', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 1, '192.168.0.8', 1338865125, '0');
INSERT INTO `zt_user` (`id`, `company`, `dept`, `account`, `password`, `realname`, `nickname`, `commiter`, `avatar`, `birthday`, `gender`, `email`, `msn`, `qq`, `yahoo`, `gtalk`, `wangwang`, `mobile`, `phone`, `address`, `zipcode`, `join`, `visits`, `ip`, `last`, `deleted`) VALUES(10, 1, 1, 'testManager', 'e10adc3949ba59abbe56e057f20f883e', '测试经理', '', '', '', '0000-00-00', 'm', '', '', '', '', '', '', '', '', '', '', '0000-00-00', 6, '192.168.0.8', 1338865842, '0');
+40
View File
@@ -116,4 +116,44 @@ class admin extends control
echo "Repairing TABLE: " . $result->Table . "\t" . $result->Msg_type . ":" . $result->Msg_text . "\n";
}
}
/**
* clear data.
*
* @access public
* @return void
*/
public function clearData()
{
if(!empty($_POST))
{
$this->confirmClearData();
}
$this->display();
}
/**
* Confirm clear data.
*
* @param string $confirm no|yes
* @access public
* @return void
*/
public function confirmClearData($confirm = 'no')
{
if($confirm == 'no')
{
die(js::confirm($this->lang->admin->confirmClearData, inlink('confirmClearData', "confirm=yes")));
}
else
{
$result = $this->admin->clearData();
if($result)
{
die(js::alert($this->lang->admin->clearDataSucceed));
}
die(js::alert($this->lang->admin->clearDataFailed));
}
}
}
+12
View File
@@ -18,6 +18,18 @@ $lang->admin->welcome = 'Welcome to ZenTaoPMS.';
$lang->admin->browseCompany = 'Browse Company';
$lang->admin->clearData = 'Clear Data';
$lang->admin->confirmClearData = 'Are you sure to clear data?';
$lang->admin->clearDataFailed = 'Failed to clear data!';
$lang->admin->clearDataSucceed = 'Succeed to clear data!';
$lang->admin->clearDataDesc = <<<EOT
<strong><font color='red'>Clear data is dangerous. Be sure to backup your database and other data files and sure nobody is using pms when importing.</font></strong>\n
The impact of clearing data:
1、Clearing data will have no effect on table company,table group,and table groupPriv.
2、If you have choosed import demo data when installing,then clearing data will delete the item where key equals showDemoUsers on config table, and delete all demo users on user table.
3、For others tables:clear all data.
EOT;
$lang->admin->info->caption = 'ZentaoPMS information';
$lang->admin->info->version = 'The current version of the system is %s,';
$lang->admin->info->links = 'You can visit the following link:';
+12
View File
@@ -18,6 +18,18 @@ $lang->admin->welcome = '欢迎使用禅道管理软件后台管理系统';
$lang->admin->browseCompany = '浏览公司';
$lang->admin->clearData = '清除数据';
$lang->admin->confirmClearData = '您确认要清楚数据吗?';
$lang->admin->clearDataFailed = '清除数据失败!';
$lang->admin->clearDataSucceed = '清除数据成功!';
$lang->admin->clearDataDesc = <<<EOT
<strong><font color='red'>清除数据存在一定的风险,清楚数据之前,我们强烈建议您备份数据库及相应的数据文件,并保证清楚数据的时候,没有其他人进行操作。</font></strong>\n
清除数据对数据库的影响如下:
1、清楚数据不会对company, group, groupPriv表进行操作。
2、如果安装的时候有导入demo数据,则会删除config表key=showDemoUsers的记录,并删除user表中的所有demo用户。
3、对于其他表则进行全部清除操作。
EOT;
$lang->admin->info->caption = '禅道系统信息';
$lang->admin->info->version = '当前系统的版本是%s,';
$lang->admin->info->links = '您可以访问以下链接:';
+42
View File
@@ -138,4 +138,46 @@ class adminModel extends model
$register->email = $this->app->user->email;
return $register;
}
/**
* Clear data.
*
* @access public
* @return void
*/
public function clearData()
{
$result = $this->dbh->query('SHOW TABLES')->fetchAll();
$showDemoUsers = $this->dao->select('value')->from(TABLE_CONFIG)->where('`key`')->eq('showDemoUsers')->fetch();
foreach($result as $item)
{
$table = current((array)$item);
if(strpos($table, 'company') !== false) continue;
if(strpos($table, 'group') !== false) continue;
if(strpos($table, 'user') !== false)
{
if($showDemoUsers)
{
$this->dao->delete()->from($table)
->where('account')->in(array('productManager', 'projectManager', 'testManager', 'dev1', 'dev2', 'dev3', 'tester1', 'tester2', 'tester3'))
->exec();
if(dao::isError()) return false;
}
continue;
}
if(strpos($table, 'config') !== false)
{
if($showDemoUsers)
{
$this->dao->delete()->from($table)
->where('`key`')->eq('showDemoUsers')
->exec();
if(dao::isError()) return false;
}
continue;
}
if(!$this->dbh->query("TRUNCATE TABLE `$table`")) return false;
}
return true;
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
/**
* The view file of admin module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Congzhi Chen <congzhi@cnezsoft.com>
* @package admin
* @version $Id: view.html.php 2568 2012-02-09 06:56:35Z shiyangyangwork@yahoo.cn $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<form method='post' target='hiddenwin'>
<table align='center' class='table-5'>
<caption><?php echo $lang->admin->clearData;?></caption>
<tr><td><?php echo nl2br($lang->admin->clearDataDesc);?></td></tr>
<tr><td class='a-center'><?php echo html::submitButton($lang->admin->clearData) . html::hidden('confirm', 'no');?></td></tr>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>
+1
View File
@@ -228,6 +228,7 @@ $lang->admin->menu->index = array('link' => 'Index|admin|index');
$lang->admin->menu->extension = array('link' => 'Extension|extension|browse', 'subModule' => 'extension');
$lang->admin->menu->editor = array('link' => 'Extension editor|editor|index', 'subModule' => 'editor');
$lang->admin->menu->mail = array('link' => 'ConfigEmail|mail|set', 'subModule' => 'mail');
$lang->admin->menu->clearData = array('link' => 'ClearData|admin|cleardata');
$lang->admin->menu->convert = array('link' => 'Import|convert|index', 'subModule' => 'convert');
$lang->admin->menu->trashes = array('link' => 'Trash|action|trash', 'subModule' => 'action');
$lang->convert->menu = $lang->admin->menu;
+1
View File
@@ -228,6 +228,7 @@ $lang->admin->menu->index = array('link' => '首页|admin|index');
$lang->admin->menu->extension = array('link' => '插件管理|extension|browse', 'subModule' => 'extension');
$lang->admin->menu->editor = array('link' => '扩展编辑器|editor|index', 'subModule' => 'editor');
$lang->admin->menu->mail = array('link' => 'Email配置|mail|set', 'subModule' => 'mail');
$lang->admin->menu->clearData = array('link' => '清除数据|admin|cleardata');
$lang->admin->menu->convert = array('link' => '从其他系统导入|convert|index', 'subModule' => 'convert');
$lang->admin->menu->trashes = array('link' => '回收站|action|trash', 'subModule' => 'action');
$lang->convert->menu = $lang->admin->menu;
+1
View File
@@ -369,6 +369,7 @@ class installModel extends model
$table = str_replace('zt_', $this->config->db->prefix, $table);
if(!$this->dbh->query($table)) return false;
}
$config->company = '1';
$config->owner = 'system';
$config->section = 'global';