return $self->load_mylist_delete if $path =~ m|opac/mylist/delete|;
return $self->load_mylist_move if $path =~ m|opac/mylist/move|;
return $self->load_mylist_print if $path =~ m|opac/mylist/doprint|;
- return $self->load_mylist if $path =~ m|opac/mylist|;
+ return $self->load_mylist if $path =~ m|opac/mylist| && $path !~ m|opac/mylist/email| && $path !~ m|opac/mylist/doemail|;
return $self->load_cache_clear if $path =~ m|opac/cache/clear|;
return $self->load_temp_warn_post if $path =~ m|opac/temp_warn/post|;
return $self->load_temp_warn if $path =~ m|opac/temp_warn|;
$self->apache->headers_out->add("cache-control" => "no-store, no-cache, must-revalidate");
$self->apache->headers_out->add("expires" => "-1");
+ if ($path =~ m|opac/mylist/email|) {
+ (undef, $self->ctx->{mylist}) = $self->fetch_mylist;
+ }
+ $self->load_simple("mylist/email") if $path =~ m|opac/mylist/email|;
+ return $self->load_mylist_email if $path =~ m|opac/mylist/doemail|;
return $self->load_email_record if $path =~ m|opac/record/email|;
return $self->load_place_hold if $path =~ m|opac/place_hold|;
return $self->generic_redirect($url);
}
+sub load_mylist_email {
+ my $self = shift;
+
+ my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
+
+ if (!$cache_key) {
+ return $self->generic_redirect;
+ }
+
+ my $url = sprintf(
+ "%s://%s%s/record/email/%s",
+ $self->ctx->{proto},
+ $self->ctx->{hostname},
+ $self->ctx->{opac_root},
+ $cache_key,
+ );
+
+ my $redirect = $self->cgi->param('redirect_to');
+ $url .= '?redirect_to=' . uri_escape_utf8($redirect);
+ my $clear_cart = $self->cgi->param('clear_cart');
+ $url .= '&is_list=1';
+ $url .= '&clear_cart=1' if $clear_cart;
+
+ return $self->generic_redirect($url);
+}
+
sub load_mylist_move {
my $self = shift;
my @rec_ids = $self->cgi->param('record');
sub load_email_record {
my $self = shift;
- my $rec_id = $self->ctx->{page_args}->[0]
+ my $rec_or_list_id = $self->ctx->{page_args}->[0]
or return Apache2::Const::HTTP_BAD_REQUEST;
- $self->{ctx}->{bre_id} = $rec_id;
+ my $is_list = $self->cgi->param('is_list');
+ my $list;
+ if ($is_list) {
+
+ $list = $U->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.anon_cache.get_value',
+ $rec_or_list_id, (ref $self)->ANON_CACHE_MYLIST);
+
+ if(!$list) {
+ $list = [];
+ }
+
+ { # sanitize
+ no warnings qw/numeric/;
+ $list = [map { int $_ } @$list];
+ $list = [grep { $_ > 0} @$list];
+ };
+ } else {
+ $list = $rec_or_list_id;
+ $self->{ctx}->{bre_id} = $rec_or_list_id;
+ }
+
$U->simplereq(
'open-ils.search',
'open-ils.search.biblio.record.email',
- $self->ctx->{authtoken}, $rec_id);
+ $self->ctx->{authtoken}, $list);
+
+ if ($self->cgi->param('clear_cart')) {
+ $self->clear_anon_cache;
+ }
+ $self->ctx->{'redirect_to'} = $self->cgi->param('redirect_to');
return Apache2::Const::OK;
}
--- /dev/null
+[%- PROCESS "opac/parts/header.tt2";
+ PROCESS "opac/parts/misc_util.tt2";
+ WRAPPER "opac/parts/base.tt2";
+ INCLUDE "opac/parts/topnav.tt2";
+ ctx.page_title = l("Confirm Cart Email") %]
+ <h2 class="sr-only">[% l('Confirm Cart Email') %]</h2>
+ [% INCLUDE "opac/parts/searchbar.tt2" %]
+ <div id="content-wrapper">
+ <div id="main-content">
+ <p class="big-strong">[% l('Please confirm that you want to email the [_1] titles in the cart.', ctx.mylist.size) %]
+ <form method="post" action="[% mkurl(ctx.opac_root _ '/mylist/doemail', {}, 1) %]">
+ <input type="hidden" name="redirect_to" value="[% ctx.referer %]" />
+ <input type="checkbox" name="clear_cart" value="on" />
+ <label for="clear_cart">[% l('Clear cart after emailing it.') %]</label>
+ <br />
+ <input id="print_cart_submit" type="submit" name="submit"
+ value="[% l('Confirm') %]" title="[% l('Confirm') %]"
+ alt="[% l('Confirm') %]" class="opac-button" />
+ <input type="reset" name="cancel" onclick="window.location='[% ctx.referer | html %]'" value="[% l('Cancel') %]" id="clear_cart_cancel" class="opac-button" />
+ </form>
+ <div class="common-full-pad"></div>
+ </div>
+ </div>
+[%- END %]
<li><a href="[% mkurl(ctx.opac_root _ '/mylist', {}) %]">[% l('View Cart') %]</a></li>
<li><a href="#">[% l('Place Holds') %]</a></li>
<li><a href="[% mkurl(ctx.opac_root _ '/mylist/print', {}) %]">[% l('Print Title Details') %]</a></li>
- <li><a href="#">[% l('Email Title Details') %]</a></li>
+ <li><a href="[% mkurl(ctx.opac_root _ '/mylist/email', {}) %]">[% l('Email Title Details') %]</a></li>
<li><a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {}) %]">[% l('Add Cart to Saved List') %]</a></li>
<li><a href="[% mkurl(ctx.opac_root _ '/mylist/clear', {}) %]">[% l('Clear Cart') %]</a></li>
</ul>
</h2>
[% END %]
<br/>
+ [% IF ctx.redirect_to %]
+ <p>[ <a href="[% ctx.redirect_to | html %]">[% l("Return") %]</a> ] </p>
+ [% ELSE %]
<p>[ <a href="[% mkurl(ctx.opac_root _ '/record/' _ ctx.bre_id) %]">[% l("Back to Record") %]</a> ]</p>
+ [% END %]
<div class="common-full-pad"></div>
</div>
<br class="clear-both" />