Review.pm

filter: Statementstmt 31.4% 61 / 194 Branchbran 1.9% 2 / 104 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 58.0% 18 / 31 Podpod 100% 11 / 11 totaltotal 23.9% 92 / 384 CC 68 SCAR 48.6
CC
68
Cov
19%
Edit
420.0
List
132.0
Save
132.0
CRAP 129.6
↑ Summary Review/Retailers.pm »
1 package Labyrinth::Plugin::Review;
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.01';
8  
9 =head1 NAME
10  
11 Labyrinth::Plugin::Review - Reviews plugin for the Labyrinth framework
12  
13 =head1 DESCRIPTION
14  
15 Contains all the functionality for book reviews.
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 5 ▶use Labyrinth::Audit;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use Labyrinth::DBUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use Labyrinth::DTUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use Labyrinth::MLUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 5 ▶use Labyrinth::Media;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 5 ▶use Labyrinth::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 5 ▶use Labyrinth::Support;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 5 ▶use Labyrinth::Users;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 5 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 5 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 # -------------------------------------
38 # Constants
39  
40 5 ▶use constant FRONTPAGE => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 5 ▶use constant COVER_WIDTH => 150;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 5 ▶use constant COVER_HEIGHT => 200;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 # -------------------------------------
45 # Variables
46  
47 # type: 0 = optional, 1 = mandatory
48 # html: 0 = none, 1 = text, 2 = textarea
49  
50 5 my %fields = (
51 # review references
52 reviewid => { type => 0, html => 0 },
53 title => { type => 1, html => 1 },
54 userid => { type => 1, html => 0 },
55 reviewtypeid => { type => 1, html => 0 },
56 postdate => { type => 1, html => 0 },
57 imageid => { type => 0, html => 0 },
58 snippet => { type => 0, html => 2 },
59 body => { type => 1, html => 2 },
60 publish => { type => 1, html => 0 },
61 additional => { type => 0, html => 1 },
62  
63 # item references
64 brand => { type => 1, html => 1 },
65 retailerid => { type => 1, html => 0 },
66 itemcode => { type => 1, html => 0 },
67 itemlink => { type => 1, html => 0 },
68 );
69  
70 5 my (@mandatory,@allfields);
71 5 for(keys %fields) {
72 70 ▶ push @mandatory, $_ if($fields{$_}->{type});
Branch: 1 branch
BranchTrueFalseTotal
if $fields{$_}{"type"} 50 20 70
73 70 push @allfields, $_;
74 }
75  
76 # -------------------------------------
77 # The Subs
78  
79 =head1 PUBLIC INTERFACE METHODS
80  
81 =over 4
82  
83 =item * FrontPage
84  
85 Provides the an abbreviated list of the latest reviews to use on the front
86 page or a side panel of the website.
87  
88 =item * List
89  
90 Provides a full list, filtered based on any search criteria, of reviews for
91 the main reviews page on the website.
92  
93 =item * Item
94  
95 Provides all the details for a specific review.
96  
97 =back
98  
99 =cut
100  
101 0 ▶sub FrontPage {
Subroutine FrontPage: not called CC=7 SCAR=40.3
Pod documented
102 0 my @rows;
103 0 my @time = split("/",formatDate(9));
104 0 my $this = "$time[0]/$time[1]";
105 0 $time[1]--;
106 0 ▶ if($time[1] < 1) { $time[0]--;$time[1]=12; }
Branch: 1 branch
BranchTrueFalseTotal
if ($time[1] < 1) 0 0 0
107 0 my $that = "$time[0]/$time[1]";
108  
109  
110 0 ▶ my $stop = $settings{'frontpage'} || FRONTPAGE;
Condition0%0/2
$Labyrinth::Plugin::Review::settings{'frontpage'} || 10
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Review::settings{'frontpage'} || 10
$Labyrinth::Plugin::Review::settings{'frontpage'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Review::settings{'frontpage'}
Aresult
11
00
111 0 my $next = $dbi->Iterator('hash','PubReviews');
112 0 ▶ while(@rows < $stop && (my $row = $next->())) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rows < $stop and my $row = &$next()) 0 0 0
Condition0%0/3
@rows < $stop and my $row = &$next()
!ll&&!rl&&r
000
MC/DC0%0/2
@rows < $stop and my $row = &$next()
@rows < $stop my $row = &$next()
Truth table0%0/3
A and B
A= @rows < $stopB= my $row = &$next()
ABresult
0X0
100
111
113 0 ▶ $row->{new} = ($row->{createdate} =~ m!^($this|$that)! ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$row->{'createdate'} =~ /^($this|$that)/ ? : 0 0 0
114 0 push @rows, $row;
115 }
116 0 ▶ $tvars{reviews} = \@rows if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
117 }
118  
119 0 ▶sub List {
Subroutine List: not called CC=11 SCAR=48.8
Pod documented
120 0 ▶ my $publish = 3 unless($tvars{command} eq 'admin');
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Review::tvars{"command"} eq "admin" 0 0 0
121  
122 0 my @where;
123 0 ▶ push @where, "r.publish=$publish" if($publish);
Branch: 1 branch
BranchTrueFalseTotal
if $publish 0 0 0
124 0 ▶ push @where, "r.title LIKE '%$cgiparams{'searchtitle'}%'" if($cgiparams{'searchtitle'});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::cgiparams{"searchtitle"} 0 0 0
125 0 ▶ push @where, "r.reviewtypeid=$cgiparams{'reviewtypeid'}" if($cgiparams{'reviewtypeid'});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::cgiparams{"reviewtypeid"} 0 0 0
126 0 ▶ push @where, "r.userid=$cgiparams{'userid'}" if($cgiparams{'userid'});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::cgiparams{"userid"} 0 0 0
127 0 ▶ push @where, "r.brand=$cgiparams{'brand'}" if($cgiparams{'brand'});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::cgiparams{"brand"} 0 0 0
128 0 ▶ push @where, "r.retailerid=$cgiparams{'retailerid'}" if($cgiparams{'retailerid'});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::cgiparams{"retailerid"} 0 0 0
129 0 ▶ my $where = @where ? 'WHERE '.join(' AND ',@where) : '';
Branch: 1 branch
BranchTrueFalseTotal
@where ? : 0 0 0
130  
131 0 my @rows = $dbi->GetQuery('hash','AllReviews',{where=>$where});
132 0 foreach (@rows) {
133 0 $_->{publishstate} = PublishState($_->{publish});
134 0 $_->{postdate} = formatDate(3,$_->{createdate});
135 }
136 0 ▶ $tvars{data} = \@rows if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
137  
138 0 $tvars{searchtitle} = $cgiparams{searchtitle};
139 0 $tvars{ddreviewers} = UserSelect($cgiparams{userid},1,1,'Reviewer');
140 0 $tvars{ddrevtypes} = _dropdownReviewTypes($cgiparams{reviewtypeid},1);
141 0 $tvars{ddretailers} = _dropdownRetailers($cgiparams{retailerid},1);
142 }
143  
144 0 ▶sub Item {
Subroutine Item: not called CC=8 SCAR=42.8
Pod documented
145 0 ▶ return unless($cgiparams{'reviewid'});
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Review::cgiparams{"reviewid"} 0 0 0
146  
147 0 my @rows = $dbi->GetQuery('hash','GetReviewByID',$cgiparams{'reviewid'});
148 0 ▶ return unless(@rows);
Branch: 1 branch
BranchTrueFalseTotal
unless @rows 0 0 0
149  
150 0 ▶ if($rows[0]->{'imageid'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rows[0]{"imageid"}) 0 0 0
151 0 my @img = $dbi->GetQuery('hash','GetImageByID',$rows[0]->{'imageid'});
152 0 ▶ $rows[0]->{'image_link'} = $img[0]->{'link'} if(@img);
Branch: 1 branch
BranchTrueFalseTotal
if @img 0 0 0
153 }
154  
155 0 ▶ $rows[0]->{body} = '<p>' . $rows[0]->{body} unless($rows[0]->{body} =~ /^<p>/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $rows[0]{"body"} =~ /^<p>/i 0 0 0
156 0 $tvars{data} = $rows[0];
157  
158 0 ▶ if($tvars{data}->{additional}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::tvars{"data"}{"additional"}) 0 0 0
159 0 my $html = '';
160 0 my @links = split ",", $tvars{data}->{additional};
161 0 foreach my $link (@links) {
162 0 my ($name,$url) = split "=", $link;
163 0 $html .= qq!<a href="$url" title="link to $name">$name</a><br />!;
164 }
165 0 $tvars{data}->{additional} = $html;
166 }
167 }
168  
169 =head1 ADMIN INTERFACE METHODS
170  
171 =over 4
172  
173 =item * Access
174  
175 Check default access to the Admin methods
176  
177 =item * Admin
178  
179 List reviews for administration purposes.
180  
181 =item * Add
182  
183 Add a review.
184  
185 =item * PreEdit
186  
187 Following an add review page, there may be additional lookuos required to
188 check the validity of the product code given. This may be an additonal API
189 call to a 3rd party website, and is most likely to be used by sub-classed
190 modules.
191  
192 Requires a call to the Edit method to display current values.
193  
194 =item * Copy
195  
196 Copies an existing review to a new review. Typical when you want to use the
197 same product to review, and just want to use the same product references.
198  
199 Requires a call to the Edit method to display current values.
200  
201 =item * Edit
202  
203 Edit a review.
204  
205 =item * Save
206  
207 Save a review.
208  
209 =item * Delete
210  
211 Delete one or more reviews.
212  
213 =back
214  
215 =cut
216  
217 0 ▶sub Access { Authorised(EDITOR) }
Subroutine Access: not called CC=1 SCAR=6.9
Pod documented
218  
219 0 ▶sub Admin {
Subroutine Admin: not called CC=5 SCAR=34.0
Pod documented
220 0 ▶ return unless AccessUser(EDITOR);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(2) 0 0 0
221  
222 0 ▶ if($cgiparams{doaction}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::cgiparams{"doaction"}) 0 0 0
223 0 ▶ if($cgiparams{doaction} eq 'Delete') { Delete(); }
Branch: 2 branches
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::cgiparams{'doaction'} eq 'Delete') { } 0 0 0
elsif ($Labyrinth::Plugin::Review::cgiparams{'doaction'} eq 'Copy') { } 0 0 0
224 0 elsif($cgiparams{doaction} eq 'Copy') { Copy(); }
225 }
226  
227 0 List();
228 }
229  
230 0 ▶sub Add {
Subroutine Add: not called CC=2 SCAR=17.9
Pod documented
231 0 AccessUser(EDITOR);
232  
233 0 my $select;
234 0 ▶ if(Authorised(PUBLISHER)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Authorised(3)) { } 0 0 0
235 0 $select = UserSelect(0,1);
236 } else {
237 0 $select = DropDownRows($tvars{user}->{userid},'userid','userid','name',{userid => $tvars{user}->{userid}, name => $tvars{user}->{name}});
238 }
239  
240 0 my %data = (
241 ddreviewers => $select,
242 ddretailers => _dropdownRetailers(),
243 ddrevtypes => _dropdownReviewTypes(),
244 postdate => formatDate(3),
245 );
246  
247 0 $tvars{data} = \%data;
248 0 $tvars{preedit} = 1;
249 }
250  
251 0 ▶sub PreEdit {
Subroutine PreEdit: not called CC=2 SCAR=17.9
Pod documented
252 0 my @man = qw(userid reviewtypeid postdate itemcode);
253 0 ▶ return if FieldCheck(\@mandatory,\@mandatory);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@mandatory, \@mandatory) 0 0 0
254  
255 0 $tvars{data}->{realname} = UserName($tvars{data}->{userid});
256 0 $tvars{data}->{createdate} = unformatDate(3,$tvars{data}->{postdate});
257 }
258  
259 0 ▶sub Copy {
Subroutine Copy: not called CC=2 SCAR=17.9
Pod documented
260 0 $cgiparams{'reviewid'} = $cgiparams{'LISTED'};
261 0 ▶ return unless AuthorCheck('GetReviewByID','reviewid',PUBLISHER);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetReviewByID", "reviewid", 3) 0 0 0
262  
263 my @fields = (
264 $tvars{data}->{reviewtypeid},0,
265 $tvars{data}->{title},
266 $tvars{data}->{brand},
267 $tvars{data}->{itemcode},
268 $tvars{data}->{userid},
269 $tvars{data}->{createdate},
270 $tvars{data}->{snippet},
271 $tvars{data}->{body},
272 $tvars{data}->{imageid},
273 $tvars{data}->{itemlink},
274 $tvars{data}->{retailerid},
275 0 1
276 );
277  
278 0 $cgiparams{reviewid} = $dbi->IDQuery('AddReview',@fields);
279 }
280  
281 0 ▶sub Edit {
Subroutine Edit: not called CC=20 SCAR=60.4
Pod documented
282 0 ▶ if($cgiparams{reviewid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::cgiparams{"reviewid"}) 0 0 0
283 0 ▶ return unless AuthorCheck('GetReviewByID','reviewid',PUBLISHER);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetReviewByID", "reviewid", 3) 0 0 0
284  
285 0 ▶ if($tvars{data}->{'imageid'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::tvars{"data"}{"imageid"}) 0 0 0
286 0 my @img = $dbi->GetQuery('hash','GetImageByID',$tvars{data}->{'imageid'});
287 0 ▶ $tvars{data}->{'image_link'} = $img[0]->{'link'} if(@img);
Branch: 1 branch
BranchTrueFalseTotal
if @img 0 0 0
288 }
289  
290 0 ▶ if($tvars{data}->{publish} == 4 && $tvars{command} ne 'view') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 4 and $Labyrinth::Plugin::Review::tvars{"command"} ne "view") 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 4 and $Labyrinth::Plugin::Review::tvars{"command"} ne "view"
!ll&&!rl&&r
000
MC/DC0%0/2
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 4 and $Labyrinth::Plugin::Review::tvars{"command"} ne "view"
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 4 $Labyrinth::Plugin::Review::tvars{"command"} ne "view"
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 4B= $Labyrinth::Plugin::Review::tvars{"command"} ne "view"
ABresult
0X0
100
111
291 0 $tvars{errcode} = 'FAILURE';
292 0 return;
293 }
294 }
295  
296 0 my $select;
297 0 ▶ if(Authorised(PUBLISHER)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Authorised(3)) { } 0 0 0
298 0 $select = UserSelect($tvars{data}->{userid},1,1);
299 } else {
300 0 $select = DropDownRows($tvars{user}->{userid},'userid','userid','name',{userid => $tvars{user}->{userid}, name => $tvars{user}->{name}});
301 }
302  
303 0 my $promote = 0;
304 0 ▶ $promote = 1 if($tvars{data}->{publish} == 1 && Authorised(EDITOR));
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 1 and Authorised(2) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 1 and Authorised(2)
!ll&&!rl&&r
000
MC/DC0%0/2
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 1 and Authorised(2)
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 1 Authorised(2)
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 1B= Authorised(2)
ABresult
0X0
100
111
305 0 ▶ $promote = 1 if($tvars{data}->{publish} == 2 && Authorised(PUBLISHER));
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 2 and Authorised(3) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 2 and Authorised(3)
!ll&&!rl&&r
000
MC/DC0%0/2
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 2 and Authorised(3)
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 2 Authorised(3)
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 2B= Authorised(3)
ABresult
0X0
100
111
306 0 ▶ $promote = 1 if($tvars{data}->{publish} == 3 && Authorised(PUBLISHER));
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 3 and Authorised(3) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 3 and Authorised(3)
!ll&&!rl&&r
000
MC/DC0%0/2
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 3 and Authorised(3)
$Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 3 Authorised(3)
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Review::tvars{"data"}{"publish"} == 3B= Authorised(3)
ABresult
0X0
100
111
307 0 $tvars{data}->{ddpublish} = PublishAction($tvars{data}->{publish},$promote);
308 0 ▶ $tvars{data}->{ddpublish} = PublishSelect($tvars{data}->{publish}) if(Authorised(ADMIN));
Branch: 1 branch
BranchTrueFalseTotal
if Authorised(4) 0 0 0
309  
310 0 $tvars{data}->{ddreviewers} = $select;
311 0 $tvars{data}->{ddretailers} = _dropdownRetailers($tvars{data}->{retailerid});
312 0 $tvars{data}->{ddrevtypes} = _dropdownReviewTypes($tvars{data}->{reviewtypeid});
313 0 $tvars{data}->{postdate} = formatDate(3,$tvars{data}->{createdate});
314  
315 0 $tvars{preview} = clone($tvars{data}); # data fields need to be editable
316  
317 0 for(keys %fields) {
318 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
319 0 $tvars{preview}->{$_} = CleanHTML($tvars{preview}->{$_}); }
320 0 elsif($fields{$_}->{html} == 2) { $tvars{data}->{$_} = SafeHTML($tvars{data}->{$_}); }
321 }
322  
323 0 ▶ if($tvars{data}->{additional}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::tvars{"data"}{"additional"}) 0 0 0
324 0 my $html = '';
325 0 my @links = split ",", $tvars{data}->{additional};
326 0 foreach my $link (@links) {
327 0 my ($name,$url) = split "=", $link;
328 0 $html .= qq!<a href="$url" title="link to $name">$name</a><br />!;
329 }
330 0 $tvars{preview}->{additional} = $html;
331 }
332 }
333  
334 0 ▶sub Save {
Subroutine Save: not called CC=11 SCAR=48.8
Pod documented
335 0 ▶ return unless AuthorCheck('GetReviewByID','reviewid',PUBLISHER);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetReviewByID", "reviewid", 3) 0 0 0
336 0 ▶ return if FieldCheck(\@allfields,\@mandatory);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@allfields, \@mandatory) 0 0 0
337  
338 0 for(keys %fields) {
339 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
340 0 elsif($fields{$_}->{html} == 2) { $tvars{data}->{$_} = CleanTags($tvars{data}->{$_}) }
341 }
342  
343 0 ▶ $tvars{data}->{createdate} = unformatDate(3,$tvars{data}->{postdate}) if($tvars{data}->{postdate});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::tvars{"data"}{"postdate"} 0 0 0
344 ($tvars{data}->{imageid}) = SaveImageFile(
345 param => 'image_link',
346 width => $settings{review_cover_width} || COVER_WIDTH,
347 height => $settings{review_cover_height} || COVER_HEIGHT,
348 stock => 'Covers'
349 0 ▶ ) if($cgiparams{image_link});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Review::cgiparams{"image_link"} 0 0 0
Condition0%0/4
$Labyrinth::Plugin::Review::settings{'review_cover_width'} || 150
l!l
00
$Labyrinth::Plugin::Review::settings{'review_cover_height'} || 200
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Review::settings{'review_cover_width'} || 150
$Labyrinth::Plugin::Review::settings{'review_cover_width'}
MC/DC0%0/1
$Labyrinth::Plugin::Review::settings{'review_cover_height'} || 200
$Labyrinth::Plugin::Review::settings{'review_cover_height'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Review::settings{'review_cover_width'}
Aresult
11
00
Truth table0%0/2
A
A= $Labyrinth::Plugin::Review::settings{'review_cover_height'}
Aresult
11
00
350  
351 my @fields = (
352 $tvars{data}->{reviewtypeid},
353 0,
354 $tvars{data}->{title},
355 $tvars{data}->{brand},
356 $tvars{data}->{itemcode},
357 $tvars{data}->{userid},
358 $tvars{data}->{createdate},
359 $tvars{data}->{snippet},
360 $tvars{data}->{body},
361 $tvars{data}->{imageid},
362 $tvars{data}->{itemlink},
363 $tvars{data}->{retailerid},
364 $tvars{data}->{publish}
365 0 );
366  
367 # store review details
368 0 ▶ if($tvars{data}->{reviewid})
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Review::tvars{'data'}{'reviewid'}) { } 0 0 0
369 0 { $dbi->DoQuery('SaveReview',@fields,$tvars{data}->{reviewid}); }
370 0 else { $cgiparams{reviewid} = $dbi->IDQuery('AddReview',@fields); }
371  
372 0 $tvars{thanks} = 1;
373 }
374  
375 0 ▶sub Delete {
Subroutine Delete: not called CC=5 SCAR=34.0
Pod documented
376 0 ▶ return unless AccessUser(PUBLISHER);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser(3) 0 0 0
377 0 my @ids = CGIArray('LISTED');
378 0 ▶ return unless @ids;
Branch: 1 branch
BranchTrueFalseTotal
unless @ids 0 0 0
379  
380 0 for my $id (@ids) {
381 0 $cgiparams{'reviewid'} = $id;
382 0 ▶ next unless AuthorCheck('GetReviewByID','reviewid',PUBLISHER);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetReviewByID", "reviewid", 3) 0 0 0
383 0 $dbi->DoQuery('DeleteReview',$cgiparams{'reviewid'});
384 }
385 }
386  
387 # -------------------------------------
388 # Private Methods
389  
390 0 ▶sub _dropdownRetailers {
Subroutine _dropdownRetailers: not called CC=3 SCAR=24.8
391 0 my ($select,$blank) = @_;
392 0 my @rows = $dbi->GetQuery('hash','AllRetailers');
393 0 ▶ unshift @rows, {retailerid=>0,retailer=>'Select Retailer'} if(defined $blank && $blank == 1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $blank and $blank == 1 0 0 0
Condition0%0/3
defined $blank and $blank == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $blank and $blank == 1
defined $blank $blank == 1
Truth table0%0/3
A and B
A= defined $blankB= $blank == 1
ABresult
0X0
100
111
394 0 return DropDownRows($select,'retailerid','retailerid','retailer',@rows);
395 }
396  
397 0 ▶sub _dropdownReviewTypes {
Subroutine _dropdownReviewTypes: not called CC=3 SCAR=24.8
398 0 my ($select,$blank) = @_;
399 0 my @rows = $dbi->GetQuery('hash','AllReviewTypes');
400 0 ▶ unshift @rows, {reviewtypeid=>0,typename=>'Select Review Type'} if(defined $blank && $blank == 1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $blank and $blank == 1 0 0 0
Condition0%0/3
defined $blank and $blank == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $blank and $blank == 1
defined $blank $blank == 1
Truth table0%0/3
A and B
A= defined $blankB= $blank == 1
ABresult
0X0
100
111
401 0 return DropDownRows($select,'reviewtypeid','reviewtypeid','typename',@rows);
402 }
403  
404 5 1;
405  
406 __END__
↑ Summary Review/Retailers.pm »