From f7ed4dde6b7bd46d53d9b6b78f028f6424a75101 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 11 Jul 2022 19:58:46 +0000 Subject: [PATCH] Bug 20439: Sort SMS providers in alphabetical order To test: 1/ Add 'Email' to the 'SMSSendDriver' system preference. 2/ Make sure 'EnhancedMessagingPreferencesOPAC' and 'EnhancedMessagingPreferences' are turned on. 3/ Add some SMS providers (/cgi-bin/koha/admin/sms_providers.pl) with different names. 4/ Notice on memberentry.pl and opac-messaging.pl the SMS providers sort by when they were added, not alphabetically. 5/ Apply patch and restart services. 6/ Look at memberentry.pl and opac-messaging.pl and notice that they SMS providers now sort alphabetically. --- members/memberentry.pl | 3 ++- opac/opac-messaging.pl | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index d406817ecd..5b4a7ba131 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -69,7 +69,8 @@ if ( $borrowernumber and not $patron ) { if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { my @providers = Koha::SMS::Providers->search->as_list; - $template->param( sms_providers => \@providers ); + my @sorted_providers = sort { $a->name cmp $b->name } @providers; + $template->param( sms_providers => \@sorted_providers ); } my $actionType = $input->param('actionType') || ''; diff --git a/opac/opac-messaging.pl b/opac/opac-messaging.pl index 01faeb3cf4..cea8ea0642 100755 --- a/opac/opac-messaging.pl +++ b/opac/opac-messaging.pl @@ -79,8 +79,9 @@ $template->param( TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification") ); if ( C4::Context->preference("SMSSendDriver") eq 'Email' ) { - my $providers = Koha::SMS::Providers->search; - $template->param( sms_providers => $providers, sms_provider_id => $patron->sms_provider_id ); + my @providers = Koha::SMS::Providers->search->as_list; + my @sorted_providers = sort { $a->name cmp $b->name } @providers; + $template->param( sms_providers => \@sorted_providers, sms_provider_id => $patron->sms_provider_id ); } my $new_session_id = $query->cookie('CGISESSID'); -- 2.30.2