~ubuntu-branches/ubuntu/lucid/ebox-openvpn/lucid

« back to all changes in this revision

Viewing changes to src/EBox/CGI/Enable.pm

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-08-02 10:38:13 UTC
  • Revision ID: james.westby@ubuntu.com-20070802103813-dfbetdraf1435qoq
Tags: upstream-0.9.3
ImportĀ upstreamĀ versionĀ 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 Warp Networks S.L.
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License, version 2, as
 
5
# published by the Free Software Foundation.
 
6
#
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
 
 
16
package EBox::CGI::OpenVPN::Enable;
 
17
 
 
18
use strict;
 
19
use warnings;
 
20
 
 
21
use base 'EBox::CGI::ClientBase';
 
22
 
 
23
use EBox::Global;
 
24
use EBox::Gettext;
 
25
 
 
26
## arguments:
 
27
##      title [required]
 
28
sub new {
 
29
        my $class = shift;
 
30
        my $self = $class->SUPER::new('title' => 'OpenVPN',
 
31
                                      @_);
 
32
        $self->{redirect} = "OpenVPN/Index";    
 
33
        $self->{domain} = "ebox-openvpn";       
 
34
        bless($self, $class);
 
35
        return $self;
 
36
}
 
37
 
 
38
sub actuate
 
39
{
 
40
    my ($self) = @_;
 
41
    my $openvpn = EBox::Global->modInstance('openvpn');
 
42
    my $activeValue = $self->param('active');
 
43
    
 
44
    my $requestedStatus;
 
45
    if ($activeValue eq 'yes') {
 
46
        $requestedStatus = 1;
 
47
    }
 
48
    elsif ($activeValue eq 'no') {
 
49
        $requestedStatus = 0;
 
50
    }
 
51
    else {
 
52
        throw EBox::Exceptions::InvalidData(data => __('active parameter'), value => $activeValue, advice => __(q{It only may be 'yes' or 'no'}) );
 
53
    }
 
54
 
 
55
    $openvpn->setService($requestedStatus);
 
56
}
 
57
 
 
58
 
 
59
sub requiredParameters
 
60
{
 
61
    return ['active']; 
 
62
}
 
63
 
 
64
 
 
65
sub optionalParameters
 
66
{
 
67
    return [ 'change']; # change is the parameter related to the input button
 
68
}
 
69
 
 
70
1;