line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Labyrinth::Plugin::Requests; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
69724
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
146
|
|
4
|
5
|
|
|
5
|
|
18
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
129
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
14
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
317
|
|
7
|
|
|
|
|
|
|
$VERSION = '1.08'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Labyrinth::Plugin::Requests - Requests handler for the Labyrinth framework. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Contains all the request administration functionality for Labyrinth. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ------------------------------------- |
20
|
|
|
|
|
|
|
# Library Modules |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
|
21
|
use base qw(Labyrinth::Plugin::Base); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
4183
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Labyrinth::Audit; |
25
|
|
|
|
|
|
|
use Labyrinth::Globals; |
26
|
|
|
|
|
|
|
use Labyrinth::DBUtils; |
27
|
|
|
|
|
|
|
use Labyrinth::MLUtils; |
28
|
|
|
|
|
|
|
use Labyrinth::Support; |
29
|
|
|
|
|
|
|
use Labyrinth::Variables; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# ------------------------------------- |
32
|
|
|
|
|
|
|
# Variables |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# type: 0 = optional, 1 = mandatory |
35
|
|
|
|
|
|
|
# html: 0 = none, 1 = text, 2 = textarea |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my %fields = ( |
38
|
|
|
|
|
|
|
requestid => { type => 0, html => 1 }, |
39
|
|
|
|
|
|
|
section => { type => 1, html => 1 }, |
40
|
|
|
|
|
|
|
command => { type => 1, html => 1 }, |
41
|
|
|
|
|
|
|
actions => { type => 0, html => 1 }, |
42
|
|
|
|
|
|
|
layout => { type => 0, html => 1 }, |
43
|
|
|
|
|
|
|
content => { type => 0, html => 1 }, |
44
|
|
|
|
|
|
|
onsuccess => { type => 0, html => 1 }, |
45
|
|
|
|
|
|
|
onerror => { type => 0, html => 1 }, |
46
|
|
|
|
|
|
|
onfailure => { type => 0, html => 1 }, |
47
|
|
|
|
|
|
|
secure => { type => 0, html => 1 }, |
48
|
|
|
|
|
|
|
rewrite => { type => 0, html => 1 }, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my @savefields = qw(section command actions layout content onsuccess onerror onfailure secure rewrite); |
52
|
|
|
|
|
|
|
my $INDEXKEY = 'requestid'; |
53
|
|
|
|
|
|
|
my $ALLSQL = 'AllRequests'; |
54
|
|
|
|
|
|
|
my $SAVESQL = 'SaveRequest'; |
55
|
|
|
|
|
|
|
my $ADDSQL = 'AddRequest'; |
56
|
|
|
|
|
|
|
my $GETSQL = 'GetRequestByID'; |
57
|
|
|
|
|
|
|
my $DELETESQL = 'DeleteRequests'; |
58
|
|
|
|
|
|
|
my $LEVEL = ADMIN; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my %adddata = ( |
61
|
|
|
|
|
|
|
section => '', |
62
|
|
|
|
|
|
|
command => '', |
63
|
|
|
|
|
|
|
actions => '', |
64
|
|
|
|
|
|
|
layout => '', |
65
|
|
|
|
|
|
|
content => '', |
66
|
|
|
|
|
|
|
onsuccess => '', |
67
|
|
|
|
|
|
|
onerror => '', |
68
|
|
|
|
|
|
|
onfailure => '', |
69
|
|
|
|
|
|
|
secure => 1, |
70
|
|
|
|
|
|
|
rewrite => '', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# security types |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my %types = ( |
76
|
|
|
|
|
|
|
1 => 'off', |
77
|
|
|
|
|
|
|
2 => 'on', |
78
|
|
|
|
|
|
|
3 => 'either', |
79
|
|
|
|
|
|
|
4 => 'both', |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
my @types = map {{'id'=>$_,'value'=> $types{$_}}} sort keys %types; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# ------------------------------------- |
85
|
|
|
|
|
|
|
# Admin Methods |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 ADMIN INTERFACE METHODS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item Admin |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Handle main administrive duties, and display requests admin page. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item Add |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Add a request. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item Edit |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Edit a request. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item Save |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Save a request. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item Delete |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Delete one or more requests. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item SecureSelect |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Security selection box. This denotes whether request requires SSL. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item SecureName |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Give an id, returns the security status. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub Admin { |
124
|
|
|
|
|
|
|
return unless(AccessUser($LEVEL)); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
if($cgiparams{doaction}) { |
127
|
|
|
|
|
|
|
if($cgiparams{doaction} eq 'Delete' ) { Delete(); } |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash','AllRequests'); |
131
|
|
|
|
|
|
|
for(@rows) { |
132
|
|
|
|
|
|
|
$_->{secured} = SecureName($_->{secure}); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
$tvars{data} = \@rows if(@rows); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub Add { |
138
|
|
|
|
|
|
|
return unless AccessUser($LEVEL); |
139
|
|
|
|
|
|
|
$tvars{data} = \%adddata; |
140
|
|
|
|
|
|
|
$tvars{data}->{ddsecure} = SecureSelect($adddata{secure}); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub Edit { |
144
|
|
|
|
|
|
|
return unless AccessUser($LEVEL); |
145
|
|
|
|
|
|
|
return unless AuthorCheck($GETSQL,$INDEXKEY,$LEVEL); |
146
|
|
|
|
|
|
|
$tvars{data}->{ddsecure} = SecureSelect($tvars{data}->{secure}); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub Save { |
150
|
|
|
|
|
|
|
return unless AccessUser($LEVEL); |
151
|
|
|
|
|
|
|
return unless AuthorCheck($GETSQL,$INDEXKEY,$LEVEL); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
return if ParamCheck(\%fields); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my @fields; |
156
|
|
|
|
|
|
|
push @fields, $tvars{data}->{$_} for(@savefields); |
157
|
|
|
|
|
|
|
if($cgiparams{$INDEXKEY}) { |
158
|
|
|
|
|
|
|
$dbi->DoQuery($SAVESQL,@fields,$cgiparams{$INDEXKEY}); |
159
|
|
|
|
|
|
|
} else { |
160
|
|
|
|
|
|
|
$cgiparams{$INDEXKEY} = $dbi->IDQuery($ADDSQL,@fields); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$tvars{thanks} = 1; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub Delete { |
167
|
|
|
|
|
|
|
return unless AccessUser($LEVEL); |
168
|
|
|
|
|
|
|
my @ids = CGIArray('LISTED'); |
169
|
|
|
|
|
|
|
return unless @ids; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# remove requests |
172
|
|
|
|
|
|
|
my $ids = join(",",@ids); |
173
|
|
|
|
|
|
|
$dbi->DoQuery($DELETESQL,{ids=>$ids}); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub SecureSelect { |
177
|
|
|
|
|
|
|
my $opt = shift || 0; |
178
|
|
|
|
|
|
|
DropDownRows($opt,"typeid",'id','value',@types); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub SecureName { |
182
|
|
|
|
|
|
|
my $id = shift || 1; |
183
|
|
|
|
|
|
|
return $types{$id}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
__END__ |