| 1 | package Labyrinth::Support; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT @EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | $VERSION = '5.32'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | Labyrinth::Support - Common Function Library for Labyrinth. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | use Labyrinth::Support; | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | The functions contain herein are commonly used throughout Labyrinth and | ||||||||||||||||||||||||||||||||||||||||||
| 20 | plugins. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 EXPORT | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | AlignName | ||||||||||||||||||||||||||||||||||||||||||
| 25 | AlignClass | ||||||||||||||||||||||||||||||||||||||||||
| 26 | AlignSelect | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | PublishState | ||||||||||||||||||||||||||||||||||||||||||
| 29 | PublishSelect | ||||||||||||||||||||||||||||||||||||||||||
| 30 | PublishAction | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | FieldCheck | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ParamCheck | ||||||||||||||||||||||||||||||||||||||||||
| 34 | AuthorCheck | ||||||||||||||||||||||||||||||||||||||||||
| 35 | MasterCheck | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | AccessName | ||||||||||||||||||||||||||||||||||||||||||
| 38 | AccessID | ||||||||||||||||||||||||||||||||||||||||||
| 39 | AccessUser | ||||||||||||||||||||||||||||||||||||||||||
| 40 | AccessGroup | ||||||||||||||||||||||||||||||||||||||||||
| 41 | AccessSelect | ||||||||||||||||||||||||||||||||||||||||||
| 42 | AccessAllFolders | ||||||||||||||||||||||||||||||||||||||||||
| 43 | AccessAllAreas | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | RealmCheck | ||||||||||||||||||||||||||||||||||||||||||
| 46 | RealmSelect | ||||||||||||||||||||||||||||||||||||||||||
| 47 | RealmName | ||||||||||||||||||||||||||||||||||||||||||
| 48 | RealmID | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | ProfileSelect | ||||||||||||||||||||||||||||||||||||||||||
| 51 | FolderName | ||||||||||||||||||||||||||||||||||||||||||
| 52 | FolderID | ||||||||||||||||||||||||||||||||||||||||||
| 53 | FolderSelect | ||||||||||||||||||||||||||||||||||||||||||
| 54 | AreaSelect | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # Export Details | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 12 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 12 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||
| 65 | 'all' => [ qw( | ||||||||||||||||||||||||||||||||||||||||||
| 66 | AlignName AlignClass AlignSelect | ||||||||||||||||||||||||||||||||||||||||||
| 67 | PublishState PublishSelect PublishAction | ||||||||||||||||||||||||||||||||||||||||||
| 68 | FieldCheck ParamCheck AuthorCheck MasterCheck | ||||||||||||||||||||||||||||||||||||||||||
| 69 | AccessName AccessID AccessUser AccessGroup AccessSelect | ||||||||||||||||||||||||||||||||||||||||||
| 70 | AccessAllFolders AccessAllAreas | ||||||||||||||||||||||||||||||||||||||||||
| 71 | RealmCheck RealmSelect RealmName RealmID | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ProfileSelect FolderName FolderID FolderSelect AreaSelect | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ) ] | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 12 | @EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 80 | # Library Modules | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | ▶ | use Time::Local; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 12 | ▶ | use Labyrinth::Audit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 12 | ▶ | use Labyrinth::Globals; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | ▶ | use Labyrinth::Groups; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 12 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | ▶ | use Labyrinth::Session; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 12 | ▶ | use Labyrinth::Writer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 12 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | # ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # The Subs | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | =item PublishState | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | Returns the name of the current publish state, given the numeric state. | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | =item PublishSelect | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 106 | available publishing states. | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | =item PublishAction | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 111 | accessible publishing states. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 12 | my %publishstates = ( | |||||||||||||||||||||||||||||||||||||||||
| 116 | 1 => {Action => 'Draft', State => 'Draft' }, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 => {Action => 'Submit', State => 'Submitted' }, | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 => {Action => 'Publish', State => 'Published' }, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 => {Action => 'Archive', State => 'Archived' }, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 12 | my @states = map {{'id'=>$_,'value'=> $publishstates{$_}->{State}}} sort keys %publishstates; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub PublishState { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PublishState: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $state = shift; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return '' unless($state); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return $publishstates{$state}->{State}; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub PublishSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PublishSelect: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my ($opt,$blank) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my @list = @states; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | unshift @list, {id=>0,value=>'Select Status'} if(defined $blank && $blank == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $blank and $blank == 1
MC/DC0%0/2
defined $blank and $blank == 1
defined $blank
$blank == 1
Truth table0%0/3
A and B
A= defined $blankB= $blank == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | DropDownRows($opt,'publish','id','value',@list); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub PublishAction { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PublishAction: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $opt = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $ack = shift || -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || -1
MC/DC0%0/1
shift() || -1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $html = qq{<select id="publish" name="publish">}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | foreach (sort keys %publishstates) { | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | unless($ack == -1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | next if(!$ack && $_ != $opt); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $ack and $_ != $opt
MC/DC0%0/2
not $ack and $_ != $opt
not $ack
$_ != $opt
Truth table0%0/3
not(A) and B
A= not $ackB= $_ != $opt
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | next if($_ < $opt || $_ > $opt+1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ < $opt or $_ > $opt + 1
MC/DC0%0/2
$_ < $opt or $_ > $opt + 1
$_ < $opt
$_ > $opt + 1
Truth table0%0/3
A or B
A= $_ < $optB= $_ > $opt + 1
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $html .= "<option value='$_'"; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $html .= ' selected="selected"' if($opt == $_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $html .= ">$publishstates{$_}->{Action}</option>"; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $html .= "</select>"; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return $html; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 12 | my %alignments = ( | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 => { name => 'none', class => 'nail' }, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 => { name => 'left', class => 'left' }, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 => { name => 'centre', class => 'centre' }, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 => { name => 'right', class => 'right' }, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 => { name => 'left (no wrap)', class => 'lnowrap' }, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 => { name => 'right (no wrap)', class => 'rnowrap' }, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 12 | my @alignments = map {{'id'=>$_,'value'=> $alignments{$_}->{name}}} sort keys %alignments; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | =item AlignName | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | Returns the name of the given alignment type, defaults to 'none'. | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | =item AlignClass | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | Returns the class of the given alignment type, defaults to 'nail'. | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | =item AlignSelect | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 177 | available alignment states. | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub AlignName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AlignName: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | my $opt = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return $alignments{$opt}->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub AlignClass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AlignClass: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my $opt = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return $alignments{$opt}->{class}; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub AlignSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AlignSelect: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | my $opt = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $num = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | DropDownRows($opt,"ALIGN$num",'id','value',@alignments); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | =item AuthorCheck | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | Checks whether the current user is the author of the data requested, or has | ||||||||||||||||||||||||||||||||||||||||||
| 200 | permissions to allow them to access the data. If not sets the BADACCESS error | ||||||||||||||||||||||||||||||||||||||||||
| 201 | code, otherwise retrieves the data. | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub AuthorCheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AuthorCheck: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my ($key,$id,$permission) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | return 1 unless($cgiparams{$id}); # if the id key doesn't exist, this is likely to be a new entry | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $permission = ADMIN unless(defined $permission); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my @rows = $dbi->GetQuery('hash',$key,$cgiparams{$id}); | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return 0 unless(@rows); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $tvars{data}{$_} = $rows[0]->{$_} for(keys %{$rows[0]}); | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | return 1 if(Authorised($permission)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | return 1 if($rows[0]->{userid} && $rows[0]->{userid} == $tvars{'loginid'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rows[0]{"userid"} and $rows[0]{"userid"} == $Labyrinth::Support::tvars{"loginid"}
MC/DC0%0/2
$rows[0]{"userid"} and $rows[0]{"userid"} == $Labyrinth::Support::tvars{"loginid"}
$rows[0]{"userid"}
$rows[0]{"userid"} == $Labyrinth::Support::tvars{"loginid"}
Truth table0%0/3
A and B
A= $rows[0]{"userid"}B= $rows[0]{"userid"} == $Labyrinth::Support::tvars{"loginid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $tvars{errcode} = 'BADACCESS'; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | =item MasterCheck | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | Ensure only a Master user can access a Master user details. | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub MasterCheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MasterCheck: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | return 1 if( !$cgiparams{userid} || ! Authorised(MASTER,$cgiparams{userid}) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Support::cgiparams{"userid"} and Authorised(5, $Labyrinth::Support::cgiparams{"userid"})
MC/DC0%0/2
$Labyrinth::Support::cgiparams{"userid"} and Authorised(5, $Labyrinth::Support::cgiparams{"userid"})
$Labyrinth::Support::cgiparams{"userid"}
Authorised(5, $Labyrinth::Support::cgiparams{"userid"})
Truth table0%0/3
A and B
A= $Labyrinth::Support::cgiparams{"userid"}B= Authorised(5, $Labyrinth::Support::cgiparams{"userid"})
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return 1 if( Authorised(MASTER,$cgiparams{userid}) && Authorised(MASTER,$tvars{'loginid'}) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Authorised(5, $Labyrinth::Support::cgiparams{"userid"}) and Authorised(5, $Labyrinth::Support::tvars{"loginid"})
MC/DC0%0/2
Authorised(5, $Labyrinth::Support::cgiparams{"userid"}) and Authorised(5, $Labyrinth::Support::tvars{"loginid"})
Authorised(5, $Labyrinth::Support::cgiparams{"userid"})
Authorised(5, $Labyrinth::Support::tvars{"loginid"})
Truth table0%0/3
A and B
A= Authorised(5, $Labyrinth::Support::cgiparams{"userid"})B= Authorised(5, $Labyrinth::Support::tvars{"loginid"})
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $tvars{errcode} = 'BADACCESS'; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =item FieldCheck(\@allfields,\@mandatory) | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | Stores all the input data listed in @allfields, then checks that all the fields | ||||||||||||||||||||||||||||||||||||||||||
| 239 | listed in @mandatory are provided. Any errors found during parameter parsing | ||||||||||||||||||||||||||||||||||||||||||
| 240 | both for missing mandatory fields and via Data::FormValidator are then flagged | ||||||||||||||||||||||||||||||||||||||||||
| 241 | and the error code set. | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | =item ParamCheck(\%fields) | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | Cleans data inputs, then stores all the input data fields in $tvars{data}. All | ||||||||||||||||||||||||||||||||||||||||||
| 246 | mandatory fields are validated to ensure each has a value. Any errors found | ||||||||||||||||||||||||||||||||||||||||||
| 247 | during parameter parsing both for missing mandatory fields and via | ||||||||||||||||||||||||||||||||||||||||||
| 248 | Data::FormValidator are then flagged and the error code set. | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | The fields hash contains a list of fields, with the keys 'type' and 'html'. | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 'type' indicates whether the field is mandatory (1) or optional (0). 'html' | ||||||||||||||||||||||||||||||||||||||||||
| 252 | indicates the level of cleaning required: | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | my %fields = ( | ||||||||||||||||||||||||||||||||||||||||||
| 255 | linkid => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | catid => { type => 0, html => 0 }, | ||||||||||||||||||||||||||||||||||||||||||
| 257 | href => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 258 | title => { type => 1, html => 3 }, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | body => { type => 0, html => 2 }, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # html: 0 = none, 1 = text, 2 = textarea, 3 = no links | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | '0' should only be used if previous parameter validation via | ||||||||||||||||||||||||||||||||||||||||||
| 266 | Data::FormValidator has already ensured that only legal characters are used. | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | '1' removes all HTML tags. | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | '2' removes disallowed HTML tags and cleans up many tags and whitespace. | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | '3' removes anything that looks like a link or script tag, with the aim of | ||||||||||||||||||||||||||||||||||||||||||
| 273 | preventing a XSS attack. | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub FieldCheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FieldCheck: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($allfields,$mandatory) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | # store base list for re-edit page | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | foreach (@$allfields) { | |||||||||||||||||||||||||||||||||||||||||
| 283 | # automatically turn arrays into strings, in case someone is trying | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # to subvert the data input process. known arrays are correctly stored | ||||||||||||||||||||||||||||||||||||||||||
| 285 | # appropriately elsewhere. | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $tvars{data}->{$_} = join("|",CGIArray($_)); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # check for mandatory fields | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | foreach (@$mandatory) { | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if(defined $cgiparams{$_} && exists $cgiparams{$_} && $cgiparams{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $Labyrinth::Support::cgiparams{$_} and exists $Labyrinth::Support::cgiparams{$_} and $Labyrinth::Support::cgiparams{$_}
defined $Labyrinth::Support::cgiparams{$_} and exists $Labyrinth::Support::cgiparams{$_}
MC/DC0%0/3
defined $Labyrinth::Support::cgiparams{$_} and exists $Labyrinth::Support::cgiparams{$_} and $Labyrinth::Support::cgiparams{$_}
defined $Labyrinth::Support::cgiparams{$_}
exists $Labyrinth::Support::cgiparams{$_}
$Labyrinth::Support::cgiparams{$_}
Truth table0%0/4
A and B and C
A= defined $Labyrinth::Support::cgiparams{$_}B= exists $Labyrinth::Support::cgiparams{$_}C= $Labyrinth::Support::cgiparams{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | # nothing | ||||||||||||||||||||||||||||||||||||||||||
| 294 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | LogDebug("FieldCheck: mandatory missing - [$_]"); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $tvars{data}->{$_.'_err'} = ErrorSymbol(); | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # check for invalid fields | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | for my $z (keys %cgiparams) { | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | next unless($z =~ /err_(.*)/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $x = $1; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $tvars{data}->{$x . '_err'} = ErrorSymbol(); | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return $errors; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | sub ParamCheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParamCheck: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my ($fields) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | for my $key (keys %$fields) { | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | # clean up cgi parameters | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if($fields->{$key}{html} == 1) { $cgiparams{$key} = CleanHTML($cgiparams{$key}) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | elsif($fields->{$key}{html} == 2) { $cgiparams{$key} = CleanTags($cgiparams{$key}) } | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | elsif($fields->{$key}{html} == 3) { $cgiparams{$key} = CleanLink($cgiparams{$key}) } | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | # store field | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | # automatically turn arrays into strings, in case someone is trying | ||||||||||||||||||||||||||||||||||||||||||
| 328 | # to subvert the data input process. known arrays are correctly stored | ||||||||||||||||||||||||||||||||||||||||||
| 329 | # appropriately elsewhere. | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $tvars{data}->{$key} = join("|",CGIArray($key)); | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | # skip checks if optional field | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | next unless($fields->{$key}{type}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | # mandatory fields must contain values | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | next if(defined $cgiparams{$key} && exists $cgiparams{$key} && $cgiparams{$key}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $Labyrinth::Support::cgiparams{$key} and exists $Labyrinth::Support::cgiparams{$key} and $Labyrinth::Support::cgiparams{$key}
defined $Labyrinth::Support::cgiparams{$key} and exists $Labyrinth::Support::cgiparams{$key}
MC/DC0%0/3
defined $Labyrinth::Support::cgiparams{$key} and exists $Labyrinth::Support::cgiparams{$key} and $Labyrinth::Support::cgiparams{$key}
defined $Labyrinth::Support::cgiparams{$key}
exists $Labyrinth::Support::cgiparams{$key}
$Labyrinth::Support::cgiparams{$key}
Truth table0%0/4
A and B and C
A= defined $Labyrinth::Support::cgiparams{$key}B= exists $Labyrinth::Support::cgiparams{$key}C= $Labyrinth::Support::cgiparams{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | # if we get here, record missing field | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | LogDebug("FieldCheck: mandatory missing - [$key]"); | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $tvars{data}->{$key.'_err'} = ErrorSymbol(); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | # check for invalid fields | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | for my $z (keys %cgiparams) { | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | next unless($z =~ /err_(.*)/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $x = $1; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $tvars{data}->{$x . '_err'} = ErrorSymbol(); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return $errors; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | =item AccessName | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | Returns the access permission name, given the access id. | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | =item AccessID | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | Returns the access id, given the access permission name. | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | =item AccessUser | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | Returns whether the current user has access at the given level of permissions. | ||||||||||||||||||||||||||||||||||||||||||
| 368 | Default permission level is ADMIN. Returns 1 if permission is granted, 0 | ||||||||||||||||||||||||||||||||||||||||||
| 369 | otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | =item AccessGroup | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | Returns whether the current user has access to the given group. Returns 1 if | ||||||||||||||||||||||||||||||||||||||||||
| 374 | yes, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =item AccessSelect | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 379 | available access states. | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =item AccessAllFolders | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | Return list of folders current user has access to. | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | =item AccessAllAreas | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | Return list of areas current user has access to. | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub AccessName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessName: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | LoadAccess(); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return $settings{access}{ids}{$value}; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | sub AccessID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessID: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | LoadAccess(); | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return $settings{access}{names}{$value}; | |||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub AccessUser { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessUser: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $permission = shift; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | $permission = ADMIN unless(defined $permission); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | return 1 if(Authorised($permission)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $tvars{errcode} = 'BADACCESS'; | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | sub AccessGroup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessGroup: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my %hash = @_; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my $groupid = $hash{ID} || GetGroupID($hash{NAME}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$hash{'ID'} || GetGroupID($hash{'NAME'})
MC/DC0%0/2
$hash{'ID'} || GetGroupID($hash{'NAME'})
$hash{'ID'}
GetGroupID($hash{'NAME'})
Truth table0%0/3
A || B
A= $hash{'ID'}B= GetGroupID($hash{'NAME'})
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | return 0 unless($groupid); # this is not bad access, the group may have been deleted | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | return 1 if UserInGroup($groupid); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $tvars{errcode} = 'BADACCESS'; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub AccessSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessSelect: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | my $opt = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | my $name = shift || 'accessid'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'accessid'
MC/DC0%0/1
shift() || 'accessid'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | my $max = Authorised(MASTER) ? MASTER : ADMIN; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my @rows = $dbi->GetQuery('hash','AllAccess',$max); | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | DropDownRows($opt,$name,'accessid','accessname',@rows); | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | sub AccessAllFolders { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessAllFolders: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | my $userid = shift || $tvars{loginid}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $Labyrinth::Support::tvars{'loginid'}
MC/DC0%0/2
shift() || $Labyrinth::Support::tvars{'loginid'}
shift()
$Labyrinth::Support::tvars{'loginid'}
Truth table0%0/3
A || B
A= shift()B= $Labyrinth::Support::tvars{'loginid'}
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | my $access = shift || PUBLISHER; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 3
MC/DC0%0/1
shift() || 3
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $groups = getusergroups($userid); | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my @rows = $dbi->GetQuery('array','GetFolderAccess', | |||||||||||||||||||||||||||||||||||||||||
| 437 | {groups=>$groups,userid=>$userid,access=>$access}); | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my @folders = map {$_->[0]} @rows; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | return join(',',@folders); | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub AccessAllAreas { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccessAllAreas: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my @rows = $dbi->GetQuery('array','AllAreas'); | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my @areas = map {"'$_->[0]'"} @rows; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | return join(',',@areas); | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | =item RealmCheck | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | Checks whether the given realm is known within the system. | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =item RealmSelect | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 455 | available realms. | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | =item RealmName | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | Returns the name of a realm, given a realm id. | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | =item RealmID | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | Returns the id of a realm, given a realm name. | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub RealmCheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RealmCheck: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | while(@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my $realm = shift; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | return 1 if($realm eq $tvars{realm}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $tvars{errcode} = 'BADACCESS'; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | return 0; # failed | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub RealmSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RealmSelect: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $opt = shift; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my @rows = $dbi->GetQuery('hash','AllRealms'); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | DropDownRows($opt,'realmid','realmid','name',@rows); | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | sub RealmName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RealmName: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my @rows = $dbi->GetQuery('hash','GetRealmByID',$id); | |||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | return $rows[0]->{realm}; | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | sub RealmID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RealmID: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my @rows = $dbi->GetQuery('hash','GetRealmByName',$name); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | return $rows[0]->{realmid}; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | =item ProfileSelect | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | Returns a dropdown list for the current list of profiles. | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =item FolderID | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | Returns the folder id, given the folder name. | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | =item FolderName | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | Returns the name of a folder, given a folder id. | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | =item FolderSelect | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 510 | available folders. | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | sub ProfileSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProfileSelect: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | my $opt = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | my $name = shift || 'profile'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'profile'
MC/DC0%0/1
shift() || 'profile'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | LoadProfiles(); | |||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my @rows = map { { profile => $_ } } sort grep {$_ ne $settings{profiles}{default} } keys %{$settings{profiles}{profiles}}; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | unshift @rows, { profile => $settings{profiles}{default} } if($settings{profiles}{default}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | unshift @rows, { profile => 'Select Profile' }; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | DropDownRows($opt,$name,'profile','profile',@rows); | |||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub FolderID { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FolderID: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my $opt = shift || return; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my @rows = $dbi->GetQuery('hash','GetFolderByPath',$opt); | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | return @rows ? $rows[0]->{folderid} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | sub FolderName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FolderName: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | my $opt = shift || return; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my @rows = $dbi->GetQuery('hash','GetFolder',$opt); | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | return @rows ? $rows[0]->{foldername} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub FolderSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FolderSelect: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | my $opt = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | my $name = shift || 'folderid'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'folderid'
MC/DC0%0/1
shift() || 'folderid'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my @rows = $dbi->GetQuery('hash','AllFolders'); | |||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | DropDownRows($opt,$name,'folderid','foldername',@rows); | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | =item AreaSelect | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | Provides a dropdown selection box, as a XHTML code snippet, of the currently | ||||||||||||||||||||||||||||||||||||||||||
| 546 | available areas. | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | sub AreaSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AreaSelect: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $opt = shift; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my @rows = $dbi->GetQuery('hash','AllAreas'); | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | DropDownRows($opt,'area','areaid','title',@rows); | |||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | __END__ | ||||||||||||||||||||||||||||||||||||||||||