fix mail-account backup; fix missing job description for admin-dashboard (outstanding tasks); avoid double backup-task insertion when customer presses refresh after scheduling the backup-job

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2016-05-05 08:23:46 +02:00
parent ae01f2cdb9
commit 2210d3de12
6 changed files with 26 additions and 14 deletions

View File

@@ -525,6 +525,17 @@ if ($page == 'overview') {
if ($action == '') { if ($action == '') {
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup");
// check whether there is a backup-job for this customer
$sel_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_TASKS."` WHERE `type` = '20'");
Database::pexecute($sel_stmt);
while ($entry = $sel_stmt->fetch())
{
$data = unserialize($entry['data']);
if ($data['customerid'] == $userinfo['customerid']) {
standard_error('customerhasongoingbackupjob');
}
}
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
if (! $_POST['path']) { if (! $_POST['path']) {
@@ -566,16 +577,6 @@ if ($page == 'overview') {
standard_success('backupscheduled'); standard_success('backupscheduled');
} else { } else {
// check whether there is a backup-job for this customer
$sel_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_TASKS."` WHERE `type` = '20'");
Database::pexecute($sel_stmt);
while ($entry = $sel_stmt->fetch())
{
$data = unserialize($entry['data']);
if ($data['customerid'] == $userinfo['customerid']) {
standard_error('customerhasongoingbackupjob');
}
}
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php'; $backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
$backup_form = htmlform::genHTMLForm($backup_data); $backup_form = htmlform::genHTMLForm($backup_data);

View File

@@ -129,7 +129,7 @@ while ($fName = readdir($lockDirHandle)) {
// //
fwrite($debugHandler, 'Previous cronjob didn\'t exit clean. PID: ' . $check_pid . "\n"); fwrite($debugHandler, 'Previous cronjob didn\'t exit clean. PID: ' . $check_pid . "\n");
fwrite($debugHandler, 'Removing lockfile: ' . $lockdir . $fName . "\n"); fwrite($debugHandler, 'Removing lockfile: ' . $lockdir . $fName . "\n");
unlink($lockdir . $fName); @unlink($lockdir . $fName);
} else { } else {
// Result: A Cronscript with this pid // Result: A Cronscript with this pid

View File

@@ -82,13 +82,13 @@ function createCustomerBackup($data = null, $customerdocroot = null, &$cronlog)
$tar_file_list = ""; $tar_file_list = "";
$mail_homedir = ""; $mail_homedir = "";
while ($row = $sel_stmt->fetch()) { while ($row = $sel_stmt->fetch()) {
$tar_file_list .= "./".$row['maildir'] . " "; $tar_file_list .= escapeshellarg("./".$row['maildir']) . " ";
$mail_homedir = $row['homedir']; $mail_homedir = $row['homedir'];
} }
if (! empty($tar_file_list)) { if (! empty($tar_file_list)) {
$cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar cfvz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' ' . escapeshellarg(trim($tar_file_list)).' -C '.escapeshellarg($mail_homedir)); $cronlog->logAction(CRON_ACTION, LOG_DEBUG, 'shell> tar cfvz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' -C '.escapeshellarg($mail_homedir) . ' ' . trim($tar_file_list));
safe_exec('tar cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' ' . escapeshellarg(trim($tar_file_list)).' -C '.escapeshellarg($mail_homedir)); safe_exec('tar cfz ' . escapeshellarg(makeCorrectFile($tmpdir . '/mail/' . $data['loginname'] . '-mail.tar.gz')) . ' -C '.escapeshellarg($mail_homedir) . ' ' . trim($tar_file_list));
$create_backup_tar_data .= './mail '; $create_backup_tar_data .= './mail ';
} }
} }

View File

@@ -108,6 +108,15 @@ function getOutstandingTasks() {
elseif ($row['type'] == '10') { elseif ($row['type'] == '10') {
$task_desc = $lng['tasks']['diskspace_set_quota']; $task_desc = $lng['tasks']['diskspace_set_quota'];
} }
// deleting user-files
elseif ($row['type'] == '20') {
$loginname = '';
if (is_array($row['data'])) {
$loginname = $row['data']['loginname'];
}
$task_desc = $lng['tasks']['backup_customerfiles'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
}
// re-generating of cron.d-file // re-generating of cron.d-file
elseif ($row['type'] == '99') { elseif ($row['type'] == '99') {
$task_desc = $lng['tasks']['regenerating_crond']; $task_desc = $lng['tasks']['regenerating_crond'];

View File

@@ -1988,3 +1988,4 @@ $lng['serversettings']['backupenabled']['title'] = "Enable backup for customers"
$lng['serversettings']['backupenabled']['description'] = "If activated, the customer will be able to schedule backup jobs (cron-backup) which generates an archive within his docroot (subdirectory chosable by customer)"; $lng['serversettings']['backupenabled']['description'] = "If activated, the customer will be able to schedule backup jobs (cron-backup) which generates an archive within his docroot (subdirectory chosable by customer)";
$lng['extras']['path_protection_label'] = '<strong class="red">Important</strong>'; $lng['extras']['path_protection_label'] = '<strong class="red">Important</strong>';
$lng['extras']['path_protection_info'] = '<strong class="red">We strongly recommend protecting the given path, see "Extras" -> "Directory protection"</strong>'; $lng['extras']['path_protection_info'] = '<strong class="red">We strongly recommend protecting the given path, see "Extras" -> "Directory protection"</strong>';
$lng['tasks']['backup_customerfiles'] = 'Backup job for customer %loginname%';

View File

@@ -1641,3 +1641,4 @@ $lng['serversettings']['backupenabled']['title'] = "Backup für Kunden aktiviere
$lng['serversettings']['backupenabled']['description'] = "Wenn dies aktiviert ist, kann der Kunde Sicherungen planen (cron-backup) welche ein Archiv in sein Heimatverzeichnis ablegt (Unterordner vom Kunden wählbar)"; $lng['serversettings']['backupenabled']['description'] = "Wenn dies aktiviert ist, kann der Kunde Sicherungen planen (cron-backup) welche ein Archiv in sein Heimatverzeichnis ablegt (Unterordner vom Kunden wählbar)";
$lng['extras']['path_protection_label'] = '<strong class="red">Wichtig</strong>'; $lng['extras']['path_protection_label'] = '<strong class="red">Wichtig</strong>';
$lng['extras']['path_protection_info'] = '<strong class="red">Wir raten dringend dazu den angegebenen Pfad zu schützen, siehe "Extras" -> "Verzeichnisschutz"</strong>'; $lng['extras']['path_protection_info'] = '<strong class="red">Wir raten dringend dazu den angegebenen Pfad zu schützen, siehe "Extras" -> "Verzeichnisschutz"</strong>';
$lng['tasks']['backup_customerfiles'] = 'Datensicherung für Kunde %loginname%';