1 package OpenILS::WWW::EGCatLoader;
2 use strict; use warnings;
3 use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
4 use OpenSRF::Utils::Logger qw/$logger/;
5 use OpenILS::Utils::CStoreEditor qw/:funcs/;
6 use OpenILS::Utils::Fieldmapper;
7 use OpenILS::Application::AppUtils;
8 use OpenSRF::Utils::JSON;
9 my $U = 'OpenILS::Application::AppUtils';
11 sub prepare_extended_user_info {
14 $self->ctx->{user} = $self->editor->retrieve_actor_user([
15 $self->ctx->{user}->id,
19 au => [qw/card home_ou addresses ident_type billing_address/]
23 ]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
29 # user : au object, fleshed
30 sub load_myopac_prefs {
32 return $self->prepare_extended_user_info || Apache2::Const::OK;
35 sub load_myopac_prefs_notify {
37 my $e = $self->editor;
39 my $user_prefs = $self->fetch_optin_prefs;
40 $user_prefs = $self->update_optin_prefs($user_prefs)
41 if $self->cgi->request_method eq 'POST';
43 $self->ctx->{opt_in_settings} = $user_prefs;
45 return Apache2::Const::OK;
48 sub fetch_optin_prefs {
50 my $e = $self->editor;
52 # fetch all of the opt-in settings the user has access to
53 # XXX: user's should in theory have options to opt-in to notices
54 # for remote locations, but that opens the door for a large
55 # set of generally un-used opt-ins.. needs discussion
56 my $opt_ins = $U->simplereq(
58 'open-ils.actor.event_def.opt_in.settings.atomic',
59 $e->authtoken, $e->requestor->home_ou);
61 # fetch user setting values for each of the opt-in settings
62 my $user_set = $U->simplereq(
64 'open-ils.actor.patron.settings.retrieve',
67 [map {$_->name} @$opt_ins]
70 return [map { {cust => $_, value => $user_set->{$_->name} } } @$opt_ins];
73 sub update_optin_prefs {
75 my $user_prefs = shift;
76 my $e = $self->editor;
77 my @settings = $self->cgi->param('setting');
80 # apply now-true settings
81 for my $applied (@settings) {
82 # see if setting is already applied to this user
83 next if grep { $_->{cust}->name eq $applied and $_->{value} } @$user_prefs;
84 $newsets{$applied} = OpenSRF::Utils::JSON->true;
87 # remove now-false settings
88 for my $pref (grep { $_->{value} } @$user_prefs) {
89 $newsets{$pref->{cust}->name} = undef
90 unless grep { $_ eq $pref->{cust}->name } @settings;
95 'open-ils.actor.patron.settings.update',
96 $e->authtoken, $e->requestor->id, \%newsets);
98 # update the local prefs to match reality
99 for my $pref (@$user_prefs) {
100 $pref->{value} = $newsets{$pref->{cust}->name}
101 if exists $newsets{$pref->{cust}->name};
107 sub load_myopac_prefs_settings {
109 return $self->prepare_extended_user_info || Apache2::Const::OK;
112 sub fetch_user_holds {
114 my $hold_ids = shift;
115 my $ids_only = shift;
117 my $available = shift;
121 my $e = $self->editor;
123 my $circ = OpenSRF::AppSession->create('open-ils.circ');
127 $hold_ids = $circ->request(
128 'open-ils.circ.holds.id_list.retrieve.authoritative',
133 $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
137 return $hold_ids if $ids_only or @$hold_ids == 0;
140 suppress_notices => 1,
141 suppress_transits => 1,
143 suppress_patron_details => 1,
144 include_bre => $flesh ? 1 : 0
147 # ----------------------------------------------------------------
148 # Collect holds in batches of $batch_size for faster retrieval
152 my $mk_req_batch = sub {
154 my $top_idx = $batch_idx + $batch_size;
155 while($batch_idx < $top_idx) {
156 my $hold_id = $hold_ids->[$batch_idx++];
157 last unless $hold_id;
158 my $ses = OpenSRF::AppSession->create('open-ils.circ');
159 my $req = $ses->request(
160 'open-ils.circ.hold.details.retrieve',
161 $e->authtoken, $hold_id, $args);
162 push(@ses, {ses => $ses, req => $req});
168 my(@collected, @holds, @ses);
171 @ses = $mk_req_batch->() if $first;
172 last if $first and not @ses;
175 # If desired by the caller, filter any holds that are not available.
177 @collected = grep { $_->{hold}->{status} == 4 } @collected;
179 while(my $blob = pop(@collected)) {
180 $blob->{marc_xml} = XML::LibXML->new->parse_string($blob->{hold}->{bre}->marc) if $flesh;
185 for my $req_data (@ses) {
186 push(@collected, {hold => $req_data->{req}->gather(1)});
187 $req_data->{ses}->kill_me;
190 @ses = $mk_req_batch->();
191 last unless @collected or @ses;
195 # put the holds back into the original server sort order
197 for my $id (@$hold_ids) {
198 push @sorted, grep { $_->{hold}->{hold}->id == $id } @holds;
204 sub handle_hold_update {
207 my $e = $self->editor;
210 my @hold_ids = $self->cgi->param('hold_id'); # for non-_all actions
211 @hold_ids = @{$self->fetch_user_holds(undef, 1)} if $action =~ /_all/;
213 my $circ = OpenSRF::AppSession->create('open-ils.circ');
215 if($action =~ /cancel/) {
217 for my $hold_id (@hold_ids) {
218 my $resp = $circ->request(
219 'open-ils.circ.hold.cancel', $e->authtoken, $hold_id, 6 )->gather(1); # 6 == patron-cancelled-via-opac
222 } elsif ($action =~ /activate|suspend/) {
225 for my $hold_id (@hold_ids) {
226 my $vals = {id => $hold_id};
228 if($action =~ /activate/) {
229 $vals->{frozen} = 'f';
230 $vals->{thaw_date} = undef;
232 } elsif($action =~ /suspend/) {
233 $vals->{frozen} = 't';
234 # $vals->{thaw_date} = TODO;
236 push(@$vlist, $vals);
239 $circ->request('open-ils.circ.hold.update.batch.atomic', $e->authtoken, undef, $vlist)->gather(1);
240 } elsif ($action eq 'edit') {
243 my $val = {"id" => $_};
244 $val->{"frozen"} = $self->cgi->param("frozen");
245 $val->{"pickup_lib"} = $self->cgi->param("pickup_lib");
247 for my $field (qw/expire_time thaw_date/) {
248 # XXX TODO make this support other date formats, not just
250 next unless $self->cgi->param($field) =~
251 m:^(\d{2})/(\d{2})/(\d{4})$:;
252 $val->{$field} = "$3-$1-$2";
258 'open-ils.circ.hold.update.batch.atomic',
259 $e->authtoken, undef, \@vals
260 )->gather(1); # LFW XXX test for failure
261 $url = 'https://' . $self->apache->hostname . $self->ctx->{opac_root} . '/myopac/holds';
265 return defined($url) ? $self->generic_redirect($url) : undef;
268 sub load_myopac_holds {
270 my $e = $self->editor;
271 my $ctx = $self->ctx;
274 my $limit = $self->cgi->param('limit') || 0;
275 my $offset = $self->cgi->param('offset') || 0;
276 my $action = $self->cgi->param('action') || '';
277 my $available = int($self->cgi->param('available') || 0);
279 my $hold_handle_result;
280 $hold_handle_result = $self->handle_hold_update($action) if $action;
282 $ctx->{holds} = $self->fetch_user_holds(undef, 0, 1, $available, $limit, $offset);
284 return defined($hold_handle_result) ? $hold_handle_result : Apache2::Const::OK;
287 sub load_place_hold {
289 my $ctx = $self->ctx;
290 my $e = $self->editor;
291 my $cgi = $self->cgi;
292 $self->ctx->{page} = 'place_hold';
294 $ctx->{hold_target} = $cgi->param('hold_target');
295 $ctx->{hold_type} = $cgi->param('hold_type');
296 $ctx->{default_pickup_lib} = $e->requestor->home_ou; # XXX staff
298 if ($ctx->{hold_type} eq 'T') {
299 $ctx->{record} = $e->retrieve_biblio_record_entry($ctx->{hold_target});
300 } elsif ($ctx->{hold_type} eq 'I') {
301 my $iss = $e->retrieve_serial_issuance([
302 $ctx->{hold_target}, {
305 "siss" => ["subscription"], "ssub" => ["record_entry"]
309 $ctx->{record} = $iss->subscription->record_entry;
313 $ctx->{marc_xml} = XML::LibXML->new->parse_string($ctx->{record}->marc);
315 if(my $pickup_lib = $cgi->param('pickup_lib')) {
318 patronid => $e->requestor->id,
319 titleid => $ctx->{hold_target}, # XXX
320 pickup_lib => $pickup_lib,
324 my $allowed = $U->simplereq(
326 'open-ils.circ.title_hold.is_possible',
330 if($allowed->{success} == 1) {
331 my $hold = Fieldmapper::action::hold_request->new;
333 $hold->pickup_lib($pickup_lib);
334 $hold->requestor($e->requestor->id);
335 $hold->usr($e->requestor->id); # XXX staff
336 $hold->target($ctx->{hold_target});
337 $hold->hold_type($ctx->{hold_type});
338 # frozen, expired, etc..
340 my $stat = $U->simplereq(
342 'open-ils.circ.holds.create',
346 if($stat and $stat > 0) {
347 # if successful, return the user to the requesting page
348 $self->apache->log->info("Redirecting back to " . $cgi->param('redirect_to'));
349 return $self->generic_redirect;
352 $ctx->{hold_failed} = 1;
354 } else { # hold *check* failed
355 $ctx->{hold_failed} = 1; # XXX process the events, etc
356 $ctx->{hold_failed_event} = $allowed->{last_event};
360 $logger->info('hold permit result ' . OpenSRF::Utils::JSON->perl2JSON($allowed));
363 return Apache2::Const::OK;
367 sub fetch_user_circs {
369 my $flesh = shift; # flesh bib data, etc.
370 my $circ_ids = shift;
374 my $e = $self->editor;
379 @circ_ids = @$circ_ids;
383 my $circ_data = $U->simplereq(
385 'open-ils.actor.user.checked_out',
390 @circ_ids = ( @{$circ_data->{overdue}}, @{$circ_data->{out}} );
392 if($limit or $offset) {
393 @circ_ids = grep { defined $_ } @circ_ids[0..($offset + $limit - 1)];
397 return [] unless @circ_ids;
399 my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
404 circ => ['target_copy'],
405 acp => ['call_number'],
411 my $circs = $e->search_action_circulation(
412 [{id => \@circ_ids}, ($flesh) ? $qflesh : {}], {substream => 1});
415 for my $circ (@$circs) {
418 marc_xml => ($flesh and $circ->target_copy->call_number->id != -1) ?
419 XML::LibXML->new->parse_string($circ->target_copy->call_number->record->marc) :
420 undef # pre-cat copy, use the dummy title/author instead
425 # make sure the final list is in the correct order
427 for my $id (@circ_ids) {
430 (grep { $_->{circ}->id == $id } @circs)
434 return \@sorted_circs;
438 sub handle_circ_renew {
441 my $ctx = $self->ctx;
443 my @renew_ids = $self->cgi->param('circ');
445 my $circs = $self->fetch_user_circs(0, ($action eq 'renew') ? [@renew_ids] : undef);
447 # TODO: fire off renewal calls in batches to speed things up
449 for my $circ (@$circs) {
451 my $evt = $U->simplereq(
453 'open-ils.circ.renew',
454 $self->editor->authtoken,
456 patron_id => $self->editor->requestor->id,
457 copy_id => $circ->{circ}->target_copy,
462 # TODO return these, then insert them into the circ data
463 # blob that is shoved into the template for each circ
464 # so the template won't have to match them
465 push(@responses, {copy => $circ->{circ}->target_copy, evt => $evt});
472 sub load_myopac_circs {
474 my $e = $self->editor;
475 my $ctx = $self->ctx;
478 my $limit = $self->cgi->param('limit') || 0; # 0 == unlimited
479 my $offset = $self->cgi->param('offset') || 0;
480 my $action = $self->cgi->param('action') || '';
482 # perform the renewal first if necessary
483 my @results = $self->handle_circ_renew($action) if $action =~ /renew/;
485 $ctx->{circs} = $self->fetch_user_circs(1, undef, $limit, $offset);
487 my $success_renewals = 0;
488 my $failed_renewals = 0;
489 for my $data (@{$ctx->{circs}}) {
490 my ($resp) = grep { $_->{copy} == $data->{circ}->target_copy->id } @results;
493 my $evt = ref($resp->{evt}) eq 'ARRAY' ? $resp->{evt}->[0] : $resp->{evt};
494 $data->{renewal_response} = $evt;
495 $success_renewals++ if $evt->{textcode} eq 'SUCCESS';
496 $failed_renewals++ if $evt->{textcode} ne 'SUCCESS';
500 $ctx->{success_renewals} = $success_renewals;
501 $ctx->{failed_renewals} = $failed_renewals;
503 return Apache2::Const::OK;
506 sub load_myopac_circ_history {
508 my $e = $self->editor;
509 my $ctx = $self->ctx;
510 my $limit = $self->cgi->param('limit') || 15;
511 my $offset = $self->cgi->param('offset') || 0;
513 $ctx->{circ_history_limit} = $limit;
514 $ctx->{circ_history_offset} = $offset;
516 my $circs = $e->json_query({
517 from => ['action.usr_visible_circs', $e->requestor->id],
518 #limit => $limit || 25,
519 #offset => $offset || 0,
522 # XXX: order-by in the json_query above appears to do nothing, so in-query
523 # paging is not reallly an option. do the sorting/paging here
525 # sort newest to oldest
526 $circs = [ sort { $b->{xact_start} cmp $a->{xact_start} } @$circs ];
527 my @ids = map { $_->{id} } @$circs;
529 # find the selected page and trim cruft
530 @ids = @ids[$offset..($offset + $limit - 1)] if $limit;
531 @ids = grep { defined $_ } @ids;
533 $ctx->{circs} = $self->fetch_user_circs(1, \@ids);
534 #$ctx->{circs} = $self->fetch_user_circs(1, [map { $_->{id} } @$circs], $limit, $offset);
536 return Apache2::Const::OK;
539 # TODO: action.usr_visible_holds does not return cancelled holds. Should it?
540 sub load_myopac_hold_history {
542 my $e = $self->editor;
543 my $ctx = $self->ctx;
544 my $limit = $self->cgi->param('limit') || 15;
545 my $offset = $self->cgi->param('offset') || 0;
546 $ctx->{hold_history_limit} = $limit;
547 $ctx->{hold_history_offset} = $offset;
550 my $holds = $e->json_query({
551 from => ['action.usr_visible_holds', $e->requestor->id],
552 limit => $limit || 25,
553 offset => $offset || 0
556 $ctx->{holds} = $self->fetch_user_holds([map { $_->{id} } @$holds], 0, 1, 0, $limit, $offset);
558 return Apache2::Const::OK;
561 sub load_myopac_payment_form {
565 $r = $self->prepare_fines(undef, undef, [$self->cgi->param('xact')]) and return $r;
566 $r = $self->prepare_extended_user_info and return $r;
568 return Apache2::Const::OK;
571 # TODO: add other filter options as params/configs/etc.
572 sub load_myopac_payments {
574 my $limit = $self->cgi->param('limit') || 20;
575 my $offset = $self->cgi->param('offset') || 0;
576 my $e = $self->editor;
578 $self->ctx->{payment_history_limit} = $limit;
579 $self->ctx->{payment_history_offset} = $offset;
582 $args->{limit} = $limit if $limit;
583 $args->{offset} = $offset if $offset;
585 $self->ctx->{payments} = $U->simplereq(
587 'open-ils.actor.user.payments.retrieve.atomic',
588 $e->authtoken, $e->requestor->id, $args);
590 return Apache2::Const::OK;
593 sub load_myopac_pay {
597 $r = $self->prepare_fines and return $r;
599 # balance_owed is computed specifically from the fines we're trying
600 # to pay in this case.
601 return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR if
602 $self->ctx->{fines}->{balance_owed} <= 0;
605 "where_process" => 1,
607 $cc_args->{$_} = $self->cgi->param($_) for (qw/
608 number cvv2 expire_year expire_month billing_first
609 billing_last billing_address billing_city billing_state
614 "cc_args" => $cc_args,
615 "userid" => $self->ctx->{user}->id,
616 "payment_type": "credit_card_payment",
617 "payments" => [$self->cgi->param('xact')] # should be safe after self->prepare_fines
620 $U->simplereq("open-ils.circ", "open-ils.circ.money.payment",
621 $self->editor->authtoken, $args, $self->ctx->{user}->last_xact_id
624 # XXX FINISH ME: indicate success/fail, redirect to page with layout
628 my ($self, $limit, $offset, $id_list) = @_;
630 # XXX TODO: check for failure after various network calls
632 $self->ctx->{"fines"} = {
640 my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
642 # TODO: This should really be a ML call, but the existing calls
643 # return an excessive amount of data and don't offer streaming
645 my %paging = ($limit or $offset) ? (limit => $limit, offset => $offset) : ();
647 my $req = $cstore->request(
648 'open-ils.cstore.direct.money.open_billable_transaction_summary.search',
650 usr => $self->editor->requestor->id,
651 balance_owed => {'!=' => 0},
652 ($id_list && @$id_list ? ("id" => $id_list) : ()),
657 mobts => [qw/grocery circulation reservation/],
658 bresv => ['target_resource_type'],
662 circ => ['target_copy'],
663 acp => ['call_number'],
666 order_by => { mobts => 'xact_start' },
671 my @total_keys = qw/total_paid total_owed balance_owed/;
672 $self->ctx->{"fines"}->{@total_keys} = (0, 0, 0);
674 while(my $resp = $req->recv) {
675 my $mobts = $resp->content;
676 my $circ = $mobts->circulation;
679 if($mobts->grocery) {
680 my @billings = sort { $a->billing_ts cmp $b->billing_ts } @{$mobts->grocery->billings};
681 $last_billing = pop(@billings);
684 # XXX TODO confirm that the following, and the later division by 100.0
685 # to get a floating point representation once again, is sufficiently
687 $self->ctx->{"fines"}->{$_} += int($mobts->$_ * 100) for (@total_keys);
689 my $marc_xml = undef;
690 if ($mobts->xact_type eq 'reservation' and
691 $mobts->reservation->target_resource_type->record) {
692 $marc_xml = XML::LibXML->new->parse_string(
693 $mobts->reservation->target_resource_type->record->marc
695 } elsif ($mobts->xact_type eq 'circulation' and
696 $circ->target_copy->call_number->id != -1) {
697 $marc_xml = XML::LibXML->new->parse_string(
698 $circ->target_copy->call_number->record->marc
703 @{$self->ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}},
706 last_grocery_billing => $last_billing,
707 marc_xml => $marc_xml
712 $self->ctx->{"fines"}->{$_} /= 100.0 for (@total_keys);
716 sub load_myopac_main {
718 my $limit = $self->cgi->param('limit') || 0;
719 my $offset = $self->cgi->param('offset') || 0;
721 return $self->prepare_fines($limit, $offset) || Apache2::Const::OK;
724 sub load_myopac_update_email {
726 my $e = $self->editor;
727 my $ctx = $self->ctx;
728 my $email = $self->cgi->param('email') || '';
730 return Apache2::Const::OK
731 unless $self->cgi->request_method eq 'POST';
733 unless($email =~ /.+\@.+\..+/) { # TODO better regex?
734 $ctx->{invalid_email} = $email;
735 return Apache2::Const::OK;
738 my $stat = $U->simplereq(
740 'open-ils.actor.user.email.update',
741 $e->authtoken, $email);
743 my $url = $self->apache->unparsed_uri;
744 $url =~ s/update_email/prefs/;
746 return $self->generic_redirect($url);
749 sub load_myopac_update_username {
751 my $e = $self->editor;
752 my $ctx = $self->ctx;
753 my $username = $self->cgi->param('username') || '';
755 return Apache2::Const::OK
756 unless $self->cgi->request_method eq 'POST';
758 unless($username and $username !~ /\s/) { # any other username restrictions?
759 $ctx->{invalid_username} = $username;
760 return Apache2::Const::OK;
763 if($username ne $e->requestor->usrname) {
765 my $evt = $U->simplereq(
767 'open-ils.actor.user.username.update',
768 $e->authtoken, $username);
770 if($U->event_equals($evt, 'USERNAME_EXISTS')) {
771 $ctx->{username_exists} = $username;
772 return Apache2::Const::OK;
776 my $url = $self->apache->unparsed_uri;
777 $url =~ s/update_username/prefs/;
779 return $self->generic_redirect($url);
782 sub load_myopac_update_password {
784 my $e = $self->editor;
785 my $ctx = $self->ctx;
787 return Apache2::Const::OK
788 unless $self->cgi->request_method eq 'POST';
790 my $current_pw = $self->cgi->param('current_pw') || '';
791 my $new_pw = $self->cgi->param('new_pw') || '';
792 my $new_pw2 = $self->cgi->param('new_pw2') || '';
794 unless($new_pw eq $new_pw2) {
795 $ctx->{password_nomatch} = 1;
796 return Apache2::Const::OK;
799 my $pw_regex = $ctx->{get_org_setting}->($e->requestor->home_ou, 'global.password_regex');
801 if($pw_regex and $new_pw !~ /$pw_regex/) {
802 $ctx->{password_invalid} = 1;
803 return Apache2::Const::OK;
806 my $evt = $U->simplereq(
808 'open-ils.actor.user.password.update',
809 $e->authtoken, $new_pw, $current_pw);
812 if($U->event_equals($evt, 'INCORRECT_PASSWORD')) {
813 $ctx->{password_incorrect} = 1;
814 return Apache2::Const::OK;
817 my $url = $self->apache->unparsed_uri;
818 $url =~ s/update_password/prefs/;
820 return $self->generic_redirect($url);
823 sub load_myopac_bookbags {
825 my $e = $self->editor;
826 my $ctx = $self->ctx;
828 $e->xact_begin; # replication...
830 my $rv = $self->load_mylist;
831 unless($rv eq Apache2::Const::OK) {
837 order_by => {cbreb => 'name'},
838 limit => $self->cgi->param('limit') || 10,
839 offset => $self->cgi->param('offset') || 0
842 $ctx->{bookbags} = $e->search_container_biblio_record_entry_bucket([
843 {owner => $self->editor->requestor->id, btype => 'bookbag'},
844 # XXX what to do about the possibility of really large bookbags here?
845 {"flesh" => 1, "flesh_fields" => {"cbreb" => ["items"]}, %$args}
848 if(!$ctx->{bookbags}) {
850 return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
853 # get unique record IDs
855 foreach my $bbag (@{$ctx->{bookbags}}) {
857 map { $_->target_biblio_record_entry } @{$bbag->items}
859 $rec_ids{$rec_id} = 1;
863 $ctx->{bookbags_marc_xml} = $self->fetch_marc_xml_by_id([keys %rec_ids]);
866 return Apache2::Const::OK;
870 # actions are create, delete, show, hide, rename, add_rec, delete_item
871 # CGI is action, list=list_id, add_rec/record=bre_id, del_item=bucket_item_id, name=new_bucket_name
872 sub load_myopac_bookbag_update {
873 my ($self, $action, $list_id) = @_;
874 my $e = $self->editor;
875 my $cgi = $self->cgi;
877 $action ||= $cgi->param('action');
878 $list_id ||= $cgi->param('list');
880 my @add_rec = $cgi->param('add_rec') || $cgi->param('record');
881 my @del_item = $cgi->param('del_item');
882 my $shared = $cgi->param('shared');
883 my $name = $cgi->param('name');
887 if($action eq 'create') {
888 $list = Fieldmapper::container::biblio_record_entry_bucket->new;
890 $list->owner($e->requestor->id);
891 $list->btype('bookbag');
892 $list->pub($shared ? 't' : 'f');
893 $success = $U->simplereq('open-ils.actor',
894 'open-ils.actor.container.create', $e->authtoken, 'biblio', $list)
898 $list = $e->retrieve_container_biblio_record_entry_bucket($list_id);
900 return Apache2::Const::HTTP_BAD_REQUEST unless
901 $list and $list->owner == $e->requestor->id;
904 if($action eq 'delete') {
905 $success = $U->simplereq('open-ils.actor',
906 'open-ils.actor.container.full_delete', $e->authtoken, 'biblio', $list_id);
908 } elsif($action eq 'show') {
909 unless($U->is_true($list->pub)) {
911 $success = $U->simplereq('open-ils.actor',
912 'open-ils.actor.container.update', $e->authtoken, 'biblio', $list);
915 } elsif($action eq 'hide') {
916 if($U->is_true($list->pub)) {
918 $success = $U->simplereq('open-ils.actor',
919 'open-ils.actor.container.update', $e->authtoken, 'biblio', $list);
922 } elsif($action eq 'rename') {
925 $success = $U->simplereq('open-ils.actor',
926 'open-ils.actor.container.update', $e->authtoken, 'biblio', $list);
929 } elsif($action eq 'add_rec') {
930 foreach my $add_rec (@add_rec) {
931 my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
932 $item->bucket($list_id);
933 $item->target_biblio_record_entry($add_rec);
934 $success = $U->simplereq('open-ils.actor',
935 'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
936 last unless $success;
939 } elsif($action eq 'del_item') {
940 foreach (@del_item) {
941 $success = $U->simplereq(
943 'open-ils.actor.container.item.delete', $e->authtoken, 'biblio', $_
945 last unless $success;
949 return $self->generic_redirect if $success;
951 $self->ctx->{bucket_action} = $action;
952 $self->ctx->{bucket_action_failed} = 1;
953 return Apache2::Const::OK;