line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package iRedAdmin::Admin; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
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($data{email})) { |
11
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/create/admin'); |
12
|
|
|
|
|
|
|
$self->ref->mech->submit_form( |
13
|
|
|
|
|
|
|
form_number => 1, |
14
|
|
|
|
|
|
|
fields => { |
15
|
|
|
|
|
|
|
mail => $data{email}, |
16
|
|
|
|
|
|
|
newpw => $data{password}, |
17
|
|
|
|
|
|
|
confirmpw => $data{password}, |
18
|
|
|
|
|
|
|
cn => $data{name}, |
19
|
|
|
|
|
|
|
preferredLanguage => $self->ref->_lang($data{lang}) |
20
|
0
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
24
|
0
|
0
|
|
|
|
|
$self->Add(%data) if $success == 2; |
25
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
26
|
|
|
|
|
|
|
}else{ |
27
|
0
|
|
|
|
|
|
$self->ref->set_error('Email is invalid!'); |
28
|
0
|
|
|
|
|
|
return 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub Edit { |
33
|
0
|
|
|
0
|
1
|
|
my ($self, %data) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if (Email::Valid->address($data{email})) { |
36
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/profile/admin/general/' . $data{email}); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my %form; |
39
|
0
|
0
|
|
|
|
|
$form{cn} = $data{name} if exists $data{name}; |
40
|
0
|
0
|
|
|
|
|
$form{preferredLanguage} = $self->ref->_lang($data{lang}) if $data{lang}; |
41
|
0
|
0
|
|
|
|
|
if (exists $data{enable}) { |
42
|
0
|
0
|
|
|
|
|
$form{accountStatus} = 'active' if $data{enable}; |
43
|
0
|
0
|
|
|
|
|
$self->ref->mech->untick('accountStatus', 'active') unless $data{enable}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
$self->ref->mech->submit_form( |
46
|
0
|
|
|
|
|
|
form_number => 1, |
47
|
|
|
|
|
|
|
fields => \%form |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
51
|
0
|
0
|
|
|
|
|
$self->Edit(%data) if $success == 2; |
52
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
53
|
|
|
|
|
|
|
}else{ |
54
|
0
|
|
|
|
|
|
$self->ref->set_error('Email is invalid!'); |
55
|
0
|
|
|
|
|
|
return 0; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub Password { |
60
|
0
|
|
|
0
|
1
|
|
my ($self, %data) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if (Email::Valid->address($data{email})) { |
63
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/profile/admin/general/' . $data{email}); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->ref->mech->submit_form( |
66
|
|
|
|
|
|
|
form_number => 2, |
67
|
|
|
|
|
|
|
fields => { |
68
|
|
|
|
|
|
|
newpw => $data{password}, |
69
|
|
|
|
|
|
|
confirmpw => $data{password} |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
74
|
0
|
0
|
|
|
|
|
$self->Password(%data) if $success == 2; |
75
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
76
|
|
|
|
|
|
|
}else{ |
77
|
0
|
|
|
|
|
|
$self->ref->set_error('Email is invalid!'); |
78
|
0
|
|
|
|
|
|
return 0; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub Enable { |
83
|
0
|
|
|
0
|
1
|
|
my ($self, @email) = @_; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->_apply('enable', [@email]); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub Disable { |
89
|
0
|
|
|
0
|
1
|
|
my ($self, @email) = @_; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
$self->_apply('disable', [@email]); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub Delete { |
95
|
0
|
|
|
0
|
1
|
|
my ($self, @email) = @_; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$self->_apply('delete', [@email]); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _apply { |
101
|
0
|
|
|
0
|
|
|
my ($self, $type, @email) = @_; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$self->ref->mech->get($self->ref->_address . '/admins'); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my %form; |
106
|
0
|
|
|
|
|
|
$form{action} = $type; |
107
|
0
|
|
|
|
|
|
$form{mail} = \@email; |
108
|
0
|
|
|
|
|
|
$self->ref->mech->submit_form( |
109
|
|
|
|
|
|
|
form_number => 1, |
110
|
|
|
|
|
|
|
fields => \%form |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $success = $self->ref->_success; |
114
|
0
|
0
|
|
|
|
|
$self->_apply($type, @email) if $success == 2; |
115
|
0
|
0
|
|
|
|
|
return $success ? 1 : 0; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |