| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Labyrinth::Plugin::Event::Venues; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
3902
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
55
|
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
48
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
79
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '1.10'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Labyrinth::Plugin::Event::Venues - Venues administration for the Labyrinth framework. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Contains all the venue administration functionality for Labyrinth. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ------------------------------------- |
|
20
|
|
|
|
|
|
|
# Library Modules |
|
21
|
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
7
|
use base qw(Labyrinth::Plugin::Base); |
|
|
2
|
|
|
|
|
1
|
|
|
|
2
|
|
|
|
|
691
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Labyrinth::DBUtils; |
|
25
|
|
|
|
|
|
|
#use Labyrinth::Media; |
|
26
|
|
|
|
|
|
|
use Labyrinth::MLUtils; |
|
27
|
|
|
|
|
|
|
use Labyrinth::Support; |
|
28
|
|
|
|
|
|
|
use Labyrinth::Variables; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Clone qw(clone); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# ------------------------------------- |
|
33
|
|
|
|
|
|
|
# Constants |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# withdrawn, may be reintroduced later |
|
36
|
|
|
|
|
|
|
#use constant MaxVenueWidth => 400; |
|
37
|
|
|
|
|
|
|
#use constant MaxVenueHeight => 400; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# ------------------------------------- |
|
40
|
|
|
|
|
|
|
# Variables |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my (@mandatory, @allfields); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# type: 0 = optional, 1 = mandatory |
|
45
|
|
|
|
|
|
|
# html: 0 = none, 1 = text, 2 = textarea |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my %fields = ( |
|
48
|
|
|
|
|
|
|
eventid => { type => 0, html => 0 }, # only applicable when adding via an event |
|
49
|
|
|
|
|
|
|
venueid => { type => 0, html => 0 }, |
|
50
|
|
|
|
|
|
|
venue => { type => 1, html => 1 }, |
|
51
|
|
|
|
|
|
|
venuelink => { type => 0, html => 2 }, |
|
52
|
|
|
|
|
|
|
address => { type => 1, html => 1 }, |
|
53
|
|
|
|
|
|
|
addresslink => { type => 0, html => 2 }, |
|
54
|
|
|
|
|
|
|
info => { type => 0, html => 2 }, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
for(keys %fields) { |
|
58
|
|
|
|
|
|
|
push @mandatory, $_ if($fields{$_}->{type}); |
|
59
|
|
|
|
|
|
|
push @allfields, $_; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my @savefields = qw(venue venuelink address addresslink info); |
|
63
|
|
|
|
|
|
|
my $INDEXKEY = 'venueid'; |
|
64
|
|
|
|
|
|
|
my $ALLSQL = 'AllVenues'; |
|
65
|
|
|
|
|
|
|
my $SAVESQL = 'SaveVenue'; |
|
66
|
|
|
|
|
|
|
my $ADDSQL = 'AddVenue'; |
|
67
|
|
|
|
|
|
|
my $GETSQL = 'GetVenueByID'; |
|
68
|
|
|
|
|
|
|
my $DELETESQL = 'DeleteVenue'; |
|
69
|
|
|
|
|
|
|
my $LEVEL = ADMIN; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# ------------------------------------- |
|
72
|
|
|
|
|
|
|
# The Subs |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 PUBLIC INTERFACE METHODS |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item Current |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Current list of venues for events. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub Current { |
|
87
|
|
|
|
|
|
|
my %venues; |
|
88
|
|
|
|
|
|
|
for my $event ($tvars{next},@{$tvars{future}}) { |
|
89
|
|
|
|
|
|
|
$venues{$event->{venueid}}->{$_} = $event->{$_} for(grep {$event->{$_}} qw(venueid venue venuelink address addresslink info)); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
my @venues = map {$venues{$_}} sort {$venues{$a}->{venue} cmp $venues{$b}->{venue}} keys %venues; |
|
92
|
|
|
|
|
|
|
$tvars{venues} = \@venues if(@venues); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 ADMIN INTERFACE METHODS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over 4 |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item Admin |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Provides list of the venues currently available. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item Add |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Add a new venue. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item Edit |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Edit an existing venue. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item Save |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Save the current venue. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item Delete |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Delete a venue. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub Admin { |
|
124
|
|
|
|
|
|
|
return unless AccessUser(EDITOR); |
|
125
|
|
|
|
|
|
|
if($cgiparams{doaction}) { |
|
126
|
|
|
|
|
|
|
if($cgiparams{doaction} eq 'Delete') { Delete(); } |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash',$ALLSQL); |
|
129
|
|
|
|
|
|
|
$tvars{data} = \@rows if(@rows); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub Edit { |
|
133
|
|
|
|
|
|
|
return unless AccessUser(EDITOR); |
|
134
|
|
|
|
|
|
|
if($cgiparams{$INDEXKEY}) { |
|
135
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash',$GETSQL,$cgiparams{$INDEXKEY}); |
|
136
|
|
|
|
|
|
|
$tvars{data}->{$_} = $rows[0]->{$_} for(keys %{$rows[0]}); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
$tvars{preview} = clone($tvars{data}); |
|
139
|
|
|
|
|
|
|
my $view = $tvars{preview}; |
|
140
|
|
|
|
|
|
|
my $data = $tvars{data}; |
|
141
|
|
|
|
|
|
|
for(keys %fields) { |
|
142
|
|
|
|
|
|
|
if($fields{$_}->{html} == 1) { $data->{$_} = CleanHTML($data->{$_}) } |
|
143
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 2) { $data->{$_} = SafeHTML($data->{$_}); |
|
144
|
|
|
|
|
|
|
$view->{$_} = CleanTags($view->{$_}) } |
|
145
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 3) { $data->{$_} = CleanLink($data->{$_}); |
|
146
|
|
|
|
|
|
|
$view->{$_} = CleanLink($view->{$_}) } |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub Save { |
|
151
|
|
|
|
|
|
|
return unless AccessUser(EDITOR); |
|
152
|
|
|
|
|
|
|
for(keys %fields) { |
|
153
|
|
|
|
|
|
|
if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } |
|
154
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } |
|
155
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
return if FieldCheck(\@allfields,\@mandatory); |
|
158
|
|
|
|
|
|
|
my @fields = map {$tvars{data}->{$_}} @savefields; |
|
159
|
|
|
|
|
|
|
if($cgiparams{$INDEXKEY}) |
|
160
|
|
|
|
|
|
|
{ $dbi->DoQuery($SAVESQL,@fields,$cgiparams{$INDEXKEY}); } |
|
161
|
|
|
|
|
|
|
else { $cgiparams{venueid} = $dbi->IDQuery($ADDSQL,@fields); } |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# the following code has been withdrawn, but may be reintroduced in a later |
|
164
|
|
|
|
|
|
|
# version of this dtistribution. |
|
165
|
|
|
|
|
|
|
# |
|
166
|
|
|
|
|
|
|
# upload new photos |
|
167
|
|
|
|
|
|
|
#my $inx = 0; |
|
168
|
|
|
|
|
|
|
#my $width = $settings{"venuewidth"} || MaxVenueWidth; |
|
169
|
|
|
|
|
|
|
#my $height = $settings{"venueheight"} || MaxVenueHeight; |
|
170
|
|
|
|
|
|
|
#while($cgiparams{"file_$inx"}) { |
|
171
|
|
|
|
|
|
|
# my ($imageid,$imagelink) = |
|
172
|
|
|
|
|
|
|
# SaveImageFile( param => "file_$inx", |
|
173
|
|
|
|
|
|
|
# stock => 'Special', |
|
174
|
|
|
|
|
|
|
# width => $width, |
|
175
|
|
|
|
|
|
|
# height => $height); |
|
176
|
|
|
|
|
|
|
# $dbi->DoQuery('AddVenueImage',$cgiparams{venueid},$imageid); |
|
177
|
|
|
|
|
|
|
# $inx++; |
|
178
|
|
|
|
|
|
|
#} |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub Delete { |
|
182
|
|
|
|
|
|
|
return unless AccessUser(ADMIN); |
|
183
|
|
|
|
|
|
|
my @ids = CGIArray('LISTED'); |
|
184
|
|
|
|
|
|
|
return unless @ids; |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
$dbi->DoQuery($DELETESQL,{ids => join(",",@ids)}); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
__END__ |