Portal/Scripts/profile.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 58 CC 3 SCAR 14.6
CC
3
Cov
0%
launch
6.0
input_html
6.0
BEGIN
2.0
CRAP 4.3
1 package CGI::Portal::Scripts::profile;
2 # Copyright (c) 2008 Alexander David P. All rights reserved.
3 #
4 # Profile page
5  
6 use strict;
7  
8 use CGI::Portal::Scripts;
9  
10 use vars qw(@ISA $VERSION);
11  
12 $VERSION = "0.12";
13  
14 @ISA = qw(CGI::Portal::Scripts);
15  
16 my $r;
17  
18 1;
19  
20 sub launch {
21 my $self = shift;
22  
23 # Authenticate
24 $self->authenticate_user();
25 if ($self->{'user'}){
26  
27 # Join user fields for SQL
28 my $fields = join(',', @{$self->{'conf'}{'user_additional'}});
29  
30 # Select users info
31 $r = $self->{'rdb'}->exec("select $fields from $self->{'conf'}{'user_table'} where $self->{'conf'}{'user_user_field'}=" . $self->{'rdb'}->escape($self->{'user'}) . " limit 1")->fetch;
32  
33 # Assign template vars
34 $self->CGI::Portal::Scripts::profile::input_html();
35  
36 # Assign tmpl
37 $self->assign_tmpl("profile.html");
38 }
39 }
40  
41 # Assign templ vars
42 sub input_html {
43 my $self = shift;
44 my @states = qw(Other AL AK AZ AR CA CO CT DC DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VA VT WA WV WI WY);
45  
46 # Template vars for user fields
47 my $c = 0;
48 foreach my $f (@{$self->{'conf'}{'user_additional'}}) {
49 my $value = $self->{'in'}{$f} || $r->[$c];
50 $self->{'tmpl_vars'}{$f} = $value;
51 $c++;
52 }
53  
54 # Default state
55 my $state_input = $self->{'in'}{'state'} || $r->[5];
56  
57 # HTML select for state
58 my $state = "<select name=state>";
59 foreach my $s (@states){
60 if ($s ne $state_input){
61 $state .= "<option>$s";
62 }else{
63 $state .= "<option selected>$s";
64 }
65 }
66 $state .= "</select>";
67  
68 # Assign to template var state
69 $self->{'tmpl_vars'}{'state'} = $state;
70 }