From: erickson Date: Mon, 18 Feb 2008 23:08:52 +0000 (+0000) Subject: added method to retrieve all picklists a user has access to X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6719ad2d14e93f5beafaddf1a3427c871186b412;p=Evergreen.git added method to retrieve all picklists a user has access to git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8769 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm index 13e10f9e53..77ef2019bc 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm @@ -164,11 +164,59 @@ sub retrieve_user_picklist { $_->entry_count(retrieve_picklist_entry_count($e, $_->id)) for @$list; }; + if($$options{flesh_username}) { + $_->owner($e->retrieve_actor_user($_->owner)->usrname) for @$list; + } + return $list; } __PACKAGE__->register_method( + method => 'retrieve_all_user_picklist', + api_name => 'open-ils.acq.picklist.user.all.retrieve', + stream => 1, + signature => { + desc => 'Retrieves all of the picklists a user is allowed to see', + params => [ + {desc => 'Authentication token', type => 'string'}, + {desc => 'Options, including "idlist", whch forces the return + of a list of IDs instead of objects', type => 'hash'}, + ], + return => {desc => 'Picklist objects on success, Event on error'} + } +); + +sub retrieve_all_user_picklist { + my($self, $conn, $auth, $options) = @_; + my $e = new_editor(authtoken=>$auth); + return $e->event unless $e->checkauth; + + my $my_list = $e->search_acq_picklist( + {owner=>$e->requestor->id, name=>{'!='=>''}}, {idlist=>1}); + + my $picklist_ids = $e->objects_allowed('VIEW_PICKLIST', 'acqpl'); + + return undef unless @$my_list or @$picklist_ids; + + if($$options{idlist}) { + return [@$my_list, @$picklist_ids]; + } + + for my $pl (@$my_list, @$picklist_ids) { + my $picklist = $e->retrieve_acq_picklist($pl) or return $e->event; + $picklist->entry_count(retrieve_picklist_entry_count($e, $picklist->id)) + if($$options{flesh_entry_count}); + $picklist->owner($e->retrieve_actor_user($picklist->owner)->usrname) + if $$options{flesh_username}; + $conn->respond($picklist); + } + + return undef; +} + + +__PACKAGE__->register_method( method => 'delete_picklist', api_name => 'open-ils.acq.picklist.delete', signature => {