12
12
# You should have received a copy of the GNU General Public License
13
13
# along with this program; if not, write to the Free Software
14
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
package EBox::CGI::SysInfo::ConfirmBackup;
18
package EBox::CGI::SysInfo::ConfirmBackup;
21
19
use base 'EBox::CGI::ClientBase';
30
28
sub new # (error=?, msg=?, cgi=?)
33
my $self = $class->SUPER::new('title' => __('Configuration Backup'),
34
'template' => '/confirm-backup.mas',
38
$self->{errorchain} = "SysInfo/Backup";
31
my $self = $class->SUPER::new('title' => __('Configuration Backup'),
32
'template' => '/confirm-backup.mas',
34
$self->{errorchain} = "SysInfo/Backup";
44
40
sub requiredParameters
48
44
if ($self->param('download.x')) {
49
45
return [qw(id download.x download.y)];
51
elsif ($self->param('delete.x')) {
46
} elsif ($self->param('delete.x')) {
52
47
return [qw(id delete.x delete.y)];
54
elsif ($self->param('restoreFromId.x')) {
48
} elsif ($self->param('delete')) {
49
return [qw(id delete)];
50
} elsif ($self->param('restoreFromId.x')) {
55
51
return [qw(restoreFromId.x restoreFromId.y id)];
57
elsif ($self->param('restoreFromFile')) {
52
} elsif ($self->param('restoreFromId')) {
53
return [qw(restoreFromId id)];
54
} elsif ($self->param('restoreFromFile')) {
58
55
return [qw(restoreFromFile backupfile)];
65
61
sub optionalParameters
67
return ['download', 'delete', 'restoreFromId'];
63
return ['download', 'delete', 'popup', 'alreadyUploaded'];
82
77
my $actionSub = $self->can($actionParam . 'Action');
83
78
my ($backupAction, $backupActionText, $backupDetails) = $actionSub->($self);
84
79
$self->{params} = [action => $backupAction, actiontext => $backupActionText, backup => $backupDetails];
80
if ($self->param('popup')) {
81
push @{ $self->{params} }, (popup => 1);
91
89
$self->{redirect} = "SysInfo/Backup";
122
120
return ('restoreFromId', __('Restore'), $self->backupDetailsFromId());
128
123
sub restoreFromFileAction
132
my $filename = $self->upload('backupfile');
128
if ($self->param('alreadyUploaded')) {
129
$filename = $self->param('backupfile');
131
$filename = $self->upload('backupfile');
134
135
my $details = $self->backupDetailsFromFile($filename);
150
147
my $id = $self->param('id');
151
148
if ($id =~ m{[./]}) {
152
149
throw EBox::Exceptions::External(
153
__("The input contains invalid characters"));
150
__("The input contains invalid characters"));
156
153
my $details = $backup->backupDetails($id);