line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package iRedAdmin::Domain; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has 'ref' => (is => 'ro'); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub Add { |
8
|
0
|
|
|
0
|
1
|
|
my ($self, %data) = @_; |
9
|
|
|
|
|
|
|
|
10
|
0
|
0
|
|
|
|
|
if (Email::Valid->address('domain@'.$data{domain})) { |
11
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/create/domain'); |
12
|
|
|
|
|
|
|
$self->ref->mech->submit_form( |
13
|
|
|
|
|
|
|
form_number => 1, |
14
|
|
|
|
|
|
|
fields => { |
15
|
|
|
|
|
|
|
domainName => $data{domain}, |
16
|
|
|
|
|
|
|
cn => $data{name} |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
21
|
0
|
0
|
|
|
|
|
$self->Add(%data) if $success == 2; |
22
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
23
|
|
|
|
|
|
|
}else{ |
24
|
0
|
|
|
|
|
|
$self->ref->set_error('Domain is invalid!'); |
25
|
0
|
|
|
|
|
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub Edit { |
30
|
0
|
|
|
0
|
1
|
|
my ($self, %data) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (Email::Valid->address('domain@'.$data{domain})) { |
33
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/profile/domain/general/' . $data{domain}); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my %form; |
36
|
0
|
0
|
|
|
|
|
$form{cn} = $data{name} if exists $data{name}; |
37
|
0
|
0
|
|
|
|
|
if (exists $data{enable}) { |
38
|
0
|
0
|
|
|
|
|
$form{accountStatus} = 'active' if $data{enable}; |
39
|
0
|
0
|
|
|
|
|
$self->ref->mech->untick('accountStatus', 'active') unless $data{enable}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
$self->ref->mech->submit_form( |
42
|
0
|
|
|
|
|
|
form_number => 1, |
43
|
|
|
|
|
|
|
fields => \%form |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
47
|
0
|
0
|
|
|
|
|
$self->Edit(%data) if $success == 2; |
48
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
49
|
|
|
|
|
|
|
}else{ |
50
|
0
|
|
|
|
|
|
$self->ref->set_error('Domain is invalid!'); |
51
|
0
|
|
|
|
|
|
return 0; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub Enable { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, @domain) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$self->_apply('enable', [@domain]); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub Disable { |
62
|
0
|
|
|
0
|
1
|
|
my ($self, @domain) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$self->_apply('disable', [@domain]); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub Delete { |
68
|
0
|
|
|
0
|
1
|
|
my ($self, @domain) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$self->_apply('delete', [@domain]); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _apply { |
74
|
0
|
|
|
0
|
|
|
my ($self, $type, @domain) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/domains'); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my %form; |
79
|
0
|
|
|
|
|
|
$form{action} = $type; |
80
|
0
|
|
|
|
|
|
$form{domainName} = \@domain; |
81
|
0
|
|
|
|
|
|
$self->ref->mech->submit_form( |
82
|
|
|
|
|
|
|
form_number => 1, |
83
|
|
|
|
|
|
|
fields => \%form |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
87
|
0
|
0
|
|
|
|
|
$self->_apply($type, @domain) if $success == 2; |
88
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |