* finish task #2262.

This commit is contained in:
wangyidong
2015-05-14 09:58:16 +08:00
parent d569700b40
commit b693b89d4c
6 changed files with 80 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
<?php
$config->backup->holdDays = 14;
+29
View File
@@ -112,6 +112,17 @@ class backup extends control
$this->backup->addFileHeader($this->backupPath . $fileName . '.file.zip.php');
}
/* Delete expired backup. */
$sqlFiles = glob("{$this->backupPath}*.sql.php");
if(!empty($sqlFiles))
{
$time = time();
foreach($sqlFiles as $file)
{
if($time - filemtime($file) > $this->config->backup->holdDays * 24 * 3600) unlink($file);
}
}
if($reload == 'yes')
{
echo js::alert($this->lang->backup->success->backup);
@@ -192,4 +203,22 @@ class backup extends control
die(js::reload('parent'));
}
/**
* Change hold days.
*
* @access public
* @return void
*/
public function change()
{
if($_POST)
{
$data = fixer::input('post')->get();
$this->loadModel('setting')->setItem('system.backup.holdDays', $data->holdDays);
die(js::reload('parent.parent'));
}
$this->display();
}
}
+3
View File
@@ -5,6 +5,8 @@ $lang->backup->history = 'History';
$lang->backup->delete = 'Delete';
$lang->backup->backup = 'Backup';
$lang->backup->restore = 'Restore';
$lang->backup->change = 'Change hold days';
$lang->backup->changeAB = 'change';
$lang->backup->name = 'Name';
$lang->backup->time = 'Time';
@@ -14,6 +16,7 @@ $lang->backup->size = 'Size';
$lang->backup->waitting = '<span id="backupType"></span> is in progress, please wait...';
$lang->backup->confirmDelete = 'Are you sure delete this backup?';
$lang->backup->confirmRestore = 'Are you sure restore this backup?';
$lang->backup->holdDays = 'Keep backup copy of the recent %s days';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = 'Success backup!';
+3
View File
@@ -5,6 +5,8 @@ $lang->backup->history = '备份历史';
$lang->backup->delete = '删除备份';
$lang->backup->backup = '备份';
$lang->backup->restore = '还原';
$lang->backup->change = '修改保留时间';
$lang->backup->changeAB = '修改';
$lang->backup->name = '文件名称';
$lang->backup->time = '备份时间';
@@ -14,6 +16,7 @@ $lang->backup->size = '大小';
$lang->backup->waitting = '<span id="backupType"></span>正在进行中,请稍候...';
$lang->backup->confirmDelete = '是否删除备份?';
$lang->backup->confirmRestore = '是否还原该备份?';
$lang->backup->holdDays = '备份保留最近 %s 天';
$lang->backup->success = new stdclass();
$lang->backup->success->backup = '备份成功!';
+35
View File
@@ -0,0 +1,35 @@
<?php
/**
* The change view file of backup module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv11.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package backup
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<div id='titlebar'>
<div class='heading'>
<span class='prefix'><?php echo html::icon($lang->icons['edit']);?></span>
<strong><?php echo $lang->backup->change;?></strong>
</div>
</div>
<form class='form-condensed' method='post' target='hiddenwin' style='padding: 30px 5%'>
<table class='w-p100'>
<tr>
<td>
<div class='input-group'>
<?php echo html::input('holdDays', $config->backup->holdDays, "class='form-control'");?>
<strong class='input-group-addon'><?php echo $lang->day;?></strong>
</div>
</td>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
<?php include '../../common/view/footer.lite.html.php';?>
+8
View File
@@ -57,6 +57,14 @@
<?php endforeach;?>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan='4'>
<?php printf($lang->backup->holdDays, $config->backup->holdDays)?>
<?php if(common::hasPriv('backup', 'change')) echo html::a(inlink('change'), $lang->backup->changeAB, '', "class='iframe' data-width='300'");?>
</td>
</tr>
</tfoot>
</table>
</div>
<div class="modal fade" id="waitting" tabindex="-1" role="dialog" aria-hidden="true">