return (undef, OpenILS::Event->new('USERNAME_EXISTS'));
}
+ $evt = _check_dup_ident($session, $patron);
+ return (undef, $evt) if $evt;
+
$logger->info("Creating new user in the DB with username: ".$patron->usrname());
my $id = $session->request(
$logger->info("Updating patron ".$patron->id." in DB");
+ my $evt;
+
if(!$noperm) {
- my $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'UPDATE_USER');
+ $evt = $U->check_perms($user_obj->id, $patron->home_ou, 'UPDATE_USER');
return (undef, $evt) if $evt;
}
+ $evt = _check_dup_ident($session, $patron);
+ return (undef, $evt) if $evt;
+
+
# update the password by itself to avoid the password protection magic
if( $patron->passwd ) {
my $s = $session->request(
return ($patron);
}
+sub _check_dup_ident {
+ my( $session, $patron ) = @_;
+
+ my $search = {
+ ident_type => $patron->ident_type,
+ ident_value => $patron->ident_value,
+ };
+
+ $logger->debug("patron update searching for dup ident values: " .
+ $patron->ident_type . ':' . $patron->ident_value);
+
+ $search->{id} = {'!=' => $patron->id} if $patron->id and $patron->id > 0;
+
+ my $dups = $session->request(
+ 'open-ils.storage.direct.actor.user.search_where.atomic', $search )->gather(1);
+
+
+ return OpenILS::Event->new('PATRON_DUP_IDENT1', payload => $patron )
+ if $dups and @$dups;
+
+ return undef;
+}
+
sub _add_update_addresses {
req.send(true);
var newuser = req.result();
- if( checkILSEvent(newuser) )
- alert(js2JSON(newuser));
- else
+ var evt;
+ if( (evt = checkILSEvent(newuser)) || ! newuser ) {
+ if(evt) alert(js2JSON(newuser));
+ return;
+
+ } else {
alert($('ue_success').innerHTML);
+ }
if(cloneme) {
/* if the user we just created was a clone, and we want to clone it,
}
);
- /*req.callback(uEditHandleDupResults);*/
req.callback(
function(r) {
uEditHandleDupResults( r.getResultObject(), search_hash, type, container );
uEditDupHashes[type] = search_hash;
switch(type) {
- case 'ident1' :
+ case 'ident' :
if(confirm($('ue_dup_ident1').innerHTML))
- uEditShowSearch(type);
+ uEditShowSearch(null, type);
break;
}
}
-function uEditShowSearch(link) {
- var type = link.getAttribute('type');
+function uEditShowSearch(link,type) {
+ if(!type) type = link.getAttribute('type');
if(window.xulG)
window.xulG.spawn_search(uEditDupHashes[type]);
else alert('Search would be:\n' + js2JSON(uEditDupHashes[type]));