updating a username returns an event if the requested username already exists
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Dec 2005 15:56:07 +0000 (15:56 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Dec 2005 15:56:07 +0000 (15:56 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2547 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/web/opac/locale/en-US/opac_common.dtd
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/xml/common/ilsevents.xml

index 9080479..03cb5cc 100644 (file)
                </desc>
        </event>
 
+       <event code='1200' textcode='USERNAME_EXISTS'>
+               <desc>
+                       The given username exists in the database
+               </desc>
+       </event>
+
+
        <event code='1500' textcode='CIRCULATION_NOT_FOUND'>
                <desc>
                        Someone attempted to retrieve a circulation object from the system and 
index 5916f2e..ea802c8 100644 (file)
@@ -995,6 +995,10 @@ sub update_password {
                $user_obj->passwd($new_value);
        } 
        elsif($self->api_name =~ /username/) {
+               my $users = search_username(undef, undef, $new_value); 
+               if( $users and $users->[0] ) {
+                       return OpenILS::Event->new('USERNAME_EXISTS');
+               }
                $user_obj->usrname($new_value);
        }
 
index e51ddf3..3af30e2 100644 (file)
@@ -2,6 +2,7 @@
 <!ENTITY ilsevent.1000 "Login failed.  The username or password entered was incorrect.">
 <!ENTITY ilsevent.1001 "Login session has timed out or does not exist">
 <!ENTITY ilsevent.1002 "User was not found in the database">
+<!ENTITY ilsevent.1200 "The given username already exists in the database">
 <!ENTITY ilsevent.5000 "Permission Denied">
 <!ENTITY ilsperm.CREATE_HOLD "User is not allowed to create holds for other users at this location">
 
index 60e7bd7..e4debd0 100644 (file)
@@ -245,7 +245,8 @@ function myOPACFleshHoldTitle(r) {
 
        if(form) {
                var img = elem("img");
-               img.setAttribute("src", buildImageLink('tor/' + record.types_of_resource()[0] + ".jpg"));
+               img.setAttribute("src", 
+                       buildImageLink('tor/' + record.types_of_resource()[0] + ".jpg"));
                addCSSClass(img, "myopac_form_pic");
                form.appendChild(img);
        }
@@ -425,6 +426,13 @@ function myOPACUpdateUsername() {
        var req = new Request(UPDATE_USERNAME, G.user.session, username );
        req.send(true);
        if(req.result()) {
+
+               var evt;
+               if(evt = checkILSEvent(req.result())) {
+                       alertILSEvent(evt);
+                       return;
+               }
+
                G.user.usrname(username);
                hideMe($('myopac_update_username_row'));
                userShown = false;
index 671430d..dcef13f 100644 (file)
@@ -2,6 +2,7 @@
        <span id='ilsevent.1000'>&ilsevent.1000;</span>
        <span id='ilsevent.1001'>&ilsevent.1001;</span>
        <span id='ilsevent.1002'>&ilsevent.1002;</span>
+       <span id='ilsevent.1200'>&ilsevent.1200;</span>
        <span id='ilsevent.5000'>&ilsevent.5000;</span>
        <span id='ilsperm.CREATE_HOLD'>&ilsperm.CREATE_HOLD;</span>