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>
Thu, 26 Dec 2013 19:10:19 +0000 (14:10 -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 6db0bdb..5860c9d 100644 (file)
@@ -1439,23 +1439,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 2d4a22e..d8ff0fa 100644 (file)
@@ -1698,11 +1698,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(