push(@errors, "Invalid dob")
unless $phash->{dob} =~ m/^\d{4}-\d{2}-\d{2}$/;
- if (my $dp = $phash->{day_phone}) {
+ # we cannot continue if errors have occured at this stage.
+ return @errors if @errors;
- if ($dp =~ /^\(?\d{3}\)?-?\s*-?\s*$/) {
- # if the day_phone only contains an area code, treat it as unset.
- $dp = undef;
+ # day_phone is not required, but if it's set,
+ # it has to be in a format we can understand.
+ # If it's malformed, we treat it as unset.
+ if (my $dp = $phash->{day_phone}) {
- } elsif ($dp =~ /^\(?(\d{3})\)?[- \.](\d{3})[- \.](\d{4})$/) {
+ if ($dp =~ /^\(?(\d{3})\)?[- \.](\d{3})[- \.](\d{4})$/) {
# Supported phone formats:
# XXX-YYY-ZZZZ / (XXX) YYY-ZZZZ / XXX.YYY.ZZZZ
$phash->{day_phone} = $dp;
} else {
- # Phone exists, is more than an area code, but is otherwise
- # malformed. Kick it back for repairs.
- push(@errors, "Invalid day_phone");
+ # Phone exists, but is malformed.
+ $phash->{day_phone} = undef;
}
}
- # we cannot continue if errors have occured at this stage.
- return @errors if @errors;
-
# password uses the last 4 characters of the student ID,
# unless a default password is set.
$phash->{passwd} = $default_pass ? $default_pass :
return 0;
}
- announce('DEBUG', "Purging user $bc with ID $user_id");
-
eval {
$db_handle->selectrow_array(
"SELECT actor.usr_delete($user_id, NULL)");
family_name,
expire_date,
dob,
+ day_phone,
email
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
SQL
$create_addr_sth = $db_handle->prepare(<<SQL);
$phash->{family_name},
$phash->{expire_date},
$phash->{dob},
+ $phash->{day_phone},
$phash->{email},
);