__PACKAGE__->register_method(
method => "update_passwd",
+ api_name => "open-ils.actor.user.alias.update",
+ signature => {
+ desc => "Update the operator's alias",
+ params => [
+ { desc => 'Authentication token', type => 'string' },
+ { desc => 'New alias', type => 'string' },
+ { desc => 'Current password', type => 'string' }
+ ],
+ return => {desc => '1 on success, Event on error or incorrect current password'}
+ }
+);
+
+__PACKAGE__->register_method(
+ method => "update_passwd",
api_name => "open-ils.actor.user.email.update",
signature => {
desc => "Update the operator's email address",
}
$db_user->usrname($new_val);
+ } elsif( $api =~ /alias/o ) {
+
+ my $exist = $e->search_actor_user({alias=>$new_val},{idlist=>1});
+ if (@$exist) {
+ $e->rollback;
+ return new OpenILS::Event('USERNAME_EXISTS');
+ }
+ $db_user->alias($new_val);
+
} elsif( $api =~ /email/o ) {
$db_user->email($new_val);
}
return $self->load_myopac_main if $path =~ m|opac/myopac/main|;
return $self->load_myopac_receipt_email if $path =~ m|opac/myopac/receipt_email|;
return $self->load_myopac_receipt_print if $path =~ m|opac/myopac/receipt_print|;
+ return $self->load_myopac_update_alias if $path =~ m|opac/myopac/update_alias|;
return $self->load_myopac_update_email if $path =~ m|opac/myopac/update_email|;
return $self->load_myopac_update_password if $path =~ m|opac/myopac/update_password|;
return $self->load_myopac_update_username if $path =~ m|opac/myopac/update_username|;
return $self->generic_redirect($url);
}
+sub load_myopac_update_alias {
+ my $self = shift;
+ my $e = $self->editor;
+ my $ctx = $self->ctx;
+ my $alias = $self->cgi->param('alias') || '';
+ my $current_pw = $self->cgi->param('current_pw') || '';
+
+ $self->prepare_extended_user_info;
+
+ return Apache2::Const::OK
+ unless $self->cgi->request_method eq 'POST';
+
+ unless($alias) {
+ $ctx->{invalid_alias} = $alias;
+ return Apache2::Const::OK;
+ }
+
+ if($alias ne $e->requestor->alias) {
+
+ my $evt = $U->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.user.alias.update',
+ $e->authtoken, $alias, $current_pw);
+
+ if($U->event_equals($evt, 'INCORRECT_PASSWORD')) {
+ $ctx->{password_incorrect} = 1;
+ return Apache2::Const::OK;
+ }
+
+ if($U->event_equals($evt, 'USERNAME_EXISTS')) {
+ $ctx->{alias_exists} = $alias;
+ return Apache2::Const::OK;
+ }
+ }
+
+ my $url = $self->apache->unparsed_uri;
+ $url =~ s/update_alias/prefs/;
+
+ return $self->generic_redirect($url);
+}
+
sub load_myopac_update_password {
my $self = shift;
my $e = $self->editor;
<td class='light_border'>[% ctx.user.email | html %]</td>
<td class='light_border'><a href='update_email'>[% l('Change') %]</a></td>
</tr>
+ <tr>
+ <td class='color_4 light_border'>[% l("Holdshelf Alias") %]</td>
+ <td class='light_border'>[% ctx.user.alias | html %]</td>
+ <td class='light_border'><a href='update_alias'>[% l('Change') %]</a></td>
+ </tr>
[% IF ctx.user.ident_value %]<tr class="hide_me">
<td class='color_4 light_border'>
--- /dev/null
+[% PROCESS "opac/parts/header.tt2";
+ PROCESS "opac/parts/misc_util.tt2";
+ WRAPPER "opac/parts/myopac/base.tt2";
+ myopac_page = "prefs" %]
+<div id='myopac_summary_div' style="padding:0px;">
+
+[% IF ctx.alias_exists %]
+ <div id='account-update-alias-error'>
+ [% bad_alias = ctx.alias_exists | html %]
+ [% | l(bad_alias) %]
+ The alias "<b>[_1]</b>" is taken. Please try a different alias.
+ [% END %]
+ </div>
+
+[% ELSIF ctx.password_incorrect %]
+ <div id='account-update-alias-error'>
+ [% |l %] Your current password was not correct. [% END %]
+ </div>
+
+[% END %]
+
+<form method='POST' id='account-update-alias'>
+ <table>
+ <tr><td>[% l('Current Alias') %]</td><td>[% ctx.user.alias | html %]</td></tr>
+ <tr><td>[% l('Current Password') %]</td><td><input type='password' name='current_pw'/></td></tr>
+ <tr><td>[% l('New Alias') %]</td><td><input type='text' name='alias' value='[% ctx.invalid_alias | html %]'/></td></tr>
+ <tr><td colspan='2' align='center'><input value="[% l('Submit') %]" type='submit'/></td></tr>
+ </table>
+</form>
+
+[% END %]