From a622e4a4d085f6d22b8990c0b9fd3b3887201ca1 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Fri, 16 Nov 2012 16:23:19 -0500 Subject: [PATCH] Enable clearing of an alias via OPAC Enable clearing of the user's holdshelf alias via the OPAC. Signed-off-by: Jeff Godin --- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 35 +++++++++++++--------- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 5 ---- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 71ebd572dd..3bfcedf4c5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -1505,23 +1505,30 @@ sub update_passwd { $db_user->usrname($new_val); } elsif( $api =~ /alias/o ) { - - my $exist = $e->search_actor_user( - { alias => { - "=" => { - transform => "evergreen.lowercase", - value => lc($new_val) + # if we are attempting to set an alias, perform a case-insensitive + # search and reject if duplicate. + # XXX: make this configurable at some level + if ($new_val && $new_val ne '') { + my $exist = $e->search_actor_user( + { alias => { + "=" => { + transform => "evergreen.lowercase", + value => lc($new_val) + } } - } - }, - { idlist => 1 } - ); + }, + { idlist => 1 } + ); - if (@$exist) { - $e->rollback; - return new OpenILS::Event('USERNAME_EXISTS'); + if (@$exist) { + $e->rollback; + return new OpenILS::Event('USERNAME_EXISTS'); + } + $db_user->alias($new_val); + } else { + # we were provided with an empty value -- clear the alias + $db_user->clear_alias; } - $db_user->alias($new_val); } elsif( $api =~ /email/o ) { $db_user->email($new_val); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 86f073abbf..9dc7f73f37 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -2144,11 +2144,6 @@ sub load_myopac_update_alias { 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( -- 2.11.0