Bugzilla – Attachment 4322 Details for
Bug 5918
When AddPatronLists is set to "general" and EnhancedMessagingPreferences is set, messaging prefs not copied from defaults
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5918 : Use the default messaging preferences if the user does not select any
Bug-5918--Use-the-default-messaging-preferences-if.patch (text/plain), 5.94 KB, created by
Chris Cormack
on 2011-05-31 22:34:49 UTC
(
hide
)
Description:
Bug 5918 : Use the default messaging preferences if the user does not select any
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-05-31 22:34:49 UTC
Size:
5.94 KB
patch
obsolete
>From 069d7f9414fd1dfae5a47933b414700831ed3b94 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Wed, 1 Jun 2011 10:34:02 +1200 >Subject: [PATCH] Bug 5918 : Use the default messaging preferences if the user does not select any > >--- > C4/Form/MessagingPreferences.pm | 21 +++++++++++++------ > .../prog/en/modules/members/memberentrygen.tt | 3 ++ > members/memberentry.pl | 11 ++++++--- > 3 files changed, 24 insertions(+), 11 deletions(-) > >diff --git a/C4/Form/MessagingPreferences.pm b/C4/Form/MessagingPreferences.pm >index 808719f..1199c77 100644 >--- a/C4/Form/MessagingPreferences.pm >+++ b/C4/Form/MessagingPreferences.pm >@@ -54,7 +54,7 @@ the same thing in staff and OPAC. > > =head2 handle_form_action > >- C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template); >+ C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template, $insert); > > Processes CGI parameters and updates the target patron or patron category's > preferences. >@@ -64,17 +64,16 @@ C<$input> is the CGI query object. > C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key > identifying the patron or patron category whose messaging preferences are to be updated. > >-C<$template> is the HTML::Template::Pro object for the response; this routine >+C<$template> is the Template::Toolkit object for the response; this routine > adds a settings_updated template variable. > > =cut > > sub handle_form_action { >- my ($query, $target_params, $template) = @_; >+ my ($query, $target_params, $template, $insert, $categorycode) = @_; > my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); >- > # TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box >- >+ my $prefs_set = 0; > OPTION: foreach my $option ( @$messaging_options ) { > my $updater = { %{ $target_params }, > message_attribute_id => $option->{'message_attribute_id'} }; >@@ -96,8 +95,16 @@ sub handle_form_action { > } > > C4::Members::Messaging::SetMessagingPreference( $updater ); >- } > >+ if ($query->param( $option->{'message_attribute_id'})){ >+ $prefs_set = 1; >+ } >+ } >+ if (! $prefs_set && $insert){ >+ # this is new borrower, and we have no preferences set, use the defaults >+ $target_params->{categorycode} = $categorycode; >+ C4::Members::Messaging::SetMessagingPreferencesFromDefaults( $target_params ); >+ } > # show the success message > $template->param( settings_updated => 1 ); > } >@@ -112,7 +119,7 @@ and fills the corresponding template variables. > C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key > identifying the patron or patron category. > >-C<$template> is the HTML::Template::Pro object for the response. >+C<$template> is the Template::Toolkit object for the response. > > =cut > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index a4361cd..3c2db31 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -1072,6 +1072,9 @@ > [% END %] > <input type="hidden" name="setting_messaging_prefs" value="1" /> > <legend>Patron messaging preferences</legend> >+ [% IF type_only %] >+ <i>If no preferences are selected, the default preferences for the category chosen will be applied on save, otherwise your selection here is saved</i> >+ [% END %] > [% INCLUDE 'messaging-preference-form.inc' %] > [% IF ( SMSSendDriver ) %] > <p><label for="SMSnumber">SMS number:</label> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index a8e764c..12630ef 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -105,14 +105,17 @@ $template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); > $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); > ( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ); > my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; >-my $category_type = $input->param('category_type'); >+my $category_type = $input->param('category_type') || ''; >+if ($category_type){ >+ $template->{VARS}->{'type_only'} = 1; >+} > my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type. > unless ($category_type or !($categorycode)){ > my $borrowercategory = GetBorrowercategory($categorycode); > $category_type = $borrowercategory->{'category_type'}; > my $category_name = $borrowercategory->{'description'}; > $template->param("categoryname"=>$category_name); >-} >+ } > $category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error ! > > # if a add or modify is requested => check validity of data. >@@ -333,8 +336,8 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ > if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { > C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes); > } >- if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) { >- C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template); >+ if (C4::Context->preference('EnhancedMessagingPreferences') and $input->param('setting_messaging_prefs')) { >+ C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template, 1, $newdata{'categorycode'}); > } > } elsif ($op eq 'save'){ > if ($NoUpdateLogin) { >-- >1.7.4.1
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 5918
: 4322 |
4323