Bugzilla – Attachment 190851 Details for
Bug 41513
Add a system preference to control which staff main page notifications appear
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41513: Adjust mainpage.pl
Bug-41513-Adjust-mainpagepl.patch (text/plain), 12.07 KB, created by
Lucas Gass (lukeg)
on 2026-01-02 20:26:03 UTC
(
hide
)
Description:
Bug 41513: Adjust mainpage.pl
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2026-01-02 20:26:03 UTC
Size:
12.07 KB
patch
obsolete
>From 04e17a41aa3e76fd83843161f52f66f11b3e7704 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Fri, 2 Jan 2026 20:21:11 +0000 >Subject: [PATCH] Bug 41513: Adjust mainpage.pl > >To test: >1. APPLY PATCH, updatedatabase, restart_all >2. Find the new system preference 'StaffMainPageNotifications' >3. All options should be checked except 'Holds to pull' and 'Holds queue'. Since these options are new I would like them to be unchecked while all other options will show, preserving current behavior. >4. You should see these options for main page notifications: > >ArticleRequests >Suggestions >Comments >Tags >PatronModifications >DischargeRequests >BiblioTickets >CheckoutNotes >ProblemReports >HoldsToPull >HoldsQueue >Jobs >CurbsidePickups >HoldCancellations >SelfRegistrations > >5. Make some notifications in each of these areas and making sure toggling the option in StaffMainPageNotifications works. >--- > mainpage.pl | 216 +++++++++++++++++++++++++++++++--------------------- > 1 file changed, 130 insertions(+), 86 deletions(-) > >diff --git a/mainpage.pl b/mainpage.pl >index 1e88c2c5b00..6df2a82991f 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -80,122 +80,166 @@ my $branch = > ? C4::Context->userenv()->{'branch'} > : undef; > >-my $pendingcomments = Koha::Reviews->search_limited( { approved => 0 } )->count; >-my $pendingtags = get_count_by_tag_status(0); >- >-# Get current branch count and total viewable count, if they don't match then pass >-# both to template >- >-if ( C4::Context->only_my_library ) { >- my $local_pendingsuggestions_count = Koha::Suggestions->search( >- { status => "ASKED", branchcode => C4::Context->userenv()->{'branch'}, archived => 0 } )->count(); >- $template->param( pendingsuggestions => $local_pendingsuggestions_count ); >-} else { >- my $pendingsuggestions = Koha::Suggestions->search( { status => "ASKED", archived => 0 } ); >- my $local_pendingsuggestions_count = >- $pendingsuggestions->search( { 'me.branchcode' => C4::Context->userenv()->{'branch'} } )->count(); >- my $pendingsuggestions_count = $pendingsuggestions->count(); >+my @staff_mainpage_notifications = split /,/, C4::Context->preference('StaffMainPageNotifications'); >+my %enabled_notifications = map { $_ => 1 } @staff_mainpage_notifications; >+ >+if ( $enabled_notifications{'Comments'} ) { >+ my $pendingcomments = Koha::Reviews->search_limited( { approved => 0 } )->count; > $template->param( >- all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count >- ? $pendingsuggestions_count >- : 0, >- pendingsuggestions => $local_pendingsuggestions_count >+ pendingcomments => $pendingcomments, > ); > } > >-my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count($branch); >-my $local_pendingmodifications_count = Koha::Patron::Modifications->pending_count( C4::Context->userenv()->{'branch'} ); >+if ( $enabled_notifications{'Tags'} ) { >+ my $pendingtags = get_count_by_tag_status(0); >+ $template->param( >+ pendingtags => $pendingtags, >+ ); >+} > >-my $pending_discharge_requests = Koha::Patron::Discharge::count( { pending => 1 } ); >-my $pending_article_requests = Koha::ArticleRequests->search_limited( >- { >- status => Koha::ArticleRequest::Status::Requested, >- $branch ? ( 'me.branchcode' => $branch ) : (), >+if ( $enabled_notifications{'Suggestions'} ) { >+ if ( C4::Context->only_my_library ) { >+ my $local_pendingsuggestions_count = Koha::Suggestions->search( >+ { status => "ASKED", branchcode => C4::Context->userenv()->{'branch'}, archived => 0 } )->count(); >+ $template->param( pendingsuggestions => $local_pendingsuggestions_count ); >+ } else { >+ my $pendingsuggestions = Koha::Suggestions->search( { status => "ASKED", archived => 0 } ); >+ my $local_pendingsuggestions_count = >+ $pendingsuggestions->search( { 'me.branchcode' => C4::Context->userenv()->{'branch'} } )->count(); >+ my $pendingsuggestions_count = $pendingsuggestions->count(); >+ $template->param( >+ all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count >+ ? $pendingsuggestions_count >+ : 0, >+ pendingsuggestions => $local_pendingsuggestions_count >+ ); > } >-)->count; >-my $pending_problem_reports = Koha::ProblemReports->search( { status => 'New' } ); >+} >+ >+if ( $enabled_notifications{'PatronModifications'} ) { >+ my $pending_borrower_modifications = Koha::Patron::Modifications->pending_count($branch); >+ my $local_pendingmodifications_count = >+ Koha::Patron::Modifications->pending_count( C4::Context->userenv()->{'branch'} ); >+ $template->param( >+ pending_borrower_modifications => $pending_borrower_modifications, >+ pending_local_borrowermods => $local_pendingmodifications_count, >+ ); >+} >+ >+if ( $enabled_notifications{'DischargeRequests'} ) { >+ my $pending_discharge_requests = Koha::Patron::Discharge::count( { pending => 1 } ); >+ $template->param( >+ pending_discharge_requests => $pending_discharge_requests, >+ ); >+} > >-if ( C4::Context->preference('OpacCatalogConcerns') || C4::Context->preference('CatalogConcerns') ) { >- my $pending_biblio_tickets = Koha::Tickets->search( >+if ( $enabled_notifications{'ArticleRequests'} ) { >+ my $pending_article_requests = Koha::ArticleRequests->search_limited( > { >- resolved_date => undef, >- biblio_id => { '!=' => undef } >+ status => Koha::ArticleRequest::Status::Requested, >+ $branch ? ( 'me.branchcode' => $branch ) : (), > } >+ )->count; >+ $template->param( >+ pending_article_requests => $pending_article_requests, > ); >- $template->param( pending_biblio_tickets => $pending_biblio_tickets->count ); > } > >-unless ( $logged_in_user->has_permission( { parameters => 'manage_background_jobs' } ) ) { >- my $already_ran_jobs = >- Koha::BackgroundJobs->search( { borrowernumber => $logged_in_user->borrowernumber } )->count ? 1 : 0; >- $template->param( already_ran_jobs => $already_ran_jobs ); >+if ( $enabled_notifications{'ProblemReports'} ) { >+ my $pending_problem_reports = Koha::ProblemReports->search( { status => 'New' } ); >+ $template->param( >+ pending_problem_reports => $pending_problem_reports, >+ ); > } > >-$template->param( >- holds_with_cancellation_requests => Koha::Holds->waiting->filter_by_has_cancellation_requests->count ); >- >-my $holds_to_pull_start_date = C4::Context->preference('HoldsToPullStartDate') || 2; >-my $reserves_to_pull_from = dt_from_string()->subtract( days => $holds_to_pull_start_date ); >+if ( $enabled_notifications{'BiblioTickets'} ) { >+ if ( C4::Context->preference('OpacCatalogConcerns') || C4::Context->preference('CatalogConcerns') ) { >+ my $pending_biblio_tickets = Koha::Tickets->search( >+ { >+ resolved_date => undef, >+ biblio_id => { '!=' => undef } >+ } >+ ); >+ $template->param( pending_biblio_tickets => $pending_biblio_tickets->count ); >+ } >+} > >-my $holds_to_pull = Koha::Holds->search( >- { >- found => undef, >- reservedate => { '>=' => $reserves_to_pull_from->ymd() } >+if ( $enabled_notifications{'Jobs'} ) { >+ unless ( $logged_in_user->has_permission( { parameters => 'manage_background_jobs' } ) ) { >+ my $already_ran_jobs = >+ Koha::BackgroundJobs->search( { borrowernumber => $logged_in_user->borrowernumber } )->count ? 1 : 0; >+ $template->param( already_ran_jobs => $already_ran_jobs ); > } >-)->count; >+} > >-#get local holds to pull by looking for holds with an item homebranch that matches the loggedinuser's location >-my $local_holds_to_pull = Koha::Holds->search( >- { >- 'me.found' => undef, >- 'item.homebranch' => C4::Context->userenv()->{'branch'}, >- 'me.reservedate' => { '>=' => $reserves_to_pull_from->ymd() } >- }, >- { join => 'item' } >-)->count; >+if ( $enabled_notifications{'HoldCancellations'} ) { >+ $template->param( >+ holds_with_cancellation_requests => Koha::Holds->waiting->filter_by_has_cancellation_requests->count ); >+} > >-my $holds_queue_count = Koha::Hold::HoldsQueueItems->search()->count; >+if ( $enabled_notifications{'HoldsToPull'} ) { >+ my $holds_to_pull_start_date = C4::Context->preference('HoldsToPullStartDate') || 2; >+ my $reserves_to_pull_from = dt_from_string()->subtract( days => $holds_to_pull_start_date ); > >-my $local_holds_queue_count = >- Koha::Hold::HoldsQueueItems->search( { 'me.holdingbranch' => C4::Context->userenv()->{'branch'} } )->count; >+ my $holds_to_pull = Koha::Holds->search( >+ { >+ found => undef, >+ reservedate => { '>=' => $reserves_to_pull_from->ymd() } >+ } >+ )->count; > >-$template->param( >- holds_queue_count => $holds_queue_count, >- local_holds_queue_count => $local_holds_queue_count, >-); >+ #get local holds to pull by looking for holds with an item homebranch that matches the loggedinuser's location >+ my $local_holds_to_pull = Koha::Holds->search( >+ { >+ 'me.found' => undef, >+ 'item.homebranch' => C4::Context->userenv()->{'branch'}, >+ 'me.reservedate' => { '>=' => $reserves_to_pull_from->ymd() } >+ }, >+ { join => 'item' } >+ )->count; > >-if ( C4::Context->preference('CurbsidePickup') ) { > $template->param( >- new_curbside_pickups => Koha::CurbsidePickups->search( >- { >- branchcode => $homebranch, >- } >- )->filter_by_to_be_staged->filter_by_scheduled_today, >+ holds_to_pull => $holds_to_pull, >+ local_holds_to_pull => $local_holds_to_pull, > ); > } > >-if ( C4::Context->preference('PatronSelfRegistrationAlert') ) { >- my $categorycode = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >- my $branchcode = C4::Context::mybranch(); >+if ( $enabled_notifications{'HoldsQueue'} ) { >+ my $holds_queue_count = Koha::Hold::HoldsQueueItems->search()->count; > >- my $rs = Koha::Patrons->search( { categorycode => $categorycode } ); >+ my $local_holds_queue_count = >+ Koha::Hold::HoldsQueueItems->search( { 'me.holdingbranch' => C4::Context->userenv()->{'branch'} } )->count; > > $template->param( >- self_registered_count => $rs->count, >- self_registered_mybranch_count => $rs->search( { branchcode => $branchcode } )->count, >+ holds_queue_count => $holds_queue_count, >+ local_holds_queue_count => $local_holds_queue_count, > ); > } > >-$template->param( >- pendingcomments => $pendingcomments, >- pendingtags => $pendingtags, >- pending_borrower_modifications => $pending_borrower_modifications, >- pending_local_borrowermods => $local_pendingmodifications_count, >- pending_discharge_requests => $pending_discharge_requests, >- pending_article_requests => $pending_article_requests, >- pending_problem_reports => $pending_problem_reports, >- holds_to_pull => $holds_to_pull, >- local_holds_to_pull => $local_holds_to_pull, >-); >+if ( $enabled_notifications{'CurbsidePickups'} ) { >+ if ( C4::Context->preference('CurbsidePickup') ) { >+ $template->param( >+ new_curbside_pickups => Koha::CurbsidePickups->search( >+ { >+ branchcode => $homebranch, >+ } >+ )->filter_by_to_be_staged->filter_by_scheduled_today, >+ ); >+ } >+} >+ >+if ( $enabled_notifications{'SelfRegistrations'} ) { >+ if ( C4::Context->preference('PatronSelfRegistrationAlert') ) { >+ my $categorycode = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >+ my $branchcode = C4::Context::mybranch(); >+ >+ my $rs = Koha::Patrons->search( { categorycode => $categorycode } ); >+ >+ $template->param( >+ self_registered_count => $rs->count, >+ self_registered_mybranch_count => $rs->search( { branchcode => $branchcode } )->count, >+ ); >+ } >+} > > output_html_with_http_headers $query, $cookie, $template->output; >-- >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 41513
:
190850
| 190851