| 1 | package Labyrinth::Plugin::Review::Types; | ||||||||||||||
| 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.00'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | =head1 NAME | ||||||||||||||
| 10 | |||||||||||||||
| 11 | Labyrinth::Plugin::Review::Types - Review Types plugin for the Labyrinth framework | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||
| 14 | |||||||||||||||
| 15 | Contains all the functionality for managing review types for reviews. | ||||||||||||||
| 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::Audit; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 25 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 27 | |||||||||||||||
| 28 | 4 | ▶ | use Data::Dumper; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 29 | |||||||||||||||
| 30 | # ------------------------------------- | ||||||||||||||
| 31 | # Variables | ||||||||||||||
| 32 | |||||||||||||||
| 33 | # type: 0 = optional, 1 = mandatory | ||||||||||||||
| 34 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 4 | my %fields = ( | |||||||||||||
| 37 | reviewtypeid => { type => 0, html => 0 }, | ||||||||||||||
| 38 | typename => { type => 1, html => 1 }, | ||||||||||||||
| 39 | typeabbr => { type => 1, html => 1 }, | ||||||||||||||
| 40 | ); | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 4 | my (@mandatory,@allfields); | |||||||||||||
| 43 | 4 | for(keys %fields) { | |||||||||||||
| 44 | 12 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 45 | 12 | push @allfields, $_; | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | # ------------------------------------- | ||||||||||||||
| 49 | # The Subs | ||||||||||||||
| 50 | |||||||||||||||
| 51 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =over 4 | ||||||||||||||
| 54 | |||||||||||||||
| 55 | =item * Access | ||||||||||||||
| 56 | |||||||||||||||
| 57 | Check default access to the Admin methods | ||||||||||||||
| 58 | |||||||||||||||
| 59 | =item * Admin | ||||||||||||||
| 60 | |||||||||||||||
| 61 | List entries for administration purposes. | ||||||||||||||
| 62 | |||||||||||||||
| 63 | =item * Add | ||||||||||||||
| 64 | |||||||||||||||
| 65 | Add a review type. | ||||||||||||||
| 66 | |||||||||||||||
| 67 | =item * Edit | ||||||||||||||
| 68 | |||||||||||||||
| 69 | Edit a review type. | ||||||||||||||
| 70 | |||||||||||||||
| 71 | =item * Save | ||||||||||||||
| 72 | |||||||||||||||
| 73 | Save a review type. | ||||||||||||||
| 74 | |||||||||||||||
| 75 | =item * Delete | ||||||||||||||
| 76 | |||||||||||||||
| 77 | Delete one or more review types. | ||||||||||||||
| 78 | |||||||||||||||
| 79 | =back | ||||||||||||||
| 80 | |||||||||||||||
| 81 | =cut | ||||||||||||||
| 82 | |||||||||||||||
| 83 | 0 | ▶ | sub Access { Authorised(PUBLISHER) } | ||||||||||||
|
Subroutine
Access: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 84 | |||||||||||||||
| 85 | sub Admin { | ||||||||||||||
| 86 | 0 | ▶ | return unless AccessUser(PUBLISHER); | ||||||||||||
|
Subroutine
Admin: not called CC=5 SCAR=34.0
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 87 | |||||||||||||||
| 88 | 0 | ▶ | if($cgiparams{doaction}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 89 | 0 | ▶ | if($cgiparams{doaction} eq 'Delete') { Delete(); } | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 90 | } | ||||||||||||||
| 91 | |||||||||||||||
| 92 | 0 | my @rows = $dbi->GetQuery('hash','AllReviewTypes'); | |||||||||||||
| 93 | 0 | ▶ | $tvars{data} = \@rows if(@rows); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 94 | } | ||||||||||||||
| 95 | |||||||||||||||
| 96 | sub Add { | ||||||||||||||
| 97 | 0 | ▶ | return unless AccessUser(PUBLISHER); | ||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 98 | } | ||||||||||||||
| 99 | |||||||||||||||
| 100 | sub Edit { | ||||||||||||||
| 101 | 0 | ▶ | return unless AccessUser(PUBLISHER); | ||||||||||||
|
Subroutine
Edit: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 102 | 0 | ▶ | return unless AuthorCheck('GetReviewTypeByID','reviewtypeid',PUBLISHER); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 103 | } | ||||||||||||||
| 104 | |||||||||||||||
| 105 | sub Save { | ||||||||||||||
| 106 | 0 | ▶ | return unless AuthorCheck('GetReviewTypeByID','reviewtypeid',PUBLISHER); | ||||||||||||
|
Subroutine
Save: not called CC=7 SCAR=40.3
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 107 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 108 | |||||||||||||||
| 109 | 0 | for(keys %fields) { | |||||||||||||
| 110 | 0 | ▶ | if($fields{$_}->{html} == 1) { $tvars{data}->{$_} = CleanHTML($tvars{data}->{$_}) } | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 111 | 0 | elsif($fields{$_}->{html} == 2) { $tvars{data}->{$_} = CleanTags($tvars{data}->{$_}) } | |||||||||||||
| 112 | } | ||||||||||||||
| 113 | |||||||||||||||
| 114 | my @fields = ( | ||||||||||||||
| 115 | $tvars{data}->{typename}, | ||||||||||||||
| 116 | $tvars{data}->{typeabbr} | ||||||||||||||
| 117 | 0 | ); | |||||||||||||
| 118 | |||||||||||||||
| 119 | # store review details | ||||||||||||||
| 120 | 0 | ▶ | if($tvars{data}->{reviewtypeid}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 121 | 0 | { $dbi->DoQuery('SaveReviewType',@fields,$tvars{data}->{reviewtypeid}); } | |||||||||||||
| 122 | 0 | else { $cgiparams{reviewtypeid} = $dbi->IDQuery('AddReviewType',@fields); } | |||||||||||||
| 123 | |||||||||||||||
| 124 | 0 | $tvars{thanks} = 1; | |||||||||||||
| 125 | } | ||||||||||||||
| 126 | |||||||||||||||
| 127 | sub Delete { | ||||||||||||||
| 128 | 0 | ▶ | return unless AccessUser(PUBLISHER); | ||||||||||||
|
Subroutine
Delete: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 129 | 0 | my @ids = CGIArray('LISTED'); | |||||||||||||
| 130 | 0 | ▶ | return unless @ids; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 131 | |||||||||||||||
| 132 | 0 | $dbi->DoQuery('DeleteReviewTypes',{ ids => join(',',@ids) }); | |||||||||||||
| 133 | } | ||||||||||||||
| 134 | |||||||||||||||
| 135 | 4 | 1; | |||||||||||||
| 136 | |||||||||||||||
| 137 | __END__ | ||||||||||||||
| 138 | |||||||||||||||
| 139 | =head1 SEE ALSO | ||||||||||||||
| 140 | |||||||||||||||
| 141 | Labyrinth | ||||||||||||||
| 142 | |||||||||||||||
| 143 | =head1 AUTHOR | ||||||||||||||
| 144 | |||||||||||||||
| 145 | Barbie, <barbie@missbarbell.co.uk> for | ||||||||||||||
| 146 | Miss Barbell Productions, L<http://www.missbarbell.co.uk/> | ||||||||||||||
| 147 | |||||||||||||||
| 148 | =head1 COPYRIGHT & LICENSE | ||||||||||||||
| 149 | |||||||||||||||
| 150 | Copyright (C) 2002-2014 Barbie for Miss Barbell Productions | ||||||||||||||
| 151 | All Rights Reserved. | ||||||||||||||
| 152 | |||||||||||||||
| 153 | This module is free software; you can redistribute it and/or | ||||||||||||||
| 154 | modify it under the Artistic License 2.0. | ||||||||||||||
| 155 | |||||||||||||||
| 156 | =cut | ||||||||||||||