| 1 | package CGI::Lazy::DB::RecordSet; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Tie::IxHash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub basewhere { | ||||||||||||||||||||||||||
|
Subroutine
basewhere: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | return $self->{_basewhere}; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub checkboxes { | ||||||||||||||||||||||||||
|
Subroutine
checkboxes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | return $self->{_checkboxes}; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | #-------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub createSelect { | ||||||||||||||||||||||||||
|
Subroutine
createSelect: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | my $joinstring = ''; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $orderbystring = $self->orderby ? ' order by '.$self->orderby : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | my $wherestring; | |||||||||||||||||||||||||||
| 30 | my @binds; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if (ref $self->where) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | my @wherelist = @{$self->where}; | |||||||||||||||||||||||||||
| 34 | 0 | my $where = shift @wherelist; | |||||||||||||||||||||||||||
| 35 | 0 | @binds = @wherelist; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($self->basewhere) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $wherestring = $self->where ? ' where '.$self->basewhere. ' and '.$where : ' where '.$self->basewhere; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | } else { | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $wherestring = $self->where ? ' where '.$where : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | } else { | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($self->basewhere) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $wherestring = $self->where ? ' where '.$self->basewhere. ' and '.$self->where : ' where '.$self->basewhere; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | $wherestring = $self->where ? ' where '.$self->where : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my @fieldlist; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | foreach my $field (keys %{$self->fieldlist}) { | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | unless ($self->displayOnly($field)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($self->readfunc($field)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 56 | 0 | push @fieldlist, $self->readfunc($field); | |||||||||||||||||||||||||||
| 57 | } elsif ($self->passwd($field)) { | ||||||||||||||||||||||||||||
| 58 | 0 | next; | |||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||
| 60 | 0 | push @fieldlist, $field; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($self->joins) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | foreach (@{$self->joins}) { | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | $joinstring .= " " if $joinstring; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | my $type = $_->{type}; | |||||||||||||||||||||||||||
| 69 | 0 | my $table = $_->{table}; | |||||||||||||||||||||||||||
| 70 | 0 | my $field1 = $_->{field1}; | |||||||||||||||||||||||||||
| 71 | 0 | my $field2 = $_->{field2}; | |||||||||||||||||||||||||||
| 72 | 0 | my $and = $_->{and}; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | $joinstring .= " $type join $table on $field1 = $field2 "; | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | $joinstring .= " and $and" if $and; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | return "select ". join (', ', @fieldlist)." from ".$self->table.$joinstring.$wherestring.$orderbystring, @binds; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub data { | ||||||||||||||||||||||||||
|
Subroutine
data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 85 | 0 | return $self->{_data}; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub db { | ||||||||||||||||||||||||||
|
Subroutine
db: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | return $self->{_db}; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 98 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | my $table = $self->table; | |||||||||||||||||||||||||||
| 101 | 0 | my $primarykey = $self->primarykey; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | foreach my $ID (keys %$data) { | |||||||||||||||||||||||||||
| 104 | 0 | my $query = "delete from $table where $primarykey = ?"; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ${$self->primarykeyhandle} = $ID; | |||||||||||||||||||||||||||
| 107 | # $self->q->util->debug->edump($query.", $ID"); | ||||||||||||||||||||||||||||
| 108 | 0 | $self->db->do($query, $ID); | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub displayOnly { | ||||||||||||||||||||||||||
|
Subroutine
displayOnly: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 116 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ($self->fieldlist->{$field}->{displayOnly}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 120 | 0 | return $self->fieldlist->{$field}->{displayOnly}; | |||||||||||||||||||||||||||
| 121 | } elsif ($self->fieldlist->{$field}->{displayonly}) { | ||||||||||||||||||||||||||||
| 122 | 0 | return $self->fieldlist->{$field}->{displayonly}; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||
| 125 | 0 | return; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub fieldlist { | ||||||||||||||||||||||||||
|
Subroutine
fieldlist: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 131 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | return $self->{_fieldlist}; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub handle { | ||||||||||||||||||||||||||
|
Subroutine
handle: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 138 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 139 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | return $self->fieldlist->{$field}->{handle}; | |||||||||||||||||||||||||||
| 143 | } else { | ||||||||||||||||||||||||||||
| 144 | 0 | return; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub hidden { | ||||||||||||||||||||||||||
|
Subroutine
hidden: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 151 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 0 | return $self->fieldlist->{$field}->{hidden}; | |||||||||||||||||||||||||||
| 155 | } else { | ||||||||||||||||||||||||||||
| 156 | 0 | return; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub inputMask { | ||||||||||||||||||||||||||
|
Subroutine
inputMask: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 163 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ($self->fieldlist->{$field}->{inputMask}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 167 | 0 | return $self->fieldlist->{$field}->{inputMask}; | |||||||||||||||||||||||||||
| 168 | } elsif ($self->fieldlist->{$field}->{inputmask}) { | ||||||||||||||||||||||||||||
| 169 | 0 | return $self->fieldlist->{$field}->{inputmask}; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||
| 172 | 0 | return; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub insert { | ||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=30 SCAR=68.4
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 179 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 180 | 0 | my $vars = shift; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | my $table = $self->table; | |||||||||||||||||||||||||||
| 183 | 0 | my $primarykey = $self->primarykey; | |||||||||||||||||||||||||||
| 184 | 0 | my $defaults = $self->insertdefaults; | |||||||||||||||||||||||||||
| 185 | 0 | my $additional = $self->insertadditional; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | foreach my $row (keys %$data) { | |||||||||||||||||||||||||||
| 188 | 0 | my @fieldlist; | |||||||||||||||||||||||||||
| 189 | my @binds; | ||||||||||||||||||||||||||||
| 190 | 0 | my @bindvalues; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if (%$vars) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 0 | foreach (keys %$vars) { | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ($vars->{$_}->{value}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | $data->{$row}->{$_} = ref $vars->{$_}->{value} ? ${$vars->{$_}->{value}} : $vars->{$_}->{value}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | # $self->q->util->debug->edump("var: ".$vars->{$_}->{value}." -- ".${$vars->{$_}->{value}}); | ||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ($defaults) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | foreach my $field (keys %$defaults) { | |||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ($defaults->{$field}->{value}) { #static quanities | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 0 | $data->{$row}->{$field} = $defaults->{$field}->{value}; | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($vars->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | ${$vars->{$field}->{handle}} = $defaults->{$field}->{value}; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | } else { #values pulled from queries and such | ||||||||||||||||||||||||||||
| 209 | 0 | my $result = $self->db->getarray(@{$defaults->{$field}->{sql}}); | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if (defined $result->[1] || defined $result->[0]->[1]) { #we got more than a single value, better warn | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result->[1] or defined $result->[0][1]
MC/DC0%0/2
defined $result->[1] or defined $result->[0][1]
defined $result->[1]
defined $result->[0][1]
Truth table0%0/3
A or B
A= defined $result->[1]B= defined $result->[0][1]
| |||||||||||||||||||||||||||||
| 212 | 0 | $self->q->errorHandler->dbReturnedMoreThanSingleValue; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | my $value = $result->[0]->[0]; | |||||||||||||||||||||||||||
| 216 | 0 | $data->{$row}->{$field} = $value; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($vars->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | ${$vars->{$field}->{handle}} = $value; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($vars->{$field}->{primarykey}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | ${$self->primarykeyhandle} = $value; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | foreach (keys %{$data->{$row}}) { | |||||||||||||||||||||||||||
| 230 | 0 | my $field = $self->verify($_); | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ($field) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | unless ($self->displayOnly($field) || $self->readOnly($field)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->displayOnly($field) or $self->readOnly($field)
MC/DC0%0/2
$self->displayOnly($field) or $self->readOnly($field)
$self->displayOnly($field)
$self->readOnly($field)
Truth table0%0/3
A or B
A= $self->displayOnly($field)B= $self->readOnly($field)
| |||||||||||||||||||||||||||||
| 233 | 0 | push @fieldlist, $field; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | my $value; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ($self->inputMask($field)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 239 | 0 | $value = sprintf $self->inputMask($field), $data->{$row}->{$field}; | |||||||||||||||||||||||||||
| 240 | } elsif ($self->passwd($field)){ | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($self->q->authn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | $value = $self->q->authn->passwdhash($data->{$row}->{$self->passwd($field)->{userField}}, $data->{$row}->{$field}); | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | } else { | ||||||||||||||||||||||||||||
| 245 | 0 | $value = $data->{$row}->{$field}; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($vars->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 0 | ${$vars->{$field}->{handle}} = $value; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ($field eq $self->primarykey) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | ${$self->primarykeyhandle} = $value; | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | push @bindvalues, $value; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ($self->writefunc($field) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 0 | push @binds, $self->fieldlist->{$field}->{writefunc}; | |||||||||||||||||||||||||||
| 261 | } else { | ||||||||||||||||||||||||||||
| 262 | 0 | push @binds, "?"; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | my $insertclause = join ', ', @fieldlist; | |||||||||||||||||||||||||||
| 270 | 0 | my $binds = join ', ', @binds; | |||||||||||||||||||||||||||
| 271 | 0 | my $query = "insert into $table ($insertclause) values ($binds)"; | |||||||||||||||||||||||||||
| 272 | # $self->q->util->debug->edump($query."\n".join ',', @bindvalues); | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | $self->db->do($query, @bindvalues); | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ($self->mysqlAuto) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 0 | my $query = 'select LAST_INSERT_ID()'; | |||||||||||||||||||||||||||
| 278 | 0 | ${$self->primarykeyhandle} = $self->db->get($query); | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($additional) { #addional queries run on insert | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 0 | foreach my $field (keys %$additional) { | |||||||||||||||||||||||||||
| 284 | 0 | my $result = $self->db->getarray($additional->{$field}->{sql}); | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if (defined $result->[1] || defined $result->[0]->[1]) { #we got more than a single value, better warn | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result->[1] or defined $result->[0][1]
MC/DC0%0/2
defined $result->[1] or defined $result->[0][1]
defined $result->[1]
defined $result->[0][1]
Truth table0%0/3
A or B
A= defined $result->[1]B= defined $result->[0][1]
| |||||||||||||||||||||||||||||
| 287 | 0 | $self->q->errorHandler->dbReturnedMoreThanSingleValue; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 0 | my $value = $result->[0]->[0]; | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ($additional->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 0 | ${$additional->{$field}->{handle}} = $value ; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub insertadditional { | ||||||||||||||||||||||||||
|
Subroutine
insertadditional: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 302 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | return $self->{_insertadditional}; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub insertdefaults { | ||||||||||||||||||||||||||
|
Subroutine
insertdefaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 309 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | return $self->{_insertdefaults}; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | #-------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub joins { | ||||||||||||||||||||||||||
|
Subroutine
joins: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 316 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return wantarray ? @{$self->{_joins}} : $self->{_joins}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | #-------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub label { | ||||||||||||||||||||||||||
|
Subroutine
label: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 323 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 324 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | return $self->fieldlist->{$field}->{label} ? $self->fieldlist->{$field}->{label} : $self->fieldlist->{$field}->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 331 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 332 | 0 | my $db = shift; | |||||||||||||||||||||||||||
| 333 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 0 | my $var = undef; | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | my $self = { | ||||||||||||||||||||||||||||
| 338 | _data => [], | ||||||||||||||||||||||||||||
| 339 | _db => $db, | ||||||||||||||||||||||||||||
| 340 | _table => $args->{table}, | ||||||||||||||||||||||||||||
| 341 | _basewhere => $args->{basewhere}, | ||||||||||||||||||||||||||||
| 342 | _primarykey => $args->{primarykey}, | ||||||||||||||||||||||||||||
| 343 | _orderby => $args->{orderby}, | ||||||||||||||||||||||||||||
| 344 | _joins => $args->{joins}, | ||||||||||||||||||||||||||||
| 345 | _insertdefaults => $args->{insertdefaults}, | ||||||||||||||||||||||||||||
| 346 | _insertadditional => $args->{insertadditional}, | ||||||||||||||||||||||||||||
| 347 | _updatedefaults => $args->{updatedefaults}, | ||||||||||||||||||||||||||||
| 348 | _updateadditional => $args->{updateadditional}, | ||||||||||||||||||||||||||||
| 349 | _where => '', | ||||||||||||||||||||||||||||
| 350 | _mysqlAuto => $args->{mysqlAuto}, | ||||||||||||||||||||||||||||
| 351 | 0 | _primarykeyhandle => \$var, | |||||||||||||||||||||||||||
| 352 | _checkboxes => [], | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | }; | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | $self->{_fieldlist} = {}; | |||||||||||||||||||||||||||
| 357 | 0 | tie (%{$self->{_fieldlist}}, 'Tie::IxHash'); | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | 0 | foreach (@{$args->{fieldlist}}) { | |||||||||||||||||||||||||||
| 360 | 0 | $self->{_fieldlist}{$_->{name}} = $_; | |||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ($_->{webcontrol} && ($_->{webcontrol}->{type} eq 'checkbox')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_->{"webcontrol"} and $_->{"webcontrol"}{"type"} eq "checkbox"
MC/DC0%0/2
$_->{"webcontrol"} and $_->{"webcontrol"}{"type"} eq "checkbox"
$_->{"webcontrol"}
$_->{"webcontrol"}{"type"} eq "checkbox"
Truth table0%0/3
A and B
A= $_->{"webcontrol"}B= $_->{"webcontrol"}{"type"} eq "checkbox"
| |||||||||||||||||||||||||||||
| 362 | 0 | push @{$self->{_checkboxes}}, $_->{name}; | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | return bless $self, $class; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub noLabel { | ||||||||||||||||||||||||||
|
Subroutine
noLabel: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 371 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 372 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 0 | return $self->fieldlist->{$field}->{noLabel}; | |||||||||||||||||||||||||||
| 376 | } else { | ||||||||||||||||||||||||||||
| 377 | 0 | return; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | #-------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub orderby { | ||||||||||||||||||||||||||
|
Subroutine
orderby: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 383 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 384 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | 0 | return $self->{_orderby} = $value; | |||||||||||||||||||||||||||
| 388 | } else { | ||||||||||||||||||||||||||||
| 389 | 0 | return $self->{_orderby}; | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub outputMask { | ||||||||||||||||||||||||||
|
Subroutine
outputMask: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 395 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 396 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ($self->fieldlist->{$field}->{outputMask}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 400 | 0 | return $self->fieldlist->{$field}->{outputMask}; | |||||||||||||||||||||||||||
| 401 | } elsif ($self->fieldlist->{$field}->{outputmask}) { | ||||||||||||||||||||||||||||
| 402 | 0 | return $self->fieldlist->{$field}->{outputmask}; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | } else { | ||||||||||||||||||||||||||||
| 405 | 0 | return; | |||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub multipleField { | ||||||||||||||||||||||||||
|
Subroutine
multipleField: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 411 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 412 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 0 | return $self->fieldlist->{$field}->{multi}; | |||||||||||||||||||||||||||
| 416 | } else { | ||||||||||||||||||||||||||||
| 417 | 0 | return; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | #---------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub multipleFieldList { | ||||||||||||||||||||||||||
|
Subroutine
multipleFieldList: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 423 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 0 | my @multipleFieldList; | |||||||||||||||||||||||||||
| 426 | 0 | foreach my $field (keys %{$self->{_fieldlist}}) { | |||||||||||||||||||||||||||
| 427 | 0 | ▶ | if ($self->multipleField($field)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | push @multipleFieldList, $self->fieldlist->{$field}->{name}; | |||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return wantarray ? @multipleFieldList : \@multipleFieldList; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 437 | 0 | ▶ | sub multipleFieldLabels { | ||||||||||||||||||||||||||
|
Subroutine
multipleFieldLabels: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 438 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 0 | my @multipleFieldLabels; | |||||||||||||||||||||||||||
| 441 | 0 | foreach my $field (keys %{$self->{_fieldlist}}) { | |||||||||||||||||||||||||||
| 442 | 0 | ▶ | if ($self->fieldlist->{$field}->{multi}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | 0 | ▶ | push @multipleFieldLabels, $self->fieldlist->{$field}->{label} ? $self->fieldlist->{$field}->{label} : $self->fieldlist->{$field}->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | 0 | ▶ | return wantarray ? @multipleFieldLabels : \@multipleFieldLabels; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 452 | 0 | ▶ | sub mysqlAuto { | ||||||||||||||||||||||||||
|
Subroutine
mysqlAuto: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 453 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 0 | return $self->{_mysqlAuto}; | |||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub passwd { | ||||||||||||||||||||||||||
|
Subroutine
passwd: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 461 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 462 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if ($self->fieldlist->{$field}->{passwd}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | 0 | return $self->fieldlist->{$field}->{passwd}; | |||||||||||||||||||||||||||
| 467 | } else { | ||||||||||||||||||||||||||||
| 468 | 0 | return; | |||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | } else { | ||||||||||||||||||||||||||||
| 471 | 0 | return; | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub primarykey { | ||||||||||||||||||||||||||
|
Subroutine
primarykey: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 477 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 478 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | 0 | return $self->{_primarykey} = $value; | |||||||||||||||||||||||||||
| 482 | } else { | ||||||||||||||||||||||||||||
| 483 | 0 | return $self->{_primarykey}; | |||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 488 | 0 | ▶ | sub primarykeyhandle { | ||||||||||||||||||||||||||
|
Subroutine
primarykeyhandle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 489 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 0 | return $self->{_primarykeyhandle}; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | #------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 495 | 0 | ▶ | sub q { | ||||||||||||||||||||||||||
|
Subroutine
q: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 496 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 0 | return $self->db->q; | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 502 | 0 | ▶ | sub readfunc { | ||||||||||||||||||||||||||
|
Subroutine
readfunc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 503 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 504 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 507 | 0 | return $self->fieldlist->{$field}->{readfunc}; | |||||||||||||||||||||||||||
| 508 | } else { | ||||||||||||||||||||||||||||
| 509 | 0 | return; | |||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 514 | 0 | ▶ | sub readOnly { | ||||||||||||||||||||||||||
|
Subroutine
readOnly: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 515 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 516 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ($self->fieldlist->{$field}->{readOnly}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 520 | 0 | return $self->fieldlist->{$field}->{readOnly}; | |||||||||||||||||||||||||||
| 521 | } elsif ($self->fieldlist->{$field}->{readonly}) { | ||||||||||||||||||||||||||||
| 522 | 0 | return $self->fieldlist->{$field}->{readonly}; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | } else { | ||||||||||||||||||||||||||||
| 525 | 0 | return; | |||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | #-------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 530 | 0 | ▶ | sub select { | ||||||||||||||||||||||||||
|
Subroutine
select: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 531 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 532 | 0 | my @bindvars = @_; | |||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | 0 | my ($query, @wherebinds) = $self->createSelect; | |||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if (@wherebinds) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 537 | 0 | unshift @bindvars, $_ for @wherebinds; | |||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 0 | my @data; | |||||||||||||||||||||||||||
| 541 | my $sth; | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 0 | my ($pkg, $file, $line) = caller; | |||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | 0 | eval { | |||||||||||||||||||||||||||
| 546 | 0 | $sth = $self->db->dbh->prepare($query); | |||||||||||||||||||||||||||
| 547 | 0 | $sth->execute(@bindvars); | |||||||||||||||||||||||||||
| 548 | # $self->q->util->debug->edump($query, @bindvars); | ||||||||||||||||||||||||||||
| 549 | }; | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 552 | 0 | $self->q->errorHandler->dbError($pkg, $file, $line, $query); | |||||||||||||||||||||||||||
| 553 | } else { | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | 0 | ▶ | while (my @record = $sth->fetchrow_array) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 556 | 0 | my @fieldlist = keys %{$self->fieldlist}; | |||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | 0 | my $record = {}; | |||||||||||||||||||||||||||
| 559 | 0 | tie (%$record, 'Tie::IxHash'); | |||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | 0 | for (0..$#fieldlist) { | |||||||||||||||||||||||||||
| 562 | 0 | ▶ | next if $self->passwd($fieldlist[$_]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 563 | 0 | $record->{$fieldlist[$_]} = $record[$_]; | |||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | 0 | push @data, $record; | |||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | 0 | $self->{_data} = \@data; | |||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | #$self->q->util->debug->edump(\@data); | ||||||||||||||||||||||||||||
| 573 | 0 | return $self->{_data}; | |||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 577 | 0 | ▶ | sub table { | ||||||||||||||||||||||||||
|
Subroutine
table: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 578 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 579 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 582 | 0 | return $self->{_table} = $value; | |||||||||||||||||||||||||||
| 583 | } else { | ||||||||||||||||||||||||||||
| 584 | 0 | return $self->{_table}; | |||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 589 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=36 SCAR=71.9
Pod
documented
| |||||||||||||||||||||||||||||
| 590 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 591 | 0 | my $data = shift; | |||||||||||||||||||||||||||
| 592 | 0 | my $vars = shift; | |||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 0 | my $table = $self->table; | |||||||||||||||||||||||||||
| 595 | 0 | my $primarykey = $self->primarykey; | |||||||||||||||||||||||||||
| 596 | 0 | my $defaults = $self->updatedefaults; | |||||||||||||||||||||||||||
| 597 | 0 | my $additional = $self->updateadditional; | |||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | 0 | foreach my $ID (keys %$data) { | |||||||||||||||||||||||||||
| 600 | 0 | my @updates; | |||||||||||||||||||||||||||
| 601 | my @binds; | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if (%$vars) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 604 | 0 | foreach (keys %$vars) { | |||||||||||||||||||||||||||
| 605 | 0 | ▶ | if ($vars->{$_}->{value}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 606 | 0 | ▶ | $data->{$ID}->{$_} = ref $vars->{$_}->{value} ? ${$vars->{$_}->{value}} : $vars->{$_}->{value}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 607 | # $self->q->util->debug->edump("var: ".$vars->{$_}->{value}." -- ".${$vars->{$_}->{value}}); | ||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | 0 | ▶ | if ($defaults) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 613 | 0 | foreach my $field (keys %$defaults) { | |||||||||||||||||||||||||||
| 614 | 0 | ▶ | if ($defaults->{$field}->{value}) { #static quanities | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 615 | 0 | $data->{$ID}->{$field} = $defaults->{$field}->{value}; | |||||||||||||||||||||||||||
| 616 | 0 | ▶ | if ($vars->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 617 | 0 | ${$vars->{$field}->{handle}} = $defaults->{$field}->{value}; | |||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||
| 619 | } else { #values pulled from queries and such | ||||||||||||||||||||||||||||
| 620 | 0 | my $result = $self->db->getarray(@{$defaults->{$field}->{sql}}); | |||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 0 | ▶ | if (defined $result->[1] || defined $result->[0]->[1]) { #we got more than a single value, better warn | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result->[1] or defined $result->[0][1]
MC/DC0%0/2
defined $result->[1] or defined $result->[0][1]
defined $result->[1]
defined $result->[0][1]
Truth table0%0/3
A or B
A= defined $result->[1]B= defined $result->[0][1]
| |||||||||||||||||||||||||||||
| 623 | 0 | $self->q->errorHandler->dbReturnedMoreThanSingleValue; | |||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | 0 | my $value = $result->[0]->[0]; | |||||||||||||||||||||||||||
| 627 | 0 | $data->{$ID}->{$field} = $value; | |||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | 0 | ▶ | if ($vars->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 630 | 0 | ${$vars->{$field}->{handle}} = $value; | |||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | 0 | foreach (keys %{$data->{$ID}}) { | |||||||||||||||||||||||||||
| 638 | 0 | my $field = $self->verify($_); | |||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if ($field) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 641 | 0 | ▶ | unless ($self->displayOnly($field) || $self->readOnly($field)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->displayOnly($field) or $self->readOnly($field)
MC/DC0%0/2
$self->displayOnly($field) or $self->readOnly($field)
$self->displayOnly($field)
$self->readOnly($field)
Truth table0%0/3
A or B
A= $self->displayOnly($field)B= $self->readOnly($field)
| |||||||||||||||||||||||||||||
| 642 | 0 | ▶ | if ($vars->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 643 | 0 | ${$vars->{$field}->{handle}} = $data->{$ID}->{$field}; | |||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | 0 | ▶ | if ($field eq $self->primarykey) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 648 | 0 | ${$self->primarykeyhandle} = $data->{$ID}->{$field}; | |||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if ($self->inputMask($field)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 653 | 0 | push @binds, sprintf $self->inputMask($field), $data->{$ID}->{$field}; | |||||||||||||||||||||||||||
| 654 | } elsif ($self->passwd($field)){ | ||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if ($data->{$ID}->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if ($self->q->authn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 657 | 0 | push @binds, $self->q->authn->passwdhash($data->{$ID}->{$self->passwd($field)->{userField}}, $data->{$ID}->{$field}); | |||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||
| 660 | } else { | ||||||||||||||||||||||||||||
| 661 | 0 | push @binds, $data->{$ID}->{$field}; | |||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if ($self->writefunc($field) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 665 | 0 | push @updates, "$field = ".$self->fieldlist->{$field}->{writefunc}; | |||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | } elsif ($self->passwd($field)) { | ||||||||||||||||||||||||||||
| 668 | 0 | ▶ | if ($self->q->authn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 669 | 0 | ▶ | if ($data->{$ID}->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 670 | 0 | push @updates, "$field = ?"; | |||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||
| 673 | } else { | ||||||||||||||||||||||||||||
| 674 | 0 | push @updates, "$field = ?"; | |||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||
| 680 | 0 | ▶ | if (@{$self->checkboxes}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 681 | 0 | foreach (@{$self->checkboxes}) { | |||||||||||||||||||||||||||
| 682 | 0 | ▶ | next if exists $data->{$ID}->{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if ($vars->{$_}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 685 | 0 | ${$vars->{$_}->{handle}} = ''; | |||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | 0 | push @updates, "$_ = ?"; | |||||||||||||||||||||||||||
| 689 | 0 | push @binds, ''; | |||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | 0 | my $updateclause = join ',', @updates; | |||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | 0 | my $query = "update $table set $updateclause where $primarykey = ?"; | |||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | # $self->q->util->debug->edump($query, join ',', @binds. " key: $ID"); | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | 0 | $self->db->do($query, @binds, $ID); | |||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | 0 | ${$self->primarykeyhandle} = $ID; | |||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | 0 | ▶ | if ($additional) { #addional queries run on insert | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 705 | 0 | foreach my $field (keys %$additional) { | |||||||||||||||||||||||||||
| 706 | 0 | my $result = $self->db->getarray($additional->{$field}->{sql}); | |||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | 0 | ▶ | if (defined $result->[1] || defined $result->[0]->[1]) { #we got more than a single value, better warn | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result->[1] or defined $result->[0][1]
MC/DC0%0/2
defined $result->[1] or defined $result->[0][1]
defined $result->[1]
defined $result->[0][1]
Truth table0%0/3
A or B
A= defined $result->[1]B= defined $result->[0][1]
| |||||||||||||||||||||||||||||
| 709 | 0 | $self->q->errorHandler->dbReturnedMoreThanSingleValue; | |||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | 0 | my $value = $result->[0]->[0]; | |||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | 0 | ▶ | if ($additional->{$field}->{handle}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 715 | 0 | ${$additional->{$field}->{handle}} = $value ; | |||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 725 | 0 | ▶ | sub updateadditional { | ||||||||||||||||||||||||||
|
Subroutine
updateadditional: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 726 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | 0 | return $self->{_updateadditional}; | |||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 732 | 0 | ▶ | sub updatedefaults { | ||||||||||||||||||||||||||
|
Subroutine
updatedefaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 733 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | 0 | return $self->{_updatedefaults}; | |||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 739 | 0 | ▶ | sub validator { | ||||||||||||||||||||||||||
|
Subroutine
validator: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 740 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 741 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 744 | 0 | return $self->fieldlist->{$field}->{validator}; | |||||||||||||||||||||||||||
| 745 | } else { | ||||||||||||||||||||||||||||
| 746 | 0 | return; | |||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||
| 751 | #---------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 752 | 0 | ▶ | sub verify { | ||||||||||||||||||||||||||
|
Subroutine
verify: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 753 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 754 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||
| 756 | 0 | $value =~ /^([\w\d\-\.]+)$/; #letters, numbers, underscores, dots, and dashes only please. | |||||||||||||||||||||||||||
| 757 | 0 | my $field = $1; | |||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { #fieldname has to be in recordset | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 760 | 0 | ▶ | if ($field =~ /\./) { #if there's a . in the fieldname | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 761 | 0 | my $table = $self->table; | |||||||||||||||||||||||||||
| 762 | 0 | ▶ | if ($field =~ /^$table/) { #the first part has to be the recordset's table | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 763 | 0 | return $field; | |||||||||||||||||||||||||||
| 764 | } else { # its a joined field, no modification allowed | ||||||||||||||||||||||||||||
| 765 | 0 | return; | |||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||
| 768 | 0 | return $field; | |||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | 0 | return; | |||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||
| 774 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 775 | 0 | ▶ | sub visibleFieldLabels { | ||||||||||||||||||||||||||
|
Subroutine
visibleFieldLabels: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 776 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | 0 | my @visibleFieldLabels; | |||||||||||||||||||||||||||
| 779 | 0 | foreach my $field (keys %{$self->{_fieldlist}}) { | |||||||||||||||||||||||||||
| 780 | 0 | ▶ | unless ($self->fieldlist->{$field}->{hidden}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 781 | 0 | ▶ | push @visibleFieldLabels, $self->fieldlist->{$field}->{label} ? $self->fieldlist->{$field}->{label} : $self->fieldlist->{$field}->{name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||
| 785 | 0 | ▶ | return wantarray ? @visibleFieldLabels : \@visibleFieldLabels; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||
| 789 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 790 | 0 | ▶ | sub visibleFields { | ||||||||||||||||||||||||||
|
Subroutine
visibleFields: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 791 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||
| 793 | 0 | my @visibleFieldList; | |||||||||||||||||||||||||||
| 794 | 0 | foreach my $field (keys %{$self->{_fieldlist}}) { | |||||||||||||||||||||||||||
| 795 | 0 | ▶ | unless ($self->fieldlist->{$field}->{hidden}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 796 | 0 | push @visibleFieldList, $self->fieldlist->{$field}->{name}; | |||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||
| 800 | 0 | ▶ | return wantarray ? @visibleFieldList : \@visibleFieldList; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 804 | 0 | ▶ | sub webcontrol { | ||||||||||||||||||||||||||
|
Subroutine
webcontrol: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 805 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 806 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 809 | 0 | return $self->fieldlist->{$field}->{webcontrol}; | |||||||||||||||||||||||||||
| 810 | } else { | ||||||||||||||||||||||||||||
| 811 | 0 | return; | |||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||
| 815 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 816 | 0 | ▶ | sub where { | ||||||||||||||||||||||||||
|
Subroutine
where: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 817 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 818 | 0 | my @values = @_; | |||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||
| 820 | 0 | ▶ | if (@values) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 821 | 0 | ▶ | if (scalar @values > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 822 | 0 | return $self->{_where} = \@values; #theres a list, store an arrayref | |||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | } else { | ||||||||||||||||||||||||||||
| 825 | 0 | return $self->{_where} = $values[0]; #where is a single string, store a scalar | |||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||
| 827 | } else { | ||||||||||||||||||||||||||||
| 828 | 0 | return $self->{_where}; | |||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 833 | 0 | ▶ | sub writefunc { | ||||||||||||||||||||||||||
|
Subroutine
writefunc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 834 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 835 | 0 | my $field = shift; | |||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | 0 | ▶ | if (exists $self->fieldlist->{$field}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 838 | 0 | return $self->fieldlist->{$field}->{writefunc}; | |||||||||||||||||||||||||||
| 839 | } else { | ||||||||||||||||||||||||||||
| 840 | 0 | return; | |||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||
| 844 | 1 | 1; | |||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||
| 846 | __END__ | ||||||||||||||||||||||||||||