| 1 | package Labyrinth::Plugin::News; | ||||||||||||||||||||||||||||
| 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 | our $VERSION = '5.19'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Labyrinth::Plugin::News - Plugin News handler for Labyrinth | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Contains all the news handling functionality for the Labyrinth | ||||||||||||||||||||||||||||
| 15 | framework. | ||||||||||||||||||||||||||||
| 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 Clone qw(clone); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use Labyrinth::Globals; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use Labyrinth::DBUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use Labyrinth::DTUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use Labyrinth::Media; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use Labyrinth::Session; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use Labyrinth::Support; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use Labyrinth::Users; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 37 | # Constants | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 4 | ▶ | use constant FRONTPAGE => 5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 4 | ▶ | use constant MAINNEWS => 5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 4 | ▶ | use constant INBRIEF => 10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 44 | # Variables | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||||||||||
| 47 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | my %fields = ( | |||||||||||||||||||||||||||
| 50 | newsid => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||
| 51 | folderid => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||
| 52 | title => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||
| 53 | userid => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||
| 54 | body => { type => 1, html => 2 }, | ||||||||||||||||||||||||||||
| 55 | postdate => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||
| 56 | imageid => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||
| 57 | ALIGN0 => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||
| 58 | front => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||
| 59 | alttag => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||
| 60 | publish => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||
| 61 | href => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 4 | my (@mandatory,@allfields); | |||||||||||||||||||||||||||
| 65 | 4 | for(keys %fields) { | |||||||||||||||||||||||||||
| 66 | 48 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 48 | push @allfields, $_; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 4 | my @savefields = qw(folderid userid title body imageid ALIGN0 front publish createdate); | |||||||||||||||||||||||||||
| 71 | 4 | my @addfields = qw(folderid userid title body imageid ALIGN0 front publish createdate); | |||||||||||||||||||||||||||
| 72 | 4 | my $INDEXKEY = 'newsid'; | |||||||||||||||||||||||||||
| 73 | 4 | my $ALLSQL = 'AllNews'; | |||||||||||||||||||||||||||
| 74 | 4 | my $SAVESQL = 'SaveNews'; | |||||||||||||||||||||||||||
| 75 | 4 | my $ADDSQL = 'AddNews'; | |||||||||||||||||||||||||||
| 76 | 4 | my $GETSQL = 'GetNewsByID'; | |||||||||||||||||||||||||||
| 77 | 4 | my $DELETESQL = 'DeleteNews'; | |||||||||||||||||||||||||||
| 78 | 4 | my $PROMOTESQL = 'PromoteNews'; | |||||||||||||||||||||||||||
| 79 | 4 | my $LEVEL = EDITOR; | |||||||||||||||||||||||||||
| 80 | 4 | my $LEVEL2 = ADMIN; | |||||||||||||||||||||||||||
| 81 | 4 | my $NEXTCOMMAND = 'news-edit'; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 84 | # The Subs | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 PUBLIC INTERFACE METHODS | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =over 4 | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item Front | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Front page news items only. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =item Main | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Main news items in full, section in brief, the remainder just titles. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =item Archive | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Archived news items only. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =item Item | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Single specified news items in full. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =back | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub Front { | ||||||||||||||||||||||||||
|
Subroutine
Front: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | my $front = $settings{'frontpage'} || FRONTPAGE; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::settings{'frontpage'} || 5
MC/DC0%0/1
$Labyrinth::Plugin::News::settings{'frontpage'} || 5
$Labyrinth::Plugin::News::settings{'frontpage'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::settings{'frontpage'}
| |||||||||||||||||||||||||||||
| 112 | 0 | my (@mainnews); | |||||||||||||||||||||||||||
| 113 | 0 | my @rows = $dbi->GetQuery('hash','FrontNews',{limit => "LIMIT $front"}); | |||||||||||||||||||||||||||
| 114 | 0 | for my $row (@rows) { | |||||||||||||||||||||||||||
| 115 | 0 | $row->{name} = UserName($row->{userid}); | |||||||||||||||||||||||||||
| 116 | 0 | $row->{postdate} = formatDate(3,$row->{createdate}); | |||||||||||||||||||||||||||
| 117 | 0 | $row->{alignment} = AlignClass($row->{align}); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $tvars{frontnews} = \@rows if(@rows); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub Main { | ||||||||||||||||||||||||||
|
Subroutine
Main: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my $main = $settings{'mainnews'} || MAINNEWS; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::settings{'mainnews'} || 5
MC/DC0%0/1
$Labyrinth::Plugin::News::settings{'mainnews'} || 5
$Labyrinth::Plugin::News::settings{'mainnews'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::settings{'mainnews'}
| |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my $brief = $settings{'inbrief'} || INBRIEF; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::settings{'inbrief'} || 10
MC/DC0%0/1
$Labyrinth::Plugin::News::settings{'inbrief'} || 10
$Labyrinth::Plugin::News::settings{'inbrief'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::settings{'inbrief'}
| |||||||||||||||||||||||||||||
| 125 | 0 | my (@mainnews,@inbrief,@archive); | |||||||||||||||||||||||||||
| 126 | 0 | my @rows = $dbi->GetQuery('hash','PubNews'); | |||||||||||||||||||||||||||
| 127 | 0 | foreach my $row (@rows) { | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | last unless($brief); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | # first n stories in full | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if($main) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | $row->{name} = UserName($row->{userid}); | |||||||||||||||||||||||||||
| 132 | 0 | $row->{postdate} = formatDate(3,$row->{createdate}); | |||||||||||||||||||||||||||
| 133 | 0 | $row->{alignment} = AlignClass($row->{align}); | |||||||||||||||||||||||||||
| 134 | 0 | push @mainnews, $row; | |||||||||||||||||||||||||||
| 135 | 0 | $main--; | |||||||||||||||||||||||||||
| 136 | 0 | next; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | # next n stories in brief | ||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if($brief) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | push @inbrief, {newsid => $row->{newsid}, title => $row->{title}, snippet => substr(CleanHTML($row->{body}),0,(82-length($row->{title})))}; | |||||||||||||||||||||||||||
| 141 | 0 | $brief--; | |||||||||||||||||||||||||||
| 142 | 0 | next; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | # remaining stories, just titles | ||||||||||||||||||||||||||||
| 145 | 0 | push @archive, {newsid => $row->{newsid}, title => $row->{title}}; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $tvars{news}{main} = \@mainnews if(@mainnews); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $tvars{news}{brief} = \@inbrief if(@inbrief); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $tvars{news}{other} = \@archive if(@archive); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub Archive { | ||||||||||||||||||||||||||
|
Subroutine
Archive: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | 0 | my (@archive); | |||||||||||||||||||||||||||
| 154 | 0 | my @rows = $dbi->GetQuery('hash','OldNews'); | |||||||||||||||||||||||||||
| 155 | 0 | foreach my $row (@rows) { | |||||||||||||||||||||||||||
| 156 | 0 | push @archive, {newsid => $row->{newsid}, title => $row->{title}, snippet => substr(CleanHTML($row->{body}),0,(82-length($row->{title})))}; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $tvars{archive} = \@archive if(@archive); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub Item { | ||||||||||||||||||||||||||
|
Subroutine
Item: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return unless($cgiparams{'newsid'}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | my @rows = $dbi->GetQuery('hash','GetNewsByID',$cgiparams{'newsid'}); | |||||||||||||||||||||||||||
| 164 | 0 | ▶ | if(@rows) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 0 | $rows[0]->{name} = UserName($rows[0]->{userid}); | |||||||||||||||||||||||||||
| 166 | 0 | $rows[0]->{postdate} = formatDate(3,$rows[0]->{createdate}); | |||||||||||||||||||||||||||
| 167 | 0 | $rows[0]->{alignment} = AlignClass($rows[0]->{align}); | |||||||||||||||||||||||||||
| 168 | 0 | $tvars{news}{item} = $rows[0]; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =over 4 | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =item Access | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | Check whether user has access to admin functions. Must be Editor or greater. | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | =item ImageCheck | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | Checks whether images are being referenced in a news item. Used to allow the | ||||||||||||||||||||||||||||
| 183 | images plugin to delete unused images. | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =item Admin | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | List new items. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | =item Add | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | Create a template variable hash to create a news item. | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =item Edit | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | Edit the given news item. | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =item Copy | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | Copy a specified news item to create a new one. Called via Admin(). | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =item EditAmendments | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | Provide additional drop downs and fields for editing. | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | =item Promote | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | Promote the given news item. | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =item Save | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | Save the given news item. | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =item Delete | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | Delete the listed news items. Called via Admin(). | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =back | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | =cut | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub Access { Authorised(EDITOR) } | ||||||||||||||||||||||||||
|
Subroutine
Access: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub ImageCheck { | ||||||||||||||||||||||||||
|
Subroutine
ImageCheck: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 224 | 0 | my @rows = $dbi->GetQuery('array','NewsImageCheck',$_[0]); | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | @rows ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub Admin { | ||||||||||||||||||||||||||
|
Subroutine
Admin: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if($cgiparams{doaction}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if($cgiparams{doaction} eq 'Delete') { Delete(); } | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 232 | 0 | elsif($cgiparams{doaction} eq 'Copy') { Copy(); } | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | # (un)check front paged items | ||||||||||||||||||||||||||||
| 235 | 0 | my @front = CGIArray('FRONT'); | |||||||||||||||||||||||||||
| 236 | 0 | ▶ | if(@front) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | my @check = $dbi->GetQuery('hash','CheckFrontPageNews'); | |||||||||||||||||||||||||||
| 238 | 0 | my %check = map {$_->{newsid} => 1} @check; | |||||||||||||||||||||||||||
| 239 | 0 | for my $id (@front) { | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | if($check{$id}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | $check{$id} = 0; | |||||||||||||||||||||||||||
| 242 | } else { | ||||||||||||||||||||||||||||
| 243 | 0 | $dbi->DoQuery('SetFrontPageNews',$id); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | 0 | for my $id (keys %check) { | |||||||||||||||||||||||||||
| 247 | 0 | ▶ | next unless($check{$id}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 0 | $dbi->DoQuery('ClearFrontPageNews',$id); | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | # selected or default (Draft/Submitted/Published) | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my $publish = $cgiparams{'publish'} || '1,2,3'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::cgiparams{'publish'} || '1,2,3'
MC/DC0%0/1
$Labyrinth::Plugin::News::cgiparams{'publish'} || '1,2,3'
$Labyrinth::Plugin::News::cgiparams{'publish'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::cgiparams{'publish'}
| |||||||||||||||||||||||||||||
| 253 | 0 | my @where; | |||||||||||||||||||||||||||
| 254 | 0 | ▶ | push @where, "userid=$tvars{'loginid'}" unless(Authorised(PUBLISHER)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 0 | ▶ | push @where, "publish IN ($publish)" if($publish); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my $where = @where ? 'WHERE '.join(' AND ',@where) : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 257 | 0 | my @rows = $dbi->GetQuery('hash','AllNews',{where=>$where}); | |||||||||||||||||||||||||||
| 258 | 0 | foreach my $row (@rows) { | |||||||||||||||||||||||||||
| 259 | 0 | $row->{publishstate} = PublishState($row->{publish}); | |||||||||||||||||||||||||||
| 260 | 0 | $row->{name} = UserName($row->{userid}); | |||||||||||||||||||||||||||
| 261 | 0 | $row->{postdate} = formatDate(3,$row->{createdate}); | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | 0 | $tvars{data} = \@rows; | |||||||||||||||||||||||||||
| 264 | 0 | $publish = $cgiparams{'publish'}; | |||||||||||||||||||||||||||
| 265 | 0 | $tvars{ddpublish} = PublishSelect($publish,1); | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub Add { | ||||||||||||||||||||||||||
|
Subroutine
Add: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | my $ddpublish; | |||||||||||||||||||||||||||
| 271 | 0 | ▶ | if(Authorised($LEVEL2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 0 | $ddpublish = PublishSelect($tvars{data}->{publish}); | |||||||||||||||||||||||||||
| 273 | } else { | ||||||||||||||||||||||||||||
| 274 | 0 | $ddpublish = PublishAction(1,1); | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | my %data = ( | ||||||||||||||||||||||||||||
| 277 | folderid => 1, | ||||||||||||||||||||||||||||
| 278 | title => '', | ||||||||||||||||||||||||||||
| 279 | userid => $tvars{loginid}, | ||||||||||||||||||||||||||||
| 280 | name => $tvars{user}->{name}, | ||||||||||||||||||||||||||||
| 281 | 0 | postdate => formatDate(3), | |||||||||||||||||||||||||||
| 282 | body => '', | ||||||||||||||||||||||||||||
| 283 | link => 'images/blank.png', | ||||||||||||||||||||||||||||
| 284 | alttag => '', | ||||||||||||||||||||||||||||
| 285 | ddpublish => $ddpublish, | ||||||||||||||||||||||||||||
| 286 | ddalign => AlignSelect(1), | ||||||||||||||||||||||||||||
| 287 | imageid => 1, | ||||||||||||||||||||||||||||
| 288 | align => 1, | ||||||||||||||||||||||||||||
| 289 | href => '', | ||||||||||||||||||||||||||||
| 290 | front => 0, | ||||||||||||||||||||||||||||
| 291 | ); | ||||||||||||||||||||||||||||
| 292 | 0 | $tvars{data} = \%data; | |||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 0 | ▶ | sub Edit { | ||||||||||||||||||||||||||
|
Subroutine
Edit: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return unless $cgiparams{$INDEXKEY}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | return unless AuthorCheck($GETSQL,$INDEXKEY,$LEVEL); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 0 | EditAmendments(); | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub Copy { | ||||||||||||||||||||||||||
|
Subroutine
Copy: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 302 | 0 | $cgiparams{'newsid'} = $cgiparams{'LISTED'}; | |||||||||||||||||||||||||||
| 303 | 0 | ▶ | return unless AuthorCheck('GetNewsByID','newsid',EDITOR); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | my @fields = ( $tvars{data}->{folderid}, | ||||||||||||||||||||||||||||
| 306 | $tvars{data}->{title}, | ||||||||||||||||||||||||||||
| 307 | $tvars{data}->{body}, | ||||||||||||||||||||||||||||
| 308 | $tvars{data}->{imageid}, | ||||||||||||||||||||||||||||
| 309 | $tvars{data}->{align}, | ||||||||||||||||||||||||||||
| 310 | $tvars{data}->{href}, | ||||||||||||||||||||||||||||
| 311 | $tvars{data}->{alttag}, | ||||||||||||||||||||||||||||
| 312 | 1, | ||||||||||||||||||||||||||||
| 313 | formatDate(0), | ||||||||||||||||||||||||||||
| 314 | 0 | $tvars{loginid}); | |||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | $cgiparams{newsid} = $dbi->IDQuery('AddNews',@fields); | |||||||||||||||||||||||||||
| 317 | #LogDebug("Copy: newsid=[$cgiparams{newsid}]"); | ||||||||||||||||||||||||||||
| 318 | 0 | SetCommand('news-edit'); | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub EditAmendments { | ||||||||||||||||||||||||||
|
Subroutine
EditAmendments: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 322 | 0 | ▶ | $tvars{data}->{align} = $cgiparams{ALIGN0} if $cgiparams{ALIGN0}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 0 | $tvars{data}->{alignment} = AlignClass($tvars{data}->{align}); | |||||||||||||||||||||||||||
| 324 | 0 | $tvars{data}->{ddalign} = AlignSelect($tvars{data}->{align}); | |||||||||||||||||||||||||||
| 325 | 0 | $tvars{data}->{ddpublish} = PublishSelect($tvars{data}->{publish}); | |||||||||||||||||||||||||||
| 326 | 0 | $tvars{data}->{name} = UserName($tvars{data}->{userid}); | |||||||||||||||||||||||||||
| 327 | 0 | $tvars{data}->{postdate} = formatDate(3,$tvars{data}->{createdate}); | |||||||||||||||||||||||||||
| 328 | 0 | $tvars{data}->{body} =~ s/^\s+//; | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if(Authorised($LEVEL2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 0 | $tvars{data}->{ddpublish} = PublishSelect($tvars{data}->{publish}); | |||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||
| 333 | 0 | my $promote = 0; | |||||||||||||||||||||||||||
| 334 | 0 | ▶ | $promote = 1 if($tvars{data}->{publish} == 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | 0 | ▶ | $promote = 1 if($tvars{data}->{publish} == 2 && AccessUser(PUBLISHER)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 2 and AccessUser(3)
MC/DC0%0/2
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 2 and AccessUser(3)
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 2
AccessUser(3)
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 2B= AccessUser(3)
| |||||||||||||||||||||||||||||
| 336 | 0 | ▶ | $promote = 1 if($tvars{data}->{publish} == 3 && AccessUser(PUBLISHER)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3 and AccessUser(3)
MC/DC0%0/2
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3 and AccessUser(3)
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3
AccessUser(3)
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3B= AccessUser(3)
| |||||||||||||||||||||||||||||
| 337 | 0 | $tvars{data}->{ddpublish} = PublishAction($tvars{data}->{publish},$promote); | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 0 | $tvars{preview} = clone($tvars{data}); # data fields need to be editable | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||
| 343 | 0 | ▶ | if($fields{$_}->{html} == 1) { $tvars{preview}->{$_} = CleanHTML($tvars{preview}->{$_}); | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 344 | 0 | $tvars{data}->{$_} = CleanHTML($tvars{data}->{$_}); } | |||||||||||||||||||||||||||
| 345 | 0 | elsif($fields{$_}->{html} == 2) { $tvars{data}->{$_} = SafeHTML($tvars{data}->{$_}); } | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub Promote { | ||||||||||||||||||||||||||
|
Subroutine
Promote: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 350 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | my @ids = CGIArray('LISTED'); | |||||||||||||||||||||||||||
| 352 | 0 | ▶ | return unless @ids; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 0 | for my $id (@ids) { | |||||||||||||||||||||||||||
| 355 | 0 | $cgiparams{$INDEXKEY} = $id; | |||||||||||||||||||||||||||
| 356 | 0 | ▶ | next unless AuthorCheck($GETSQL,$INDEXKEY,$LEVEL); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | 0 | my $publish = $tvars{data}->{publish} + 1; | |||||||||||||||||||||||||||
| 358 | 0 | ▶ | next unless($publish < 5); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | $dbi->DoQuery($PROMOTESQL,$publish,$cgiparams{$INDEXKEY}); | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub Save { | ||||||||||||||||||||||||||
|
Subroutine
Save: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||
| 364 | 0 | ▶ | return unless AuthorCheck('GetNewsByID','newsid',EDITOR); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 0 | ▶ | my $publish = $tvars{data}->{publish} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::tvars{'data'}{'publish'} || 0
MC/DC0%0/1
$Labyrinth::Plugin::News::tvars{'data'}{'publish'} || 0
$Labyrinth::Plugin::News::tvars{'data'}{'publish'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::tvars{'data'}{'publish'}
| |||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 0 | EditAmendments(); | |||||||||||||||||||||||||||
| 368 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||
| 369 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 370 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 371 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if($cgiparams{image}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | ($tvars{data}->{'imageid'}) = | ||||||||||||||||||||||||||||
| 377 | SaveImageFile( | ||||||||||||||||||||||||||||
| 378 | param => 'image', | ||||||||||||||||||||||||||||
| 379 | stock => 'Special', | ||||||||||||||||||||||||||||
| 380 | href => $tvars{data}->{href}, | ||||||||||||||||||||||||||||
| 381 | alttag => $tvars{data}->{alttag} | ||||||||||||||||||||||||||||
| 382 | 0 | ); | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $tvars{data}->{createdate} = formatDate(0) if($tvars{data}->{publish} == 3 && $publish < 3); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3 and $publish < 3
MC/DC0%0/2
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3 and $publish < 3
$Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3
$publish < 3
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::News::tvars{"data"}{"publish"} == 3B= $publish < 3
| |||||||||||||||||||||||||||||
| 386 | 0 | $tvars{data}->{createdate} = unformatDate(3,$tvars{data}->{postdate}); | |||||||||||||||||||||||||||
| 387 | 0 | ▶ | $tvars{data}->{front} = $tvars{data}->{front} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $tvars{data}->{latest} = $tvars{data}->{latest} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $tvars{data}->{folderid} ||= 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::tvars{"data"}{"folderid"} ||= 1
MC/DC0%0/1
$Labyrinth::Plugin::News::tvars{"data"}{"folderid"} ||= 1
$Labyrinth::Plugin::News::tvars{"data"}{"folderid"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::tvars{"data"}{"folderid"}
| |||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $tvars{data}->{imageid} ||= 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::News::tvars{"data"}{"imageid"} ||= 1
MC/DC0%0/1
$Labyrinth::Plugin::News::tvars{"data"}{"imageid"} ||= 1
$Labyrinth::Plugin::News::tvars{"data"}{"imageid"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::News::tvars{"data"}{"imageid"}
| |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | my @fields = ( $tvars{data}->{folderid}, | ||||||||||||||||||||||||||||
| 393 | $tvars{data}->{title}, | ||||||||||||||||||||||||||||
| 394 | $tvars{data}->{snippet}, | ||||||||||||||||||||||||||||
| 395 | $tvars{data}->{body}, | ||||||||||||||||||||||||||||
| 396 | $tvars{data}->{imageid}, | ||||||||||||||||||||||||||||
| 397 | $tvars{data}->{align}, | ||||||||||||||||||||||||||||
| 398 | $tvars{data}->{front}, | ||||||||||||||||||||||||||||
| 399 | $tvars{data}->{latest}, | ||||||||||||||||||||||||||||
| 400 | $tvars{data}->{publish}, | ||||||||||||||||||||||||||||
| 401 | $tvars{data}->{createdate}, | ||||||||||||||||||||||||||||
| 402 | 0 | ); | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if($tvars{data}->{newsid}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 0 | { $dbi->DoQuery('SaveNews',@fields,$tvars{data}->{newsid}); } | |||||||||||||||||||||||||||
| 406 | 0 | else { $cgiparams{newsid} = $dbi->IDQuery('AddNews',@fields,$tvars{loginid}); } | |||||||||||||||||||||||||||
| 407 | 0 | $tvars{thanks} = 1; | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub Delete { | ||||||||||||||||||||||||||
|
Subroutine
Delete: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 411 | 0 | ▶ | return unless AccessUser($LEVEL2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 0 | my @ids = CGIArray('LISTED'); | |||||||||||||||||||||||||||
| 413 | 0 | ▶ | return unless @ids; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 414 | 0 | for my $id (@ids) { | |||||||||||||||||||||||||||
| 415 | 0 | $cgiparams{'newsid'} = $id; | |||||||||||||||||||||||||||
| 416 | 0 | ▶ | next unless AuthorCheck('GetNewsByID','newsid',EDITOR); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | 0 | $dbi->DoQuery('DeleteNews',$cgiparams{'newsid'}); | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 4 | 1; | |||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | __END__ | ||||||||||||||||||||||||||||