Skip to content

Commit 4ad6849

Browse files
author
Till Brehm
committed
Merge branch 'master' of /home/git/repositories/florian030/ispconfig3
2 parents 0b50f8f + 2e14530 commit 4ad6849

File tree

12 files changed

+534
-3
lines changed

12 files changed

+534
-3
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE `mail_backup` (
2+
`backup_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
3+
`server_id` int(10) unsigned NOT NULL,
4+
`parent_domain_id` int(10) unsigned NOT NULL,
5+
`mailuser_id` int(10) unsigned NOT NULL,
6+
`backup_mode` varchar(64) NOT NULL DEFAULT '',
7+
`tstamp` int(10) unsigned NOT NULL,
8+
`filename` varchar(255) NOT NULL,
9+
`filesize` VARCHAR(10) NOT NULL,
10+
PRIMARY KEY (`backup_id`)
11+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
12+
13+
ALTER TABLE `mail_user` ADD `backup_interval` VARCHAR( 255 ) NOT NULL ;
14+
ALTER TABLE `mail_user` ADD `backup_copies` INT NOT NULL DEFAULT '1';

install/sql/ispconfig3.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,24 @@ CREATE TABLE `mail_access` (
651651

652652
-- --------------------------------------------------------
653653

654+
--
655+
-- Table structure for table `mail_backup`
656+
--
657+
658+
CREATE TABLE `mail_backup` (
659+
`backup_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
660+
`server_id` int(10) unsigned NOT NULL,
661+
`parent_domain_id` int(10) unsigned NOT NULL,
662+
`mailuser_id` int(10) unsigned NOT NULL,
663+
`backup_mode` varchar(64) NOT NULL DEFAULT '',
664+
`tstamp` int(10) unsigned NOT NULL,
665+
`filename` varchar(255) NOT NULL,
666+
`filesize` VARCHAR(10) NOT NULL,
667+
PRIMARY KEY (`backup_id`)
668+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
669+
670+
-- --------------------------------------------------------
671+
654672
--
655673
-- Table structure for table `mail_content_filter`
656674
--
@@ -863,6 +881,8 @@ CREATE TABLE `mail_user` (
863881
`disablelda` enum('n','y') NOT NULL default 'n',
864882
`disabledoveadm` enum('n','y') NOT NULL default 'n',
865883
`last_quota_notification` date NULL default NULL,
884+
`backup_interval` VARCHAR( 255 ) NOT NULL,
885+
`backup_copies` INT NOT NULL DEFAULT '1',
866886
PRIMARY KEY (`mailuser_id`),
867887
KEY `server_id` (`server_id`,`email`),
868888
KEY `email_access` (`email`,`access`)
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2013, Florian Schaal, info@schaal-24.de
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
class plugin_backuplist_mail extends plugin_base {
32+
33+
var $module;
34+
var $form;
35+
var $tab;
36+
var $record_id;
37+
var $formdef;
38+
var $options;
39+
40+
function onShow() {
41+
global $app;
42+
$listTpl = new tpl;
43+
$listTpl->newTemplate('templates/mail_user_backup_list.htm');
44+
45+
//* Loading language file
46+
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_mail_backup_list.lng";
47+
include($lng_file);
48+
$listTpl->setVar($wb);
49+
50+
$message = '';
51+
$error = '';
52+
53+
if(isset($_GET['backup_action'])) {
54+
$backup_id = $app->functions->intval($_GET['backup_id']);
55+
/*
56+
if($_GET['backup_action'] == 'download' && $backup_id > 0) {
57+
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'";
58+
$tmp = $app->db->queryOneRecord($sql);
59+
if($tmp['number'] == 0) {
60+
$message .= $wb['download_info_txt'];
61+
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
62+
"VALUES (".
63+
(int)$this->form->dataRecord['server_id'] . ", " .
64+
time() . ", " .
65+
"'backup_download', " .
66+
"'".$backup_id."', " .
67+
"'pending', " .
68+
"''" .
69+
")";
70+
$app->db->query($sql);
71+
} else {
72+
$error .= $wb['download_pending_txt'];
73+
}
74+
}
75+
*/
76+
if($_GET['backup_action'] == 'restore' && $backup_id > 0) {
77+
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'";
78+
$tmp = $app->db->queryOneRecord($sql);
79+
if($tmp['number'] == 0) {
80+
$message .= $wb['restore_info_txt'];
81+
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
82+
"VALUES (".
83+
(int)$this->form->dataRecord['server_id'] . ", " .
84+
time() . ", " .
85+
"'backup_restore', " .
86+
"'".$backup_id."', " .
87+
"'pending', " .
88+
"''" .
89+
")";
90+
$app->db->query($sql);
91+
} else {
92+
$error .= $wb['restore_pending_txt'];
93+
}
94+
}
95+
}
96+
97+
//* Get the data
98+
$sql = "SELECT * FROM mail_backup WHERE mailuser_id = ".$this->form->id." ORDER BY tstamp DESC";
99+
$records = $app->db->queryAllRecords($sql);
100+
$bgcolor = "#FFFFFF";
101+
if(is_array($records)) {
102+
foreach($records as $rec) {
103+
// Change of color
104+
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
105+
$rec["bgcolor"] = $bgcolor;
106+
$rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']);
107+
$rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])];
108+
$records_new[] = $rec;
109+
}
110+
}
111+
112+
$listTpl->setLoop('records',@$records_new);
113+
114+
$listTpl->setVar('parent_id',$this->form->id);
115+
$listTpl->setVar('msg',$message);
116+
$listTpl->setVar('error',$error);
117+
118+
// Setting Returnto information in the session
119+
$list_name = 'backup_list';
120+
$_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id;
121+
$_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
122+
$_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
123+
$_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
124+
$_SESSION["s"]["form"]["return_to"] = $list_name;
125+
return $listTpl->grab();
126+
} // end function
127+
} // end class
128+
129+
?>

interface/web/mail/form/mail_user.tform.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,5 +346,39 @@
346346
);
347347
}
348348

349+
//* Backup
350+
$form["tabs"]['backup'] = array (
351+
'title' => "Backup",
352+
'width' => 100,
353+
'template' => "templates/mail_user_backup.htm",
354+
'readonly' => false,
355+
'fields' => array (
356+
##################################
357+
# Begin Datatable fields
358+
##################################
359+
'backup_interval' => array (
360+
'datatype' => 'VARCHAR',
361+
'formtype' => 'SELECT',
362+
'default' => '',
363+
'value' => array('none' => 'no_backup_txt', 'daily' => 'daily_backup_txt', 'weekly' => 'weekly_backup_txt', 'monthly' => 'monthly_backup_txt')
364+
),
365+
'backup_copies' => array (
366+
'datatype' => 'INTEGER',
367+
'formtype' => 'SELECT',
368+
'default' => '',
369+
'value' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10')
370+
),
371+
##################################
372+
# ENDE Datatable fields
373+
##################################
374+
),
375+
'plugins' => array (
376+
'backup_records' => array (
377+
'class' => 'plugin_backuplist_mail',
378+
'options' => array(
379+
)
380+
)
381+
)
382+
);
349383

350384
?>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
$wb['list_head_txt'] = 'Existing backups';
3+
$wb['date_txt'] = 'Date';
4+
$wb['backup_type_txt'] = 'Type';
5+
$wb['filename_txt'] = 'Backup file';
6+
$wb['restore_backup_txt'] = 'Restore';
7+
$wb['restore_info_txt'] = 'Restore of the backup has been started. This action takes several minutes to be completed.';
8+
$wb['restore_confirm_txt'] = 'Restoring may overwrite existing files in your mailbox. Do you really want to restore this backup?';
9+
$wb['download_pending_txt'] = 'There is already a pending backup download job.';
10+
$wb['restore_pending_txt'] = 'There is already a pending backup restore job.';
11+
$wb['filesize_txt'] = 'Filesize';
12+
?>

interface/web/mail/lib/lang/en_mail_user.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ $wb['generate_password_txt'] = 'Generate Password';
4747
$wb['repeat_password_txt'] = 'Repeat Password';
4848
$wb['password_mismatch_txt'] = 'The passwords do not match.';
4949
$wb['password_match_txt'] = 'The passwords do match.';
50+
$wb["backup_interval_txt"] = 'Backup interval';
51+
$wb["backup_copies_txt"] = 'Number of backup copies';
52+
$wb['no_backup_txt'] = 'No backup';
53+
$wb['daily_backup_txt'] = 'Daily';
54+
$wb['weekly_backup_txt'] = 'Weekly';
55+
$wb['monthly_backup_txt'] = 'Monthly';
5056
?>

interface/web/mail/mail_user_edit.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@ function onAfterUpdate() {
319319

320320
} // end if email addess changed
321321

322+
//* Change backup options when user mail backup options have been changed
323+
if(isset($this->dataRecord['backup_interval']) && ($this->dataRecord['backup_interval'] != $this->oldDataRecord['backup_interval'] || $this->dataRecord['backup_copies'] != $this->oldDataRecord['backup_copies'])) {
324+
$backup_interval = $this->dataRecord['backup_interval'];
325+
$backup_copies = $this->dataRecord['backup_copies'];
326+
$app->db->datalogUpdate('mail_user', "backup_interval = '$backup_interval', backup_copies = '$backup_copies'", 'mailuser_id', $rec['mailuser_id']);
327+
unset($backup_copies);
328+
unset($backup_interval);
329+
} // end if backup options changed
330+
322331
}
323332

324333
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<h2><tmpl_var name="list_head_txt"></h2>
2+
<p><tmpl_var name="list_desc_txt"></p>
3+
4+
<tmpl_if name="config_error_msg">
5+
<div style="background: #ffdfdf; border: 1px solid #df7d7d; border-width: 1px 0; margin: 1.5em 0 1.5em 0; padding: 7px;">
6+
<p style="font-face:bold">{tmpl_var name='configuration_error_txt'}</p>
7+
<div>
8+
<div style="float:left;width:150px;">{tmpl_var name='config_error_tstamp'} :&nbsp;</div><div style="padding-left:150px;">{tmpl_var name='config_error_msg'}</div>
9+
</div>
10+
</div>
11+
</tmpl_if>
12+
13+
<div class="panel panel_mail_user">
14+
15+
<div class="pnl_formsarea">
16+
<fieldset class="inlineLabels"><legend>Backup</legend>
17+
<div class="ctrlHolder">
18+
<label for="backup_interval">{tmpl_var name='backup_interval_txt'}</label>
19+
<select name="backup_interval" id="backup_interval" class="selectInput">
20+
{tmpl_var name='backup_interval'}
21+
</select>
22+
</div>
23+
<div class="ctrlHolder">
24+
<label for="backup_copies">{tmpl_var name='backup_copies_txt'}</label>
25+
<select name="backup_copies" id="backup_copies" class="selectInput">
26+
{tmpl_var name='backup_copies'}
27+
</select>
28+
</div>
29+
</fieldset>
30+
{tmpl_var name='backup_records'}
31+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
32+
33+
<div class="buttonHolder buttons">
34+
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','mail/mail_user_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
35+
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('mail/mail_user_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
36+
</div>
37+
</div>
38+
39+
</div>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<tmpl_if name="msg">
2+
<div id="OKMsg"><p><tmpl_var name="msg"></p></div>
3+
</tmpl_if>
4+
<tmpl_if name="error">
5+
<div id="errorMsg"><h3>ERROR</h3><ol><tmpl_var name="error"></ol></div>
6+
</tmpl_if>
7+
<h3><tmpl_var name="list_head_txt"></h3>
8+
9+
<div class="panel panel_list_mail_backup">
10+
11+
<div class="pnl_listarea">
12+
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
13+
<table class="list">
14+
<thead>
15+
<tr class="caption">
16+
<th class="tbl_col_date" scope="col"><tmpl_var name="date_txt"></th>
17+
<th class="tbl_col_filename" scope="col"><tmpl_var name="filename_txt"></th>
18+
<th class="tbl_col_filename" scope="col"><tmpl_var name="filesize_txt"></th>
19+
<th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
<tmpl_loop name="records">
24+
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
25+
<td class="tbl_col_date">{tmpl_var name="date"}</td>
26+
<td class="tbl_col_filename">{tmpl_var name="filename"}</td>
27+
<td class="tbl_col_filesize">{tmpl_var name="filesize"}</td>
28+
<td class="tbl_col_buttons">
29+
<div class="buttons">
30+
<button class="button iconstxt icoRestore" type="button" onclick="confirm_action('mail/mail_user_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=restore&backup_id={tmpl_var name='backup_id'}','{tmpl_var name='restore_confirm_txt'}');"><span>{tmpl_var name="restore_backup_txt"}</span></button>
31+
<!-- <button class="button iconstxt icoDownload" type="button" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=download&backup_id={tmpl_var name='backup_id'}');"><span>{tmpl_var name="download_backup_txt"}</span></button>
32+
-->
33+
</div>
34+
</td>
35+
</tr>
36+
</tmpl_loop>
37+
<tmpl_unless name="records">
38+
<tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
39+
<td colspan="4">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
40+
</tr>
41+
</tmpl_unless>
42+
</tbody>
43+
</table>
44+
</fieldset>
45+
</div>
46+
47+
</div>

server/lib/classes/cron.d/500-backup.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function onRunJob() {
7272
chmod(escapeshellcmd($backup_dir), $backup_dir_permissions);
7373
}
7474

75-
$sql = "SELECT * FROM web_domain WHERE server_id = '".$conf['server_id']."' AND (type = 'vhost' OR type = 'vhostsubdomain') AND backup_interval != 'none'";
75+
$sql = "SELECT * FROM web_domain WHERE server_id = '".$conf['server_id']."' AND (type = 'vhost' OR type = 'vhostsubdomain')";
7676
$records = $app->db->queryAllRecords($sql);
7777
if(is_array($records)) {
7878
foreach($records as $rec) {

0 commit comments

Comments
 (0)