|
Lines 51-60
sub accept {
Link Here
|
| 51 |
if ( $self->invitekey ne $invitekey ) { |
51 |
if ( $self->invitekey ne $invitekey ) { |
| 52 |
Koha::Exceptions::Virtualshelves::InvalidInviteKey->throw; |
52 |
Koha::Exceptions::Virtualshelves::InvalidInviteKey->throw; |
| 53 |
} |
53 |
} |
| 54 |
$self->invitekey(undef); |
54 |
|
| 55 |
$self->sharedate(dt_from_string); |
55 |
# If this borrower already has a share, there is no need to accept twice |
| 56 |
$self->borrowernumber($borrowernumber); |
56 |
# We solve this by 'pretending' to reaccept, but delete instead |
| 57 |
$self->store; |
57 |
my $search = Koha::Virtualshelfshares->search({ shelfnumber => $self->shelfnumber, borrowernumber => $borrowernumber, invitekey => undef }); |
|
|
58 |
if( $search->count ) { |
| 59 |
$self->delete; |
| 60 |
return $search->next; |
| 61 |
} else { |
| 62 |
$self->invitekey(undef); |
| 63 |
$self->sharedate(dt_from_string); |
| 64 |
$self->borrowernumber($borrowernumber); |
| 65 |
$self->store; |
| 66 |
return $self; |
| 67 |
} |
| 58 |
} |
68 |
} |
| 59 |
|
69 |
|
| 60 |
sub has_expired { |
70 |
sub has_expired { |
| 61 |
- |
|
|