From f04e49f5256978606e9a34c9f3802150f7f455ec Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Fri, 26 Jul 2024 16:42:12 +0000 Subject: [PATCH] Bug 29194: Create logical ordering of patron messaging preferences This patch introduces a default ordering for patron messaging preferences. The prefs are then sorted by this ordering before being displayed. To test: 1) Visit a patrons detail page. 2) Note the message prefs aren't ordered (or rather sorted by 'message_attribute_id') 3) Apply patch, restart_all 4) Ensure they are now sorted in teh following fashion: 'Hold_Filled' => 1, 'Hold_Reminder' => 2, 'Recall_Requested' => 3, 'Recall_Waiting' => 4, 'Ill_ready' => 5, 'Ill_unavailable' => 6, 'Ill_update' => 7, 'Item_Checkout' => 8, 'Auto_Renewals' => 9, 'Advance_Notice' => 10, 'Item_Due' => 11, 'Item_Check_in' => 12 Signed-off-by: Roman Dolny Signed-off-by: Marcel de Rooy Please note discussion on BZ about the preferred order ;) Signed-off-by: Katrin Fischer --- C4/Members/Messaging.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/C4/Members/Messaging.pm b/C4/Members/Messaging.pm index 25e6a04a0f..e3b93f614b 100644 --- a/C4/Members/Messaging.pm +++ b/C4/Members/Messaging.pm @@ -215,7 +215,25 @@ END_SQL my @return = values %$choices; - @return = sort { $a->{message_attribute_id} <=> $b->{message_attribute_id} } @return; + # Define messaging sort order based on logical grouping of events + my %messaging_order = ( + 'Hold_Filled' => 1, + 'Hold_Reminder' => 2, + 'Recall_Requested' => 3, + 'Recall_Waiting' => 4, + 'Ill_ready' => 5, + 'Ill_unavailable' => 6, + 'Ill_update' => 7, + 'Item_Checkout' => 8, + 'Auto_Renewals' => 9, + 'Advance_Notice' => 10, + 'Item_Due' => 11, + 'Item_Check_in' => 12 + ); + + @return = + sort { ( $messaging_order{ $a->{message_name} } // 999 ) <=> ( $messaging_order{ $b->{message_name} } // 999 ) } + @return; # warn( Data::Dumper->Dump( [ \@return ], [ 'return' ] ) ); return \@return; -- 2.39.5