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.
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 {
</td>
<td>[% 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
%]
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;
<input
type='text'
name='[% field_path %]'
- value='[% CGI.param(field_path) | html %]'/>
+ value='[% value || CGI.param(field_path) | html %]'/>
[% IF require %]
<span class='patron-reg-invalid'>*</span>
[% END %]
[% END %]
<!-- ====> shifting the code back to the right for context -->
<tr>
- <td>
+ <td colspan='3'>
<a href="[% ctx.opac_root %]/home"
class="opac-button">[% l('Go Back') %]</a>
- </td>
- <td>
<input type="submit"
value="[% l('Submit Registration') %]"
class="opac-button" />