Enable clearing of an alias via OPAC
authorJeff Godin <jgodin@tadl.org>
Fri, 16 Nov 2012 21:23:19 +0000 (16:23 -0500)
committerJeff Godin <jgodin@tadl.org>
Fri, 16 Nov 2012 21:25:28 +0000 (16:25 -0500)
Enable clearing of the user's holdshelf alias via the OPAC.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index c766728..8a982a4 100644 (file)
@@ -1419,23 +1419,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);
index 3a3ddc1..6412457 100644 (file)
@@ -1564,11 +1564,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(