Event/Talks.pm

filter: Statementstmt 43.0% 40 / 93 Branchbran 4.0% 2 / 50 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 64.7% 11 / 17 Podpod 100% 6 / 6 totaltotal 33.9% 59 / 174 SCAR 58.9
CC
30
Cov
28%
Save
132.0
Edit
56.0
Admin
30.0
CRAP 360.7
« Event.pm ↑ Summary Event/Venues.pm »
1 package Labyrinth::Plugin::Event::Talks;
2  
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 $VERSION = '1.09';
8  
9 =head1 NAME
10  
11 Labyrinth::Plugin::Event::Talks - Event Talk handler for the Labyrinth framework.
12  
13 =head1 DESCRIPTION
14  
15 Contains all the event talk functionality for Labyrinth.
16  
17 =cut
18  
19 # -------------------------------------
20 # Library Modules
21  
22 5 ▶use base qw(Labyrinth::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 5 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 5 ▶use Labyrinth::DBUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use Labyrinth::MLUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use Labyrinth::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 5 ▶use Labyrinth::Support;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 5 ▶use Labyrinth::Users;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 5 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 # -------------------------------------
34 # Variables
35  
36 # type: 0 = optional, 1 = mandatory
37 # html: 0 = none, 1 = text, 2 = textarea
38  
39  
40 5 my %fields = (
41 eventid => { type => 1, html => 0 },
42 talkid => { type => 0, html => 0 },
43 userid => { type => 1, html => 0 },
44 guest => { type => 0, html => 0 },
45 talktitle => { type => 1, html => 1 },
46 abstract => { type => 1, html => 2 },
47 resource => { type => 0, html => 2 },
48 );
49  
50 5 my (@mandatory,@allfields);
51 5 for(keys %fields) {
52 35 ▶ push @mandatory, $_ if($fields{$_}->{type});
Branch: 1 branch
BranchTrueFalseTotal
if $fields{$_}{"type"} 20 15 35
53 35 push @allfields, $_;
54 }
55  
56 # -------------------------------------
57 # The Subs
58  
59 =head1 ADMIN INTERFACE METHODS
60  
61 =over 4
62  
63 =item Admin
64  
65 Provides list of the talks currently available.
66  
67 =item Add
68  
69 Add a new talk.
70  
71 =item Edit
72  
73 Edit an existing talk.
74  
75 =item Save
76  
77 Save the current talk.
78  
79 =item Delete
80  
81 Delete a talk.
82  
83 =item EventSelect
84  
85 Provides a dropdown list of events available.
86  
87 =back
88  
89 =cut
90  
91 sub Admin {
92 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
93  
94 0 ▶ if($cgiparams{doaction}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Talks::cgiparams{"doaction"}) 0 0 0
95 0 ▶ if($cgiparams{doaction} eq 'Delete') { Delete(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Talks::cgiparams{"doaction"} eq "Delete") 0 0 0
96 }
97  
98 0 my @rows = $dbi->GetQuery('hash','AllTechTalks');
99 0 ▶ $tvars{data} = \@rows if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
100 }
101  
102 sub Add {
103 0 ▶ my $self = shift;
Subroutine Add: not called CC=3 SCAR=24.8
Pod documented
104  
105 0 ▶ return unless AccessUser(EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
106 0 ▶ return unless AuthorCheck('GetEventByID','eventid',EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetEventByID", "eventid", 2) 0 0 0
107  
108 0 $tvars{data}{ddusers} = UserSelect(0,1,0,'Speaker',1);
109 0 $tvars{data}{ddevents} = $self->EventSelect($cgiparams{eventid});
110 }
111  
112 sub Edit {
113 0 ▶ my $self = shift;
Subroutine Edit: not called CC=7 SCAR=40.3
Pod documented
114  
115 0 ▶ return unless AccessUser(EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
116 0 ▶ return unless AuthorCheck('GetEventByID','eventid',EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetEventByID", "eventid", 2) 0 0 0
117  
118 0 ▶ if($cgiparams{talkid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Talks::cgiparams{"talkid"}) 0 0 0
119 0 my @rows = $dbi->GetQuery('hash','GetTechTalkByID',$cgiparams{talkid});
120 0 ▶ $tvars{data} = $rows[0] if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
121 0 $tvars{data}{abstracted} = $tvars{data}{abstract};
122 0 $tvars{data}{resourced} = $tvars{data}{resource};
123 0 ▶ $cgiparams{eventid} ||= $tvars{data}{eventid};
Condition0%0/3
$Labyrinth::Plugin::Event::Talks::cgiparams{"eventid"} ||= $Labyrinth::Plugin::Event::Talks::tvars{"data"}{"eventid"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Labyrinth::Plugin::Event::Talks::cgiparams{"eventid"} ||= $Labyrinth::Plugin::Event::Talks::tvars{"data"}{"eventid"}
$Labyrinth::Plugin::Event::Talks::cgiparams{"eventid"} $Labyrinth::Plugin::Event::Talks::tvars{"data"}{"eventid"}
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Event::Talks::cgiparams{"eventid"}B= $Labyrinth::Plugin::Event::Talks::tvars{"data"}{"eventid"}
ABresult
1X1
011
000
124 }
125  
126 0 ▶ my $opt = $cgiparams{talkid} ? $tvars{data}{userid} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Event::Talks::cgiparams{'talkid'} ? : 0 0 0
127 0 $tvars{data}{ddusers} = UserSelect($opt,1,0,'Speaker',1);
128 0 $tvars{data}{ddevents} = $self->EventSelect($cgiparams{eventid});
129 }
130  
131 sub Save {
132 0 ▶ return unless AccessUser(EDITOR);
Subroutine Save: not called CC=11 SCAR=48.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
133 0 ▶ return unless AuthorCheck('GetEventByID','eventid',EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetEventByID", "eventid", 2) 0 0 0
134  
135 0 ▶ my $opt = $cgiparams{talkid} ? $tvars{data}{userid} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Event::Talks::cgiparams{'talkid'} ? : 0 0 0
136 0 $tvars{data}{ddusers} = UserSelect($opt,1,0,'Speaker',1);
137  
138 0 ▶ return if FieldCheck(\@allfields,\@mandatory);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@allfields, \@mandatory) 0 0 0
139  
140 0 ▶ $tvars{data}{guest} = ($tvars{data}{guest} ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Event::Talks::tvars{'data'}{'guest'} ? : 0 0 0
141 0 for(keys %fields) {
142 0 ▶ next unless($fields{$_});
Branch: 1 branch
BranchTrueFalseTotal
unless $fields{$_} 0 0 0
143 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
144 0 elsif($fields{$_}->{html} == 2) { $tvars{data}{$_} = CleanTags($tvars{data}{$_}) }
145 }
146  
147  
148 my @fields = ( $tvars{data}{eventid},
149 $tvars{data}{userid},
150 $tvars{data}{guest},
151 $tvars{data}{talktitle},
152 $tvars{data}{abstract},
153 $tvars{data}{resource}
154 0 );
155  
156 0 ▶ if($cgiparams{talkid})
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Event::Talks::cgiparams{'talkid'}) { } 0 0 0
157 0 { $dbi->DoQuery('SaveTechTalk',@fields,$cgiparams{talkid}); }
158 0 else { $cgiparams{talkid} = $dbi->IDQuery('AddTechTalk',@fields); }
159 }
160  
161 sub Delete {
162 0 ▶ return unless AccessUser(ADMIN);
Subroutine Delete: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(4) 0 0 0
163 0 my @ids = CGIArray('LISTED');
164 0 ▶ return unless @ids;
Branch: 1 branch
BranchTrueFalseTotal
unless @ids 0 0 0
165  
166 0 for my $id (@ids) {
167 0 $cgiparams{'talkid'} = $id;
168 0 ▶ next unless AuthorCheck('GetTechTalkByID','talkid',EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetTechTalkByID", "talkid", 2) 0 0 0
169  
170 0 $dbi->DoQuery('DeleteTechTalk',$cgiparams{'talkid'});
171 }
172 }
173  
174 sub EventSelect {
175 0 ▶ my ($self,$opt,$blank) = @_;
Subroutine EventSelect: not called CC=4 SCAR=30.0
Pod documented
176 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
177  
178 0 my @list;
179 0 my @rows = $dbi->GetQuery('hash','AllTalkEvents');
180 0 for(@rows) { push @list, { id => $_->{eventid}, value => $_->{eventdate} . ' - ' . $_->{title} }; }
181 0 ▶ unshift @list, { id => 0, value => 'Select Event'} if($blank == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $blank == 1 0 0 0
182 0 DropDownRows($opt,'eventid','id','value',@list);
183 }
184  
185 5 1;
186  
187 __END__
188  
189 =head1 SEE ALSO
190  
191 L<Labyrinth>
192  
193 =head1 AUTHOR
194  
195 Barbie, <barbie@missbarbell.co.uk> for
196 Miss Barbell Productions, L<http://www.missbarbell.co.uk/>
197  
198 =head1 COPYRIGHT & LICENSE
199  
200 Copyright (C) 2002-2015 Barbie for Miss Barbell Productions
201 All Rights Reserved.
202  
203 This module is free software; you can redistribute it and/or
204 modify it under the Artistic License 2.0.
205  
206 =cut
« Event.pm ↑ Summary Event/Venues.pm »