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