added method to add a user to one or more groups
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 Dec 2005 21:09:13 +0000 (21:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 Dec 2005 21:09:13 +0000 (21:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2453 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm

index 78813d2..be94e9f 100644 (file)
@@ -1218,7 +1218,7 @@ __PACKAGE__->register_method(
        method  => "retrieve_groups",
        api_name        => "open-ils.actor.groups.retrieve",
        notes           => <<"  NOTES");
-       Returns a list of user groups
+       Returns a list of user groupss
        NOTES
 sub retrieve_groups {
        my( $self, $client ) = @_;
@@ -1270,6 +1270,34 @@ sub build_group_tree {
 }
 
 
+__PACKAGE__->register_method(
+       method  => "add_user_to_groups",
+       api_name        => "open-ils.actor.user.add_to_groups",
+       notes           => <<"  NOTES");
+       Adds a user to one or more permission groups
+       NOTES
+
+sub add_user_to_groups {
+       my( $self, $client, $authtoken, $userid, @groups ) = @_;
+       my( $requestor, $target, $evt ) = $apputils->checkses_requestor(
+               $authtoken, $userid, 'CREATE_USER_GROUP_LINK' );
+       return $evt if $evt;
+
+       for my $group (@groups) {
+               my $link = Fieldmapper::permission::usr_grp_map->new;
+               $link->grp($group);
+               $link->usr($userid);
+               my $id = $apputils->simplereq(
+                       'open-ils.storage',
+                       'open-ils.storage.direct.permission.usr_grp_map.create', $link );
+               throw OpenSRF::EX::ERROR 
+                       ("Unable to create new permission.usr_grp_map object") unless $id;
+       }
+
+       return 1;
+}
+
+