Bugzilla – Attachment 193357 Details for
Bug 39658
Allow definition of non-hierarchical linked patron accounts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39658: Add link_to_patron and linked_account_links methods
Bug-39658-Add-linktopatron-and-linkedaccountlinks-.patch (text/plain), 2.99 KB, created by
Jacob O'Mara
on 2026-02-18 14:20:56 UTC
(
hide
)
Description:
Bug 39658: Add link_to_patron and linked_account_links methods
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2026-02-18 14:20:56 UTC
Size:
2.99 KB
patch
obsolete
>From 9add0c11a1f52d80eeeaf9ff7935d1bb029837b7 Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <Jacob.omara@openfifth.co.uk> >Date: Wed, 21 Jan 2026 15:36:17 +0000 >Subject: [PATCH] Bug 39658: Add link_to_patron and linked_account_links > methods > >- link_to_patron($other_patron): Links patrons, handles group logic >- linked_account_links(): Returns all links in patron's group >--- > Koha/Patron.pm | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 72 insertions(+) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index cbfd466c6e3..d95b3628200 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -46,6 +46,7 @@ use Koha::Encryption; > use Koha::Exceptions; > use Koha::Exceptions::Password; > use Koha::Exceptions::HoldGroup; >+use Koha::Exceptions::PatronAccountLink; > use Koha::Holds; > use Koha::HoldGroups; > use Koha::ILL::Requests; >@@ -704,6 +705,77 @@ sub linked_accounts_debt { > return $total; > } > >+=head3 linked_account_links >+ >+ my $links = $patron->linked_account_links; >+ >+Returns all AccountLinks in this patron's link group as a Koha::Patron::AccountLinks >+resultset, or undef if patron is not linked. >+ >+=cut >+ >+sub linked_account_links { >+ my ($self) = @_; >+ >+ my $link = $self->account_link; >+ return unless $link; >+ >+ return Koha::Patron::AccountLinks->search( { link_group_id => $link->link_group_id } ); >+} >+ >+=head3 link_to_patron >+ >+ my $link = $patron->link_to_patron( $other_patron ); >+ >+Links this patron to another patron's account. Handles group creation/joining. >+Returns the patron's AccountLink object. >+ >+Throws: >+ Koha::Exceptions::PatronAccountLink::AlreadyLinked >+ Koha::Exceptions::PatronAccountLink::DifferentGroups >+ >+=cut >+ >+sub link_to_patron { >+ my ( $self, $other_patron ) = @_; >+ >+ my $own_link = $self->account_link; >+ my $other_link = $other_patron->account_link; >+ >+ # Both already linked to same group >+ if ( $own_link && $other_link && $own_link->link_group_id == $other_link->link_group_id ) { >+ Koha::Exceptions::PatronAccountLink::AlreadyLinked->throw(); >+ } >+ >+ # Both belong to different groups >+ if ( $own_link && $other_link ) { >+ Koha::Exceptions::PatronAccountLink::DifferentGroups->throw(); >+ } >+ >+ # Determine group ID >+ my $link_group_id; >+ if ($own_link) { >+ $link_group_id = $own_link->link_group_id; >+ } elsif ($other_link) { >+ $link_group_id = $other_link->link_group_id; >+ } else { >+ $link_group_id = Koha::Patron::AccountLinks->get_next_group_id(); >+ } >+ >+ # Create missing links >+ unless ($own_link) { >+ Koha::Patron::AccountLink->new( { link_group_id => $link_group_id, borrowernumber => $self->borrowernumber } ) >+ ->store; >+ } >+ >+ unless ($other_link) { >+ Koha::Patron::AccountLink->new( >+ { link_group_id => $link_group_id, borrowernumber => $other_patron->borrowernumber } )->store; >+ } >+ >+ return $self->account_link; >+} >+ > =head3 housebound_profile > > Returns the HouseboundProfile associated with this patron. >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39658
:
193344
|
193345
|
193346
|
193347
|
193348
|
193349
|
193350
|
193351
|
193352
|
193353
|
193354
|
193355
|
193356
|
193357
|
193358
|
193359
|
193462
|
193463
|
193464
|
193465
|
193466
|
193467
|
193468
|
193469
|
193470
|
193471
|
193472
|
193473
|
193474
|
193475
|
193476
|
193477
|
193478
|
193479
|
193781
|
193782
|
193783
|
193784
|
193785
|
193786
|
193787
|
193788
|
193789
|
193790
|
193791
|
193792
|
193793
|
193794
|
193795
|
193796
|
193797
|
193798
|
193800
|
193801
|
193802
|
193803
|
193804
|
193805
|
193806
|
193807
|
193808
|
193809
|
193810
|
193811
|
193812
|
193813
|
193814
|
193815
|
193816
|
193817