Lines 54-60
the same thing in staff and OPAC.
Link Here
|
54 |
|
54 |
|
55 |
=head2 handle_form_action |
55 |
=head2 handle_form_action |
56 |
|
56 |
|
57 |
C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template); |
57 |
C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template, $insert); |
58 |
|
58 |
|
59 |
Processes CGI parameters and updates the target patron or patron category's |
59 |
Processes CGI parameters and updates the target patron or patron category's |
60 |
preferences. |
60 |
preferences. |
Lines 64-80
C<$input> is the CGI query object.
Link Here
|
64 |
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key |
64 |
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key |
65 |
identifying the patron or patron category whose messaging preferences are to be updated. |
65 |
identifying the patron or patron category whose messaging preferences are to be updated. |
66 |
|
66 |
|
67 |
C<$template> is the HTML::Template::Pro object for the response; this routine |
67 |
C<$template> is the Template::Toolkit object for the response; this routine |
68 |
adds a settings_updated template variable. |
68 |
adds a settings_updated template variable. |
69 |
|
69 |
|
70 |
=cut |
70 |
=cut |
71 |
|
71 |
|
72 |
sub handle_form_action { |
72 |
sub handle_form_action { |
73 |
my ($query, $target_params, $template) = @_; |
73 |
my ($query, $target_params, $template, $insert, $categorycode) = @_; |
74 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
74 |
my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); |
75 |
|
|
|
76 |
# TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box |
75 |
# TODO: If a "NONE" box and another are checked somehow (javascript failed), we should pay attention to the "NONE" box |
77 |
|
76 |
my $prefs_set = 0; |
78 |
OPTION: foreach my $option ( @$messaging_options ) { |
77 |
OPTION: foreach my $option ( @$messaging_options ) { |
79 |
my $updater = { %{ $target_params }, |
78 |
my $updater = { %{ $target_params }, |
80 |
message_attribute_id => $option->{'message_attribute_id'} }; |
79 |
message_attribute_id => $option->{'message_attribute_id'} }; |
Lines 96-103
sub handle_form_action {
Link Here
|
96 |
} |
95 |
} |
97 |
|
96 |
|
98 |
C4::Members::Messaging::SetMessagingPreference( $updater ); |
97 |
C4::Members::Messaging::SetMessagingPreference( $updater ); |
99 |
} |
|
|
100 |
|
98 |
|
|
|
99 |
if ($query->param( $option->{'message_attribute_id'})){ |
100 |
$prefs_set = 1; |
101 |
} |
102 |
} |
103 |
if (! $prefs_set && $insert){ |
104 |
# this is new borrower, and we have no preferences set, use the defaults |
105 |
$target_params->{categorycode} = $categorycode; |
106 |
C4::Members::Messaging::SetMessagingPreferencesFromDefaults( $target_params ); |
107 |
} |
101 |
# show the success message |
108 |
# show the success message |
102 |
$template->param( settings_updated => 1 ); |
109 |
$template->param( settings_updated => 1 ); |
103 |
} |
110 |
} |
Lines 112-118
and fills the corresponding template variables.
Link Here
|
112 |
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key |
119 |
C<$target_params> is a hashref containing either a C<categorycode> key or a C<borrowernumber> key |
113 |
identifying the patron or patron category. |
120 |
identifying the patron or patron category. |
114 |
|
121 |
|
115 |
C<$template> is the HTML::Template::Pro object for the response. |
122 |
C<$template> is the Template::Toolkit object for the response. |
116 |
|
123 |
|
117 |
=cut |
124 |
=cut |
118 |
|
125 |
|