~ubuntu-branches/ubuntu/vivid/zentyal-core/vivid-proposed

« back to all changes in this revision

Viewing changes to src/EBox/CGI/SysInfo/ConfirmBackup.pm

  • Committer: Package Import Robot
  • Author(s): Jorge Salamero Sanz
  • Date: 2012-08-28 10:03:33 UTC
  • Revision ID: package-import@ubuntu.com-20120828100333-oz3n5kpav4z0tl27
Tags: 2.3.21+quantal1
New upstream release for Quantal

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
15
 
 
16
 
package EBox::CGI::SysInfo::ConfirmBackup;
17
 
 
18
15
use strict;
19
16
use warnings;
20
17
 
 
18
package EBox::CGI::SysInfo::ConfirmBackup;
21
19
use base 'EBox::CGI::ClientBase';
22
20
 
23
21
use EBox::Config;
29
27
 
30
28
sub new # (error=?, msg=?, cgi=?)
31
29
{
32
 
        my $class = shift;
33
 
        my $self = $class->SUPER::new('title' => __('Configuration Backup'),
34
 
                                      'template' => '/confirm-backup.mas',
35
 
                                      @_);
36
 
        bless($self, $class);
37
 
 
38
 
        $self->{errorchain} = "SysInfo/Backup";
39
 
 
40
 
        return $self;
 
30
    my $class = shift;
 
31
    my $self = $class->SUPER::new('title' => __('Configuration Backup'),
 
32
                                  'template' => '/confirm-backup.mas',
 
33
                                  @_);
 
34
    $self->{errorchain} = "SysInfo/Backup";
 
35
 
 
36
    bless($self, $class);
 
37
    return $self;
41
38
}
42
39
 
43
 
 
44
40
sub requiredParameters
45
41
{
46
42
  my ($self) = @_;
47
43
 
48
44
  if ($self->param('download.x')) {
49
45
    return [qw(id download.x download.y)];
50
 
  }
51
 
  elsif ($self->param('delete.x')) {
 
46
  }  elsif ($self->param('delete.x')) {
52
47
    return [qw(id delete.x delete.y)];
53
 
  }
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)];
56
 
  }
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)];
59
56
  }
60
57
 
61
58
  return [];
62
59
}
63
60
 
64
 
 
65
61
sub optionalParameters
66
62
{
67
 
    return ['download', 'delete', 'restoreFromId'];
 
63
    return ['download', 'delete', 'popup', 'alreadyUploaded'];
68
64
}
69
65
 
70
 
 
71
66
sub actuate
72
67
{
73
68
  my ($self) = @_;
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);
 
82
      }
 
83
 
85
84
      return;
86
85
    }
87
86
  }
88
87
 
89
 
 
90
88
  # otherwise...
91
89
  $self->{redirect} = "SysInfo/Backup";
92
90
  return;
122
120
  return ('restoreFromId', __('Restore'), $self->backupDetailsFromId());
123
121
}
124
122
 
125
 
 
126
 
 
127
 
 
128
123
sub  restoreFromFileAction
129
124
{
130
125
  my ($self) = @_;
131
126
 
132
 
  my $filename = $self->upload('backupfile');
 
127
  my $filename;
 
128
  if ($self->param('alreadyUploaded')) {
 
129
      $filename = $self->param('backupfile');
 
130
  } else {
 
131
      $filename = $self->upload('backupfile');
 
132
  }
 
133
 
133
134
 
134
135
  my $details = $self->backupDetailsFromFile($filename);
135
136
 
138
139
  return ('restoreFromFile', __('Restore'), $details);
139
140
}
140
141
 
141
 
 
142
 
 
143
 
 
144
 
 
145
142
sub backupDetailsFromId
146
143
{
147
144
  my ($self) = @_;
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"));
154
151
  }
155
152
 
156
153
  my $details =  $backup->backupDetails($id);
159
156
  return $details;
160
157
}
161
158
 
162
 
 
163
159
sub backupDetailsFromFile
164
160
{
165
161
  my ($self, $filename) = @_;
170
166
  return $details;
171
167
}
172
168
 
173
 
 
174
169
sub setPrintabletype
175
170
{
176
171
  my ($self, $details_r) = @_;
193
188
  return $details_r;
194
189
}
195
190
 
 
191
# to avoid the <div id=content>
 
192
sub _print
 
193
{
 
194
    my ($self) = @_;
 
195
    if (not $self->param('popup')) {
 
196
        return $self->SUPER::_print();
 
197
    }
 
198
 
 
199
    $self->_printPopup();
 
200
}
196
201
 
197
202
1;