[open-ils-commits] r11249 - trunk/Open-ILS/src/perlmods/OpenILS/Application

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Nov 17 14:37:32 EST 2008


Author: erickson
Date: 2008-11-17 14:37:28 -0500 (Mon, 17 Nov 2008)
New Revision: 11249

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Log:
added API for merging users

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-11-17 19:36:50 UTC (rev 11248)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2008-11-17 19:37:28 UTC (rev 11249)
@@ -2988,5 +2988,51 @@
     return 0;
 }
 
+
+
+__PACKAGE__->register_method (
+	method		=> 'merge_users',
+	api_name	=> 'open-ils.actor.user.merge',
+	signature	=> {
+        desc => q/
+            Given a source user and destination user, transfer all data from the source
+            to the dest. user and delete the source user.  All user related data is 
+            transferred, including circulations, holds, bookbags, etc.
+        /
+    }
+);
+
+sub merge_users {
+    my($self, $conn, $auth, $src_id, $dest_id, $options) = @_;
+    my $e = new_editor(xact => 1, authtoken => $auth);
+	return $e->die_event unless $e->checkauth;
+
+    my $src_user = $e->retrieve_actor_user($src_id) or return $e->die_event;
+    my $dest_user = $e->retrieve_actor_user($dest_id) or return $e->die_event;
+
+    return $e->die_event unless $e->allowed('MERGE_USERS', $src_user->home_ou);
+    if($src_user->home_ou ne $dest_user->home_ou) {
+        return $e->die_event unless $e->allowed('MERGE_USERS', $dest_user->home_ou);
+    }
+
+    my $query = {
+        select => {
+            au => [ {
+                transform => 'actor.usr_merge',
+                params => [$dest_id],
+                column => 'id',
+            } ]
+        },
+        from => 'au',
+        where => {id => $src_id},
+    };
+
+    return $e->die_event unless $e->json_query($query);
+    $e->commit;
+    return 1;
+}
+
+
+
 1;
 



More information about the open-ils-commits mailing list