Event/Sponsors.pm

filter: Statementstmt 51.4% 36 / 70 Branchbran 5.5% 2 / 36 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 60.0% 9 / 15 Podpod 100% 6 / 6 totaltotal 40.7% 53 / 130 SCAR 49.5
CC
21
Cov
35%
Save
90.0
Admin
30.0
SponsorSelect
20.0
CRAP 141.1
« Event/Venues.pm ↑ Summary Event/Types.pm »
1 package Labyrinth::Plugin::Event::Sponsors;
2  
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 $VERSION = '1.09';
8  
9 =head1 NAME
10  
11 Labyrinth::Plugin::Event::Sponsors - Event Sponsor handler for the Labyrinth framework.
12  
13 =head1 DESCRIPTION
14  
15 Contains all the event sponsor functionality for Labyrinth.
16  
17 =cut
18  
19 # -------------------------------------
20 # Library Modules
21  
22 7 ▶use base qw(Labyrinth::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 7 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 7 ▶use Labyrinth::DBUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 7 ▶use Labyrinth::MLUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 7 ▶use Labyrinth::Support;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 7 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 # -------------------------------------
32 # Variables
33  
34 # type: 0 = optional, 1 = mandatory
35 # html: 0 = none, 1 = text, 2 = textarea
36  
37  
38 7 my %fields = (
39 sponsorid => { type => 0, html => 0 },
40 sponsor => { type => 1, html => 1 },
41 sponsorlink => { type => 0, html => 1 },
42 );
43  
44 7 my (@mandatory,@allfields);
45 7 for(keys %fields) {
46 21 ▶ push @mandatory, $_ if($fields{$_}->{type});
Branch: 1 branch
BranchTrueFalseTotal
if $fields{$_}{"type"} 7 14 21
47 21 push @allfields, $_;
48 }
49  
50 7 our $INDEXKEY = 'sponsorid';
51 7 our $LEVEL = ADMIN;
52  
53 # -------------------------------------
54 # The Subs
55  
56 =head1 PUBLIC INTERFACE METHODS
57  
58 =over 4
59  
60 =item SponsorSelect
61  
62 Provides a dropdown list of sponsors available.
63  
64 =back
65  
66 =cut
67  
68 sub SponsorSelect {
69 0 ▶ my ($self,$opt,$blank) = @_;
Subroutine SponsorSelect: not called CC=4 SCAR=30.0
Pod documented
70 0 ▶ $blank ||= 0;
Condition0%0/2
$blank ||= 0
l!l
00
MC/DC0%0/1
$blank ||= 0
$blank
Truth table0%0/2
A
A= $blank
Aresult
11
00
71  
72 0 my @rows = $dbi->GetQuery('hash','AllSponsors');
73 0 my @list;
74 0 for(@rows) { push @list, { id => $_->{sponsorid}, value => $_->{sponsor} }; }
75 0 ▶ unshift @list, { id => 0, value => 'Select Sponsor' } if($blank == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $blank == 1 0 0 0
76 0 DropDownRows($opt,$INDEXKEY,'id','value',@list);
77 }
78  
79 =head1 ADMIN INTERFACE METHODS
80  
81 =over 4
82  
83 =item Admin
84  
85 Provides list of the sponsors currently available.
86  
87 =item Add
88  
89 Add a new sponsor.
90  
91 =item Edit
92  
93 Edit an existing sponsor.
94  
95 =item Save
96  
97 Save the current sponsor.
98  
99 =item Delete
100  
101 Delete a sponsor.
102  
103 =back
104  
105 =cut
106  
107 sub Admin {
108 0 ▶ return unless AccessUser(EDITOR);
Subroutine Admin: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
109  
110 0 ▶ if($cgiparams{doaction}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Sponsors::cgiparams{"doaction"}) 0 0 0
111 0 ▶ if($cgiparams{doaction} eq 'Delete') { Delete(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Sponsors::cgiparams{"doaction"} eq "Delete") 0 0 0
112 }
113  
114 0 my @rows = $dbi->GetQuery('hash','AllSponsors');
115 0 ▶ $tvars{data} = \@rows if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
116 }
117  
118 sub Add {
119 0 ▶ return unless AccessUser(EDITOR);
Subroutine Add: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
120 $tvars{data} = {
121 0 sponsor => 'Sponsor',
122 sponsorlink => ''
123 };
124 }
125  
126 sub Edit {
127 0 ▶ return unless AccessUser(EDITOR);
Subroutine Edit: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
128 0 ▶ return unless AuthorCheck('GetSponsorByID',$INDEXKEY,EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetSponsorByID", $Labyrinth::Plugin::Event::Sponsors::INDEXKEY, 2) 0 0 0
129 }
130  
131 sub Save {
132 0 ▶ return unless AccessUser(EDITOR);
Subroutine Save: not called CC=9 SCAR=45.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
133 0 ▶ return unless AuthorCheck('GetSponsorByID',$INDEXKEY,EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetSponsorByID", $Labyrinth::Plugin::Event::Sponsors::INDEXKEY, 2) 0 0 0
134  
135 0 ▶ return if FieldCheck(\@allfields,\@mandatory);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@allfields, \@mandatory) 0 0 0
136  
137 0 for(keys %fields) {
138 0 ▶ next unless($fields{$_});
Branch: 1 branch
BranchTrueFalseTotal
unless $fields{$_} 0 0 0
139 0 ▶ if($fields{$_}->{html} == 1) { $tvars{data}->{$_} = CleanHTML($tvars{data}->{$_}) }
Branch: 2 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
140 0 elsif($fields{$_}->{html} == 2) { $tvars{data}->{$_} = CleanTags($tvars{data}->{$_}) }
141 }
142  
143 my @fields = (
144 $tvars{data}->{sponsor},
145 $tvars{data}->{sponsorlink}
146 0 );
147  
148 0 ▶ if($cgiparams{$INDEXKEY})
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Sponsors::cgiparams{$Labyrinth::Plugin::Event::Sponsors::INDEXKEY}) { } 0 0 0
149 0 { $dbi->DoQuery('SaveSponsor',@fields,$cgiparams{$INDEXKEY}); }
150 0 else { $cgiparams{$INDEXKEY} = $dbi->IDQuery('AddSponsor',@fields); }
151 }
152  
153 sub Delete {
154 0 ▶ return unless AccessUser(ADMIN);
Subroutine Delete: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(4) 0 0 0
155 0 my @ids = CGIArray('LISTED');
156  
157 0 ▶ return unless @ids;
Branch: 1 branch
BranchTrueFalseTotal
unless @ids 0 0 0
158  
159 0 $dbi->DoQuery('DeleteSponsors',{ids => join(',',@ids)});
160 }
161  
162 7 1;
163  
164 __END__
165  
166 =head1 SEE ALSO
167  
168 L<Labyrinth>
169  
170 =head1 AUTHOR
171  
172 Barbie, <barbie@missbarbell.co.uk> for
173 Miss Barbell Productions, L<http://www.missbarbell.co.uk/>
174  
175 =head1 COPYRIGHT & LICENSE
176  
177 Copyright (C) 2002-2015 Barbie for Miss Barbell Productions
178 All Rights Reserved.
179  
180 This module is free software; you can redistribute it and/or
181 modify it under the Artistic License 2.0.
182  
183 =cut
« Event/Venues.pm ↑ Summary Event/Types.pm »