Skip to content

Commit

Permalink
show scheduled backup and give customer the possiblity to abort the job
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
  • Loading branch information
d00p committed May 22, 2016
1 parent d97957e commit b51f082
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
27 changes: 26 additions & 1 deletion customer_extras.php
Expand Up @@ -522,17 +522,29 @@

if (Settings::Get('system.backupenabled') == 1)
{
if ($action == 'abort' && isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob");
$entry = isset($_POST['backup_job_entry']) ? (int)$_POST['backup_job_entry'] : 0;
if ($entry > 0) {
$del_stmt = Database::prepare("DELETE FROM `".TABLE_PANEL_TASKS."` WHERE `id` = :tid");
Database::pexecute($del_stmt, array('tid' => $entry));
standard_success('backupaborted');
}
redirectTo($filename, array('page' => $page, 'action' => '', 's' => $s));
}
if ($action == '') {
$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);
$existing_backupJob = null;
while ($entry = $sel_stmt->fetch())
{
$data = unserialize($entry['data']);
if ($data['customerid'] == $userinfo['customerid']) {
standard_error('customerhasongoingbackupjob');
$existing_backupJob = $entry;
break;
}
}

Expand Down Expand Up @@ -577,11 +589,24 @@
standard_success('backupscheduled');
} else {

if (!empty($existing_backupJob)) {
$action = "abort";
$row = unserialize($entry['data']);
$row['path'] = makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['destdir']));
$row['backup_web'] = ($row['backup_web'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
}
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
$backup_form = htmlform::genHTMLForm($backup_data);
$title = $backup_data['backup']['title'];
$image = $backup_data['backup']['image'];

if (!empty($existing_backupJob)) {
// overwrite backup_form after we took everything from it we needed
eval("\$backup_form = \"" . getTemplate("extras/backup_listexisting") . "\";");
}
eval("echo \"" . getTemplate("extras/backup") . "\";");
}
}
Expand Down
1 change: 1 addition & 0 deletions lng/english.lng.php
Expand Up @@ -1981,6 +1981,7 @@
$lng['extras']['backup_dbs'] = 'Backup databases';
$lng['error']['customerhasongoingbackupjob'] = 'There is already a backup job waiting to be processed, please be patient.';
$lng['success']['backupscheduled'] = 'Your backup job has been scheduled. Please wait for it to be processed';
$lng['success']['backupaborted'] = 'Your scheduled backup has been cancelled';
$lng['crondesc']['cron_backup'] = 'Process backup jobs';
$lng['error']['backupfunctionnotenabled'] = 'The backup function is not enabled';
$lng['serversettings']['backupenabled']['title'] = "Enable backup for customers";
Expand Down
1 change: 1 addition & 0 deletions lng/german.lng.php
Expand Up @@ -1634,6 +1634,7 @@
$lng['extras']['backup_dbs'] = 'Datenbanken sichern';
$lng['error']['customerhasongoingbackupjob'] = 'Es gibt noch einen austehenden Backup-Job. Bitte haben Sie etwas Geduld.';
$lng['success']['backupscheduled'] = 'Ihre Sicherung wurde erfolgreich geplant. Bitte warten Sie nun, bis diese abgearbeitet wurde.';
$lng['success']['backupaborted'] = 'Die geplante Sicherung wurde abgebrochen';
$lng['crondesc']['cron_backup'] = 'Ausstehende Sicherungen erstellen';
$lng['error']['backupfunctionnotenabled'] = 'Die Sicherungs-Funktion is nicht aktiviert';
$lng['serversettings']['backupenabled']['title'] = "Backup für Kunden aktivieren";
Expand Down
9 changes: 9 additions & 0 deletions templates/Sparkle/customer/extras/backup.tpl
Expand Up @@ -7,6 +7,15 @@ $header
</h2>
</header>

<if !empty($existing_backupJob)>
<div class="messagewrapperfull">
<div class="warningcontainer bradius">
<div class="warningtitle">{$lng['admin']['warning']}</div>
<div class="warning">{$lng['error']['customerhasongoingbackupjob']}</div>
</div>
</div>
</if>

<section>

<form action="{$linker->getLink(array('section' => 'extras'))}" method="post" enctype="application/x-www-form-urlencoded">
Expand Down
26 changes: 26 additions & 0 deletions templates/Sparkle/customer/extras/backup_listexisting.tpl
@@ -0,0 +1,26 @@
<thead>
<tr>
<th>{$lng['panel']['path']}</th>
<th>{$lng['extras']['backup_web']}</th>
<th>{$lng['extras']['backup_mail']}</th>
<th>{$lng['extras']['backup_dbs']}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{$row['path']}</td>
<td>{$row['backup_web']}</td>
<td>{$row['backup_mail']}</td>
<td>{$row['backup_dbs']}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
<p>
<input type="hidden" name="backup_job_entry" value="{$existing_backupJob['id']}" />
<input type="submit" value="{$lng['panel']['abort']}" class="nobutton" />
</p>
</td>
</tr>
</tfoot>

0 comments on commit b51f082

Please sign in to comment.