From a1200e64981322e05ace740421182846098b2711 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 20 May 2009 11:35:53 -0500 Subject: [PATCH] bug 3222: messaging preferences for patron categories Add the ability to set the default circulation messages preferences for a patron category. When the EnhancedMessagingPreferences syspref is ON, the administrator will be able to define default patron messaging preferences for a patron category. When a new patron record is created (either manually or via a patron import), the new patron's preferences will be copied from the default for that patron's category. Signed-off-by: Daniel Sweeney Signed-off-by: Galen Charlton --- admin/categorie.pl | 32 +++++++++++++++++++ .../prog/en/modules/admin/categorie.tmpl | 24 ++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/admin/categorie.pl b/admin/categorie.pl index 70de77393b..bc5f725b60 100755 --- a/admin/categorie.pl +++ b/admin/categorie.pl @@ -41,6 +41,7 @@ use CGI; use C4::Context; use C4::Auth; use C4::Output; +use C4::Form::MessagingPreferences; sub StringSearch { my ($searchstring,$type)=@_; @@ -106,6 +107,9 @@ if ($op eq 'add_form') { category_type => $data->{'category_type'}, "type_".$data->{'category_type'} => 1, ); + if (C4::Context->preference('EnhancedMessagingPreferences')) { + C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); + } # END $OP eq ADD_FORM ################## ADD_VALIDATE ################################## # called by add_form, used to insert/modify data in DB @@ -122,6 +126,10 @@ if ($op eq 'add_form') { $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','overduenoticerequired','category_type')); $sth->finish; } + if (C4::Context->preference('EnhancedMessagingPreferences')) { + C4::Form::MessagingPreferences::handle_form_action($input, + { categorycode => $input->param('categorycode') }, $template); + } print "Content-Type: text/html\n\n"; exit; @@ -188,6 +196,10 @@ if ($op eq 'add_form') { category_type => $results->[$i]{'category_type'}, "type_".$results->[$i]{'category_type'} => 1, toggle => $toggle ); + if (C4::Context->preference('EnhancedMessagingPreferences')) { + my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); + $row{messaging_prefs} = $brief_prefs if @$brief_prefs; + } push @loop, \%row; if ( $toggle eq 0 ) { @@ -215,3 +227,23 @@ if ($op eq 'add_form') { } #---- END $OP eq DEFAULT output_html_with_http_headers $input, $cookie, $template->output; +exit 0; + +sub _get_brief_messaging_prefs { + my $categorycode = shift; + my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); + my $results = []; + PREF: foreach my $option ( @$messaging_options ) { + my $pref = C4::Members::Messaging::GetMessagingPreferences( { categorycode => $categorycode, + message_name => $option->{'message_name'} } ); + next unless @{$pref->{'transports'}}; + my $brief_pref = { message_attribute_id => $option->{'message_attribute_id'}, + message_name => $option->{'message_name'}, + }; + foreach my $transport ( @{$pref->{'transports'}} ) { + push @{ $brief_pref->{'transports'} }, { transport => $transport }; + } + push @$results, $brief_pref; + } + return $results; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tmpl index 81b8962753..d8b76ebdd6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tmpl @@ -133,6 +133,12 @@ + +
+

Default messaging preferences for this patron category

+ +
+
@@ -221,6 +227,9 @@ Confirm Deletion of Category Enrollment fee Overdue Hold fee + + Messaging +   @@ -243,6 +252,21 @@ Confirm Deletion of Category YesNo + + + + + : + + + + +
+ + none + + + ?op=add_form&categorycode=">Edit ?op=delete_confirm&categorycode=">Delete -- 2.39.5