| 1 | package Labyrinth::Plugin::Event::Venues; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | 4 | ▶ | use vars qw($VERSION); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | 4 | $VERSION = '1.09'; | |||||||||||||||||
| 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 | 4 | ▶ | use base qw(Labyrinth::Plugin::Base); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 4 | ▶ | use Labyrinth::DBUtils; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 25 | #use Labyrinth::Media; | ||||||||||||||||||
| 26 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 27 | 4 | ▶ | use Labyrinth::Support; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 28 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | 4 | ▶ | use Clone qw(clone); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 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 | 4 | my (@mandatory, @allfields); | |||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||
| 45 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | 4 | 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 | 4 | for(keys %fields) { | |||||||||||||||||
| 58 | 28 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 59 | 28 | push @allfields, $_; | |||||||||||||||||
| 60 | } | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | 4 | my @savefields = qw(venue venuelink address addresslink info); | |||||||||||||||||
| 63 | 4 | my $INDEXKEY = 'venueid'; | |||||||||||||||||
| 64 | 4 | my $ALLSQL = 'AllVenues'; | |||||||||||||||||
| 65 | 4 | my $SAVESQL = 'SaveVenue'; | |||||||||||||||||
| 66 | 4 | my $ADDSQL = 'AddVenue'; | |||||||||||||||||
| 67 | 4 | my $GETSQL = 'GetVenueByID'; | |||||||||||||||||
| 68 | 4 | my $DELETESQL = 'DeleteVenue'; | |||||||||||||||||
| 69 | 4 | 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 | 0 | ▶ | my %venues; | ||||||||||||||||
|
Subroutine
Current: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||
| 88 | 0 | for my $event ($tvars{next},@{$tvars{future}}) { | |||||||||||||||||
| 89 | 0 | $venues{$event->{venueid}}->{$_} = $event->{$_} for(grep {$event->{$_}} qw(venueid venue venuelink address addresslink info)); | |||||||||||||||||
| 90 | } | ||||||||||||||||||
| 91 | 0 | my @venues = map {$venues{$_}} sort {$venues{$a}->{venue} cmp $venues{$b}->{venue}} keys %venues; | |||||||||||||||||
| 92 | 0 | ▶ | $tvars{venues} = \@venues if(@venues); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||
|
Subroutine
Admin: not called CC=5 SCAR=34.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 125 | 0 | ▶ | if($cgiparams{doaction}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 126 | 0 | ▶ | if($cgiparams{doaction} eq 'Delete') { Delete(); } | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 127 | } | ||||||||||||||||||
| 128 | 0 | my @rows = $dbi->GetQuery('hash',$ALLSQL); | |||||||||||||||||
| 129 | 0 | ▶ | $tvars{data} = \@rows if(@rows); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 130 | } | ||||||||||||||||||
| 131 | |||||||||||||||||||
| 132 | sub Edit { | ||||||||||||||||||
| 133 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||
|
Subroutine
Edit: not called CC=8 SCAR=42.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 134 | 0 | ▶ | if($cgiparams{$INDEXKEY}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 135 | 0 | my @rows = $dbi->GetQuery('hash',$GETSQL,$cgiparams{$INDEXKEY}); | |||||||||||||||||
| 136 | 0 | $tvars{data}->{$_} = $rows[0]->{$_} for(keys %{$rows[0]}); | |||||||||||||||||
| 137 | } | ||||||||||||||||||
| 138 | 0 | $tvars{preview} = clone($tvars{data}); | |||||||||||||||||
| 139 | 0 | my $view = $tvars{preview}; | |||||||||||||||||
| 140 | 0 | my $data = $tvars{data}; | |||||||||||||||||
| 141 | 0 | for(keys %fields) { | |||||||||||||||||
| 142 | 0 | ▶ | if($fields{$_}->{html} == 1) { $data->{$_} = CleanHTML($data->{$_}) } | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 143 | 0 | elsif($fields{$_}->{html} == 2) { $data->{$_} = SafeHTML($data->{$_}); | |||||||||||||||||
| 144 | 0 | $view->{$_} = CleanTags($view->{$_}) } | |||||||||||||||||
| 145 | 0 | elsif($fields{$_}->{html} == 3) { $data->{$_} = CleanLink($data->{$_}); | |||||||||||||||||
| 146 | 0 | $view->{$_} = CleanLink($view->{$_}) } | |||||||||||||||||
| 147 | } | ||||||||||||||||||
| 148 | } | ||||||||||||||||||
| 149 | |||||||||||||||||||
| 150 | sub Save { | ||||||||||||||||||
| 151 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||
|
Subroutine
Save: not called CC=8 SCAR=42.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 152 | 0 | for(keys %fields) { | |||||||||||||||||
| 153 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 154 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||
| 155 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||
| 156 | } | ||||||||||||||||||
| 157 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 158 | 0 | my @fields = map {$tvars{data}->{$_}} @savefields; | |||||||||||||||||
| 159 | 0 | ▶ | if($cgiparams{$INDEXKEY}) | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 160 | 0 | { $dbi->DoQuery($SAVESQL,@fields,$cgiparams{$INDEXKEY}); } | |||||||||||||||||
| 161 | 0 | 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 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||
|
Subroutine
Delete: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 183 | 0 | my @ids = CGIArray('LISTED'); | |||||||||||||||||
| 184 | 0 | ▶ | return unless @ids; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 185 | |||||||||||||||||||
| 186 | 0 | $dbi->DoQuery($DELETESQL,{ids => join(",",@ids)}); | |||||||||||||||||
| 187 | } | ||||||||||||||||||
| 188 | |||||||||||||||||||
| 189 | 4 | 1; | |||||||||||||||||
| 190 | |||||||||||||||||||
| 191 | __END__ | ||||||||||||||||||
| 192 | |||||||||||||||||||
| 193 | =head1 SEE ALSO | ||||||||||||||||||
| 194 | |||||||||||||||||||
| 195 | L<Labyrinth> | ||||||||||||||||||
| 196 | |||||||||||||||||||
| 197 | =head1 AUTHOR | ||||||||||||||||||
| 198 | |||||||||||||||||||
| 199 | Barbie, <barbie@missbarbell.co.uk> for | ||||||||||||||||||
| 200 | Miss Barbell Productions, L<http://www.missbarbell.co.uk/> | ||||||||||||||||||
| 201 | |||||||||||||||||||
| 202 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||
| 203 | |||||||||||||||||||
| 204 | Copyright (C) 2002-2015 Barbie for Miss Barbell Productions | ||||||||||||||||||
| 205 | All Rights Reserved. | ||||||||||||||||||
| 206 | |||||||||||||||||||
| 207 | This module is free software; you can redistribute it and/or | ||||||||||||||||||
| 208 | modify it under the Artistic License 2.0. | ||||||||||||||||||
| 209 | |||||||||||||||||||
| 210 | =cut | ||||||||||||||||||