| 1 | package Labyrinth::Plugin::CPAN::Preferences; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | our $VERSION = '0.20'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | Labyrinth::Plugin::CPAN::Preferences - Handles preferences pages. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # Libraries | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use base qw(Labyrinth::Plugin::Base); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Labyrinth::Audit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Labyrinth::DTUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use Labyrinth::Mailer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use Labyrinth::Session; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use Labyrinth::Support; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use Labyrinth::Plugin::CPAN; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use Net::SSLeay qw(get_https make_headers); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use Sort::Versions; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | use Time::Local; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # Variables | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # The following distributions are considered exceptions from the norm and | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # are to be added on a case by case basis. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | my $EXCEPTIONS = 'Test.php|Net-ITE.pm|CGI.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my %date_fields = ( | |||||||||||||||||||||||||||||||||||||||||
| 43 | y => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | m => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | d => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | my (@date_man,@date_all); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | for(keys %date_fields) { | |||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | ▶ | push @date_man, $_ if($date_fields{$_}->{type}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | push @date_all, $_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | my %pref_fields = ( | |||||||||||||||||||||||||||||||||||||||||
| 55 | dist => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | active => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ignored => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | report => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | grade => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | tuple => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | version => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | versions => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | patches => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | perl => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | perls => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | platform => { type => 1, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | platforms => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | my (@pref_man,@pref_all); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 4 | for(keys %pref_fields) { | |||||||||||||||||||||||||||||||||||||||||
| 72 | 52 | ▶ | push @pref_man, $_ if($pref_fields{$_}->{type}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 52 | push @pref_all, $_; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | my %months = ( | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 => 'January', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 => 'February', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 => 'March', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 => 'April', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 => 'May', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 6 => 'June', | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 7 => 'July', | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 8 => 'August', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 9 => 'September', | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 10 => 'October', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 11 => 'November', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 => 'December', | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 92 | # Public Interface Functions | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | =head2 Public Interface Methods | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =item Login | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | Author Login mechanism. Uses the PAUSE authentication system. | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | =item Logged | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | Ensure correct user is logged in. | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | =item Default | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | Default preferences page. | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | =item Distros | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | Author distributions list page. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | =item Distro | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | Single distribution preferences page. | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | =item XDropDownMultiList | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | Provide a drop down multi-select list, base on a list of strings. | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | =item XDropDownMultiRows | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | Provide a drop down multi-select list, base on a list of rows. | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | =item DefSave | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | Save default preferences. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | =item DistSave | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | Save distribution preferences. | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | =item Delete | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | Delete the preferences for a distribution, and use the default preferences. | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub Login { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Login: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | # if a regular login or no login, use the core login mechanism | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if(!$cgiparams{pause} || !$cgiparams{eject} || $cgiparams{pause} =~ /\@/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"pause"} && $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"eject"} or $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"pause"} =~ /\@/
$Labyrinth::Plugin::CPAN::Preferences::cgiparams{'pause'} && $Labyrinth::Plugin::CPAN::Preferences::cgiparams{'eject'}
MC/DC0%0/3
not $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"pause"} && $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"eject"} or $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"pause"} =~ /\@/
$Labyrinth::Plugin::CPAN::Preferences::cgiparams{'pause'}
$Labyrinth::Plugin::CPAN::Preferences::cgiparams{'eject'}
$Labyrinth::Plugin::CPAN::Preferences::cgiparams{"pause"} =~ /\@/
Truth table0%0/4
not(A && B) or C
A= $Labyrinth::Plugin::CPAN::Preferences::cgiparams{'pause'}B= $Labyrinth::Plugin::CPAN::Preferences::cgiparams{'eject'}C= $Labyrinth::Plugin::CPAN::Preferences::cgiparams{"pause"} =~ /\@/
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $cgiparams{cause} = $cgiparams{pause}; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $cgiparams{effect} = $cgiparams{eject}; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | LogDebug("pause=$cgiparams{pause}, eject=$cgiparams{eject}"); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | LogDebug("cause=$cgiparams{cause}, effect=$cgiparams{effect}"); | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $tvars{errcode} = 'NEXT'; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $tvars{command} = 'user-logged'; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $result = LWP::UserAgent->new->get("https://pause.perl.org/pause/authenquery", | |||||||||||||||||||||||||||||||||||||||||
| 159 | Authorization => | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 'Basic ' . MIME::Base64::encode("$cgiparams{pause}:$cgiparams{eject}",'') | ||||||||||||||||||||||||||||||||||||||||||
| 161 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if($result->code == 200) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my @rows = $dbi->GetQuery('hash','CheckUser','PAUSE','PAUSE'); | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | # add entry to session table | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $session; | |||||||||||||||||||||||||||||||||||||||||
| 168 | ( $session, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | $tvars{user}{name}, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | $tvars{'loginid'}, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | $tvars{realm}, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | $tvars{langcode} | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ) = Labyrinth::Session::_save_session(uc $cgiparams{pause},$rows[0]->{userid},$rows[0]->{realm},$rows[0]->{langcode}); | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # set template variables | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $tvars{'loggedin'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $tvars{user}{folder} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $tvars{user}{option} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $tvars{user}{userid} = $tvars{'loginid'}; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $tvars{user}{access} = VerifyUser($tvars{'loginid'}); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $tvars{realm} ||= 'public'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{"realm"} ||= "public"
MC/DC0%0/1
$Labyrinth::Plugin::CPAN::Preferences::tvars{"realm"} ||= "public"
$Labyrinth::Plugin::CPAN::Preferences::tvars{"realm"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{"realm"}
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | # set login activity | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $dbi->DoQuery('UpdateAuthorLogin',time(),$tvars{user}{name}); | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $tvars{errmess} = 2; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub Logged { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Logged: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub Default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Default: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $author = $tvars{user}{author} || $tvars{user}{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
MC/DC0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
Truth table0%0/3
A || B
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}B= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my @rows = $dbi->GetQuery('hash','GetAuthorDefault',$author); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | $tvars{data} = $rows[0] if(@rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $cpan = Labyrinth::Plugin::CPAN->new(); | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my @perls = sort {versioncmp($b->{perl},$a->{perl})} $dbi->GetQuery('hash','GetPerlVersions'); | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $cpan->Configure(); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $archs = $cpan->osnames(); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my @archs = map {{oscode => $_, osname => $archs->{$_}}} sort {lc $archs->{$a} cmp lc $archs->{$b}} keys %$archs; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $tvars{data}{ddarch} = XDropDownMultiRows($tvars{data}{platform},'platforms','oscode','osname',5,@archs); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $tvars{data}{ddperl} = XDropDownMultiRows($tvars{data}{perl},'perls','perl','perl',5,@perls); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub Distros { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Distros: not called CC=24 SCAR=64.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $author = $tvars{user}{author} || $tvars{user}{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
MC/DC0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
Truth table0%0/3
A || B
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}B= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $cpan = Labyrinth::Plugin::CPAN->new(); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my @rows = $dbi->GetQuery('array','GetAuthorDists',$author); | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my @dists = map {$_->[0]} @rows; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my @distros = $dbi->GetQuery('hash','GetAuthorDistros',$author); | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my %distros = map {$_->{distribution} => $_} @distros; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | for(keys %distros) { | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $distros{$_}->{name} = $_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $distros{$_}->{grade} =~ s/PASS/P/; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $distros{$_}->{grade} =~ s/FAIL/F/; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $distros{$_}->{grade} =~ s/UNKNOWN/U/; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $distros{$_}->{grade} =~ s/NA/N/; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $distros{$_}->{grade} =~ s/,//g; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $distros{$_}->{tuple} =~ s/ALL/A/; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $distros{$_}->{tuple} =~ s/FIRST/F/; | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $distros{$_}->{version} =~ s/ALL/A/; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $distros{$_}->{version} =~ s/LATEST/L/; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $distros{$_}->{version} =~ s/(NOT|INC).*/C/; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $distros{$_}->{perl} =~ s/ALL/A/; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $distros{$_}->{perl} =~ s/(NOT|INC).*/C/; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $distros{$_}->{perl} .= '+P' if($distros{$_}->{perl} eq 'A' && $distros{$_}->{patches}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$distros{$_}{"perl"} eq "A" and $distros{$_}{"patches"}
MC/DC0%0/2
$distros{$_}{"perl"} eq "A" and $distros{$_}{"patches"}
$distros{$_}{"perl"} eq "A"
$distros{$_}{"patches"}
Truth table0%0/3
A and B
A= $distros{$_}{"perl"} eq "A"B= $distros{$_}{"patches"}
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $distros{$_}->{platform} =~ s/ALL/A/; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $distros{$_}->{platform} =~ s/(NOT|INC).*/C/; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | # check whether any distributions have had their ignore status altered | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if($cgiparams{enable}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $updated = 0; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my @check = CGIArray('dists'); | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my %check = @check ? map {$_=>1} @check : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # ensure user checked are disabled in the DB | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | for(@check) { | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | next if($distros{$_} && $distros{$_}->{ignored} == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$distros{$_} and $distros{$_}{"ignored"} == 1
MC/DC0%0/2
$distros{$_} and $distros{$_}{"ignored"} == 1
$distros{$_}
$distros{$_}{"ignored"} == 1
Truth table0%0/3
A and B
A= $distros{$_}B= $distros{$_}{"ignored"} == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $updated = 1; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if(defined $distros{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | push @list, "'$_'"; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $distros{$_}->{ignored} = 2; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $dbi->DoQuery('InsertDistroPrefs',1,1,'FAIL','FIRST','LATEST',0,'ALL','ALL',$author,$_); | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $distros{$_}->{ignored} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $dbi->DoQuery('SetAuthorIgnore',{dists => join(',',@list)},2,$author) if(@list); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | # ensure user unchecked are enabled in the DB | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | @list = (); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | for(keys %distros) { | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | next if($check{$_}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $updated = 1; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my @rows = $dbi->GetQuery('hash','GetAuthorDistro',$author,$_); | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if(@rows) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if($rows[0]->{ignored} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $dbi->DoQuery('DeleteDistroPrefs', $author, $_); | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | delete $distros{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | push @list, "'$_'"; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $distros{$_}->{ignored} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | $dbi->DoQuery('SetAuthorIgnore',{dists => join(',',@list)},0,$author) if(@list); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | $tvars{thanks} = 1 if($updated); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | @distros = (); | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my %dists = map {$_ => 1} @dists; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | for my $dist (sort keys %dists) { | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | next unless($dist =~ /^[A-Za-z0-9][A-Za-z0-9\-_]*$/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dist =~ /^[A-Za-z0-9][A-Za-z0-9\-_]*$/ or $dist =~ /$EXCEPTIONS/
MC/DC0%0/2
$dist =~ /^[A-Za-z0-9][A-Za-z0-9\-_]*$/ or $dist =~ /$EXCEPTIONS/
$dist =~ /^[A-Za-z0-9][A-Za-z0-9\-_]*$/
$dist =~ /$EXCEPTIONS/
Truth table0%0/3
A or B
A= $dist =~ /^[A-Za-z0-9][A-Za-z0-9\-_]*$/B= $dist =~ /$EXCEPTIONS/
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | || $dist =~ /$EXCEPTIONS/); | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if(defined $distros{$dist}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if($distros{$dist}->{ignored}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | push @distros, {name => $dist, ignored => $distros{$dist}->{ignored}}; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | push @distros, $distros{$dist} | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | push @distros, {name => $dist, ignored => 0}; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $tvars{data}{dists} = \@distros; | |||||||||||||||||||||||||||||||||||||||||
| 308 | #$tvars{hash}{dists} = \%dists; | ||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub Distro { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Distro: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $author = $tvars{user}{author} || $tvars{user}{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
MC/DC0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
Truth table0%0/3
A || B
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}B= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $dist = $cgiparams{dist}; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $version = $cgiparams{version}; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my @rows = $dbi->GetQuery('hash','GetAuthorDistro',$author,$dist); | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | $tvars{data} = $rows[0] if(@rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $tvars{data}{dist} = $dist; | |||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $cpan = Labyrinth::Plugin::CPAN->new(); | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my @vers = $dbi->GetQuery('array','GetAuthorDistVersions',$author,$dist); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my @versions = sort {versioncmp($b,$a)} map {$_->[0]} @vers; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $tvars{data}{ddversions} = XDropDownMultiList($version,'versions',5,@versions); | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my @perls = sort {versioncmp($b->{perl},$a->{perl})} $dbi->GetQuery('hash','GetPerlVersions'); | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $cpan->Configure(); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $archs = $cpan->osnames(); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my @archs = map {{oscode => $_, osname => $archs->{$_}}} sort {lc $archs->{$a} cmp lc $archs->{$b}} keys %$archs; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $tvars{data}{ddarch} = XDropDownMultiRows($tvars{data}{platform},'platforms','oscode','osname',5,@archs); | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $tvars{data}{ddperl} = XDropDownMultiRows($tvars{data}{perl},'perls','perl','perl',5,@perls); | |||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | for(qw(version perl platform)) { | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $tvars{data}{$_} =~ s/,/, /g; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $tvars{data}{$_} =~ s/(NOT|INC),/$1:/g; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | sub XDropDownMultiList { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XDropDownMultiList: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my ($opts,$name,$count,@items) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my %opts; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if(defined $opts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if(ref($opts) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | %opts = map {$_ => 1} @$opts; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } elsif($opts =~ /,/) { | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | %opts = map {$_ => 1} split(/,/,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 351 | } elsif($opts) { | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | %opts = ("$opts" => 1); | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my %hash = ( name => $name ); | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | for(@items) { | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | push @{$hash{options}}, { index => $_, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opts and $opts{$_}
MC/DC0%0/2
defined $opts and $opts{$_}
defined $opts
$opts{$_}
Truth table0%0/3
A and B
A= defined $optsB= $opts{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | value => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | selected => (defined $opts && $opts{$_} ? 1 : 0)}; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub XDropDownMultiRows { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XDropDownMultiRows: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ($opts,$name,$index,$value,$count,@items) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my %opts; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if(defined $opts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if(ref($opts) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | %opts = map {$_ => 1} @$opts; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } elsif($opts =~ /,/) { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | %opts = map {$_ => 1} split(/,/,$opts); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } elsif($opts) { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | %opts = ("$opts" => 1); | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my %hash = ( name => $name ); | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | for(@items) { | |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | push @{$hash{options}}, { index => $_->{$index}, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opts and $opts{$_->{$index}}
MC/DC0%0/2
defined $opts and $opts{$_->{$index}}
defined $opts
$opts{$_->{$index}}
Truth table0%0/3
A and B
A= defined $optsB= $opts{$_->{$index}}
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | value => $_->{$value}, | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | selected => (defined $opts && $opts{$_->{$index}} ? 1 : 0)}; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub DefSave { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DefSave: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | for(keys %pref_fields) { | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if($pref_fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | elsif($pref_fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | elsif($pref_fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | return if FieldCheck(\@pref_all,\@pref_man); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | my $author = $tvars{user}{author} || $tvars{user}{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
MC/DC0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
Truth table0%0/3
A || B
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}B= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | # change reporting activity | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $dbi->DoQuery('UpdateAuthorActive',$tvars{data}{active},$author); | |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | _save_distprefs($author,'-'); | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub DistSave { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DistSave: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | for(keys %pref_fields) { | |||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if($pref_fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | elsif($pref_fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | elsif($pref_fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | return if FieldCheck(\@pref_all,\@pref_man); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | my $author = $tvars{user}{author} || $tvars{user}{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
MC/DC0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
Truth table0%0/3
A || B
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}B= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | _save_distprefs($author,$tvars{data}{dist}); | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub _save_distprefs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save_distprefs: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my ($author,$dist) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my @fields; | |||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | $tvars{data}{patches} = $tvars{data}{patches} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | # save default settings | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | for(qw(grade versions perls platforms)) { | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @array = CGIArray($_); | |||||||||||||||||||||||||||||||||||||||||
| 435 | #LogDebug("$_ => @array"); | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $tvars{data}{$_} = join(',',@array); | |||||||||||||||||||||||||||||||||||||||||
| 437 | #LogDebug("tvars($_) => $tvars{data}{$_}"); | ||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | for(qw(version perl platform)) { | |||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | next if($tvars{data}{$_} eq 'ALL'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | next if($tvars{data}{$_} eq 'LATEST'); # only applicable to version | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | next unless($tvars{data}{$_ . 's'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $tvars{data}{$_} .= ',' . $tvars{data}{$_ . 's'}; | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | push @fields, $tvars{data}{$_} for(qw(ignored report grade tuple version patches perl platform)); | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my @rows = $dbi->GetQuery('hash','GetAuthorDistro',$author,$dist); | |||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | if(@rows) { $dbi->DoQuery('UpdateDistroPrefs',@fields, $author, $dist) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | else { $dbi->DoQuery('InsertDistroPrefs',@fields, $author, $dist) } | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $tvars{thanks} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | sub Delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Delete: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | return unless RealmCheck('author','admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | my $author = $tvars{user}{author} || $tvars{user}{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
MC/DC0%0/2
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'} || $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}
$Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
Truth table0%0/3
A || B
A= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'author'}B= $Labyrinth::Plugin::CPAN::Preferences::tvars{'user'}{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $dist = $cgiparams{dist}; | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my @rows = $dbi->GetQuery('hash','GetAuthorDistro',$author,$dist); | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | $dbi->DoQuery('DeleteDistroPrefs', $author, $dist) if(@rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | =head2 Admin Interface Methods | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | =item Admin | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | Prepare Admin login as author. | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | =item Imposter | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | Allow Admin to login as named author. | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | =item Clear | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | Clear imposter status and return to Admin. | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | sub Admin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Admin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | return unless RealmCheck('admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $tvars{where} = "AND u.realm='author' AND u.userid > 3"; | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | sub Imposter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Imposter: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | return unless RealmCheck('admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | UpdateSession('name' => 'imposter:' . $cgiparams{pause}); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $tvars{user}{author} = $cgiparams{pause}; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | sub Clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Clear: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | return unless RealmCheck('admin'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | UpdateSession('name' => 'Admin'); | |||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $tvars{user}{name} = 'Admin'; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | delete $tvars{user}{author}; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | __END__ | ||||||||||||||||||||||||||||||||||||||||||