From 3fe0ee0b51ce4e5ea22fde0a03fadad55de34382 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 6 Aug 2013 14:31:41 -0400 Subject: [PATCH] LP1207396 Patron self-registration web form Signed-off-by: Bill Erickson --- .../lib/OpenILS/WWW/EGCatLoader/Register.pm | 27 ++++++++++++++++++++++ Open-ILS/src/templates/opac/register.tt2 | 9 ++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm index 613cca8e2b..1b359a68f1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm @@ -16,6 +16,7 @@ sub load_patron_reg { my $cgi = $self->cgi; $ctx->{register} = {}; $self->collect_register_validation_settings; + $self->collect_requestor_info; # in the home org unit selector, we only want to present # org units to the patron which support self-registration. @@ -88,6 +89,32 @@ sub load_patron_reg { return Apache2::Const::OK; } +# if the pending account is requested by an existing user account, +# load the existing user's data to pre-populate some fields. +sub collect_requestor_info { + my $self = shift; + return unless $self->ctx->{user}; + + my $user = $self->editor->retrieve_actor_user([ + $self->ctx->{user}->id, + {flesh => 1, flesh_fields => { + au => [qw/mailing_address billing_address/]} + } + ]); + + + my $vhash = $self->ctx->{register}{values} = {}; + my $addr = $user->mailing_address || $user->billing_address; + $vhash->{stgu}{home_ou} = $user->home_ou; + + if ($addr) { + $vhash->{stgma}{city} = $addr->city; + $vhash->{stgma}{county} = $addr->county; + $vhash->{stgma}{state} = $addr->state; + $vhash->{stgma}{post_code} = $addr->post_code; + } +} + # if the username is in use by an actor.usr OR a # pending user treat it as taken and warn the user. sub test_requested_username { diff --git a/Open-ILS/src/templates/opac/register.tt2 b/Open-ILS/src/templates/opac/register.tt2 index b565bb43ec..518420c3e0 100644 --- a/Open-ILS/src/templates/opac/register.tt2 +++ b/Open-ILS/src/templates/opac/register.tt2 @@ -92,7 +92,7 @@ register_fields = [ [% INCLUDE build_org_selector name='stgu.home_ou' - value=ctx_org + value=value || ctx_org can_have_users_only=1 valid_org_list=ctx.register.valid_orgs %] @@ -116,6 +116,7 @@ FOR field_def IN register_fields; show = ctx.register.settings.$fclass.$fname.show; require = ctx.register.settings.$fclass.$fname.require; example = ctx.register.settings.$fclass.$fname.example; + value = ctx.register.values.$fclass.$fname; invalid_require = ctx.register.invalid.$fclass.$fname.require; invalid_regex = ctx.register.invalid.$fclass.$fname.regex; @@ -130,7 +131,7 @@ FOR field_def IN register_fields; + value='[% value || CGI.param(field_path) | html %]'/> [% IF require %] * [% END %] @@ -159,11 +160,9 @@ FOR field_def IN register_fields; [% END %] - + [% l('Go Back') %] - - -- 2.11.0