* finish task#808.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:';
|
||||
|
||||
@@ -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 = '您可以访问以下链接:';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+21
@@ -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';?>
|
||||
Reference in New Issue
Block a user