aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm20
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm18
2 files changed, 36 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 9baee5eb4..ac462e293 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -398,6 +398,13 @@ sub initialize_report : Private {
}
+ if ( $c->req->param('first_name') && $c->req->param('last_name') ) {
+ $c->stash->{first_name} = $c->req->param('first_name');
+ $c->stash->{last_name} = $c->req->param('last_name');
+
+ $c->req->param( 'name', sprintf( '%s %s', $c->req->param('first_name'), $c->req->param('last_name') ) );
+ }
+
# Capture whether the map was used
$report->used_map( $c->req->param('skipped') ? 0 : 1 );
@@ -791,13 +798,22 @@ sub process_report : Private {
}
if ( $contacts[0]->area_id == 2482 ) {
- for my $field ( qw/ fms_extra_title / ) {
+ for my $field ( qw/ fms_extra_title first_name last_name / ) {
+ my $value = $c->request->param( $field );
+ if ( !$value ) {
+ $c->stash->{field_errors}->{ $field } = _('This information is required');
+ }
push @extra, {
name => $field,
description => uc( $field),
- value => $c->request->param( $field ) || '',
+ value => $value || '',
};
}
+
+ if ( $c->request->param('fms_extra_title') ) {
+ $c->stash->{fms_extra_title} = $c->request->param('fms_extra_title');
+ $c->stash->{extra_name_info} = 1;
+ }
}
if ( @extra ) {
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 56d726a8d..7b0ffca73 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -172,4 +172,22 @@ sub belongs_to_council {
return 0;
}
+=head2 split_name
+
+ $name = $user->split_name;
+ printf( 'Welcome %s %s', $name->{first}, $name->{last} );
+
+Returns a hashref with first and last keys with first name(s) and last name.
+NB: the spliting algorithm is extremely basic.
+
+=cut
+
+sub split_name {
+ my $self = shift;
+
+ my ($first, $last) = $self->name =~ /^(\S*)(?: (.*))?$/;
+
+ return { first => $first, last => $last };
+}
+
1;