Bug 20687: Check all share keys for a given list

This patch gets all the shares for a list and iterates through to find
the correct one when accepting from a link

To test:
1 - Create a private list in the opac
2 - Invite 2 patrons to the list
3 - Try to accept from the patron you first shared to
4 - You will get a failure message about expiration of the link
5 - Apply patch
6 - Now try to accept the first share
7 - It works! Success!

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2018-05-01 13:47:18 +00:00
parent 4df24fdde1
commit 07cc384cda
1 changed files with 13 additions and 13 deletions

View File

@ -133,29 +133,29 @@ sub show_accept {
# We could have used ->find with the share id, but we don't want to change
# the url sent to the patron
my $shared_shelf = Koha::Virtualshelfshares->search(
my $shared_shelves = Koha::Virtualshelfshares->search(
{
shelfnumber => $param->{shelfnumber},
},
{
order_by => { -desc => 'sharedate' },
limit => 1,
}
);
if ( $shared_shelf ) {
$shared_shelf = $shared_shelf->next;
if ( $shared_shelves ) {
my $key = keytostring( stringtokey( $param->{key}, 0 ), 1 );
my $is_accepted = eval { $shared_shelf->accept( $key, $param->{loggedinuser} ) };
if ( $is_accepted ) {
notify_owner($param);
while ( my $shared_shelf = $shared_shelves->next ) {
my $is_accepted = eval { $shared_shelf->accept( $key, $param->{loggedinuser} ) };
if ( $is_accepted ) {
notify_owner($param);
#redirect to view of this shared list
print $param->{query}->redirect(
-uri => SHELVES_URL . $param->{shelfnumber},
-cookie => $param->{cookie}
);
exit;
#redirect to view of this shared list
print $param->{query}->redirect(
-uri => SHELVES_URL . $param->{shelfnumber},
-cookie => $param->{cookie}
);
exit;
}
}
$param->{errcode} = 7; #not accepted (key not found or expired)
} else {