Bugzilla – Attachment 189066 Details for
Bug 34069
Add ability to restore a recently deleted borrower from deletedborrowers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34069: Deal with view_borrower_infos_from_any_libraries
Bug-34069-Deal-with-viewborrowerinfosfromanylibrar.patch (text/plain), 5.20 KB, created by
Lucas Gass (lukeg)
on 2025-11-04 21:46:05 UTC
(
hide
)
Description:
Bug 34069: Deal with view_borrower_infos_from_any_libraries
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-11-04 21:46:05 UTC
Size:
5.20 KB
patch
obsolete
>From 4cde491eee923965d41c4196b3387e6ce79531ea Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 4 Nov 2025 21:45:08 +0000 >Subject: [PATCH] Bug 34069: Deal with view_borrower_infos_from_any_libraries > >--- > Koha/Old/Patron.pm | 8 ++++++ > .../tools/restore_deleted_borrowers.tt | 27 ++++++++++++++++-- > tools/restore_deleted_borrowers.pl | 28 +++++++++++++++++-- > 3 files changed, 59 insertions(+), 4 deletions(-) > >diff --git a/Koha/Old/Patron.pm b/Koha/Old/Patron.pm >index 62264ed3fac..a395a0ef839 100644 >--- a/Koha/Old/Patron.pm >+++ b/Koha/Old/Patron.pm >@@ -84,6 +84,14 @@ sub restore_deleted_borrower { > # Retrive all the data about this patron from deleteborrowers table > my $patron_data = $self->unblessed; > >+ # some fields must be cleared >+ # borrower_debarments table is cleared on delete, we must also removed the debarment from the patron record >+ $patron_data->{debarred} = undef; >+ $patron_data->{debarredcomment} = undef; >+ >+ #dont restore borrowers with flags, those will have to be re-added >+ $patron_data->{flags} = undef; >+ > # Create the Koha::Patron object > my $patron = Koha::Patron->new($patron_data); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore_deleted_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore_deleted_borrowers.tt >index d5770e0845e..499adaf3fb0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore_deleted_borrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore_deleted_borrowers.tt >@@ -77,8 +77,12 @@ > <li> > <label for="branchcode">Library:</label> > <select name="branchcode" id="branchcode"> >- <option value="">All libraries</option> >- [% PROCESS options_for_libraries libraries => Branches.all() %] >+ [% IF can_view_all_libraries %] >+ <option value="">All libraries</option> >+ [% END %] >+ [% FOREACH lib IN allowed_libraries %] >+ <option value="[% lib.branchcode | html %]" [% IF branchcode == lib.branchcode %]selected="selected"[% END %]> [% lib.branchname | html %] </option> >+ [% END %] > </select> > </li> > <li> >@@ -243,6 +247,25 @@ > }); > [% END %] > >+ $("#restore_form").on("submit", function(e) { >+ var checked = $("#deleted_patrons_table tbody input[type='checkbox']:checked").length; >+ >+ if (checked === 0) { >+ e.preventDefault(); >+ alert(_("Please select at least one patron to restore.")); >+ return false; >+ } >+ >+ var message = __("Are you sure you want to restore %s patron(s)?").format(checked); >+ >+ if (!confirm(message)) { >+ e.preventDefault(); >+ return false; >+ } >+ >+ return true; >+ }); >+ > }); > </script> > [% END %] >diff --git a/tools/restore_deleted_borrowers.pl b/tools/restore_deleted_borrowers.pl >index 02f93e3ef6a..81ed20d34a7 100755 >--- a/tools/restore_deleted_borrowers.pl >+++ b/tools/restore_deleted_borrowers.pl >@@ -23,7 +23,7 @@ use CGI qw ( -utf8 ); > use Try::Tiny; > use Scalar::Util qw( blessed ); > >-use C4::Auth qw( get_template_and_user ); >+use C4::Auth qw( get_template_and_user haspermission ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Context; > >@@ -39,10 +39,34 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > template_name => "tools/restore_deleted_borrowers.tt", > query => $input, > type => "intranet", >- flagsrequired => { tools => 'restore_deleted_patrons' }, >+ flagsrequired => { borrowers => 'restore_deleted_borrowers' }, > } > ); > >+#check if the user can view patrons from any branch, or just thier own >+my $logged_in_patron = Koha::Patrons->find($loggedinuser); >+my $can_view_all_libraries = >+ haspermission( $logged_in_patron->userid, { borrowers => 'view_borrower_infos_from_any_libraries' } ); >+ >+my @libraries; >+if ($can_view_all_libraries) { >+ >+ # User can view all branches, get them all >+ @libraries = Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list; >+} else { >+ >+ # User can only view their branch or branches in the group, get only those >+ @libraries = Koha::Libraries->search_filtered( >+ { only_from_group => 1 }, >+ { order_by => ['branchname'] } >+ )->as_list; >+} >+ >+$template->param( >+ allowed_libraries => \@libraries, >+ can_view_all_libraries => $can_view_all_libraries, >+); >+ > if ( $op eq 'search' ) { > > # Get search parameters >-- >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 34069
:
188299
|
188302
|
188988
|
188989
|
188990
|
189027
|
189028
|
189029
|
189030
|
189037
|
189066
|
189067
|
189370
|
189371
|
189372
|
189373
|
189374
|
189375
|
189376
|
189377
|
189642
|
189645
|
189718
|
189773
|
189774
|
189779
|
189780
|
189781
|
189782
|
189783
|
189784
|
189785
|
189786
|
189787
|
189788
|
189789
|
189790
|
189791
|
189792
|
189793
|
189794
|
189795
|
189940
|
189941
|
189942
|
189943
|
189944
|
189945
|
189946
|
189947
|
189948
|
189949
|
189950
|
189951
|
189952
|
189953
|
189954