From 894c6dd0fe3ffffadd23f2b04b3db0130ff161ea Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 13 Oct 2022 06:19:27 +0000 Subject: [PATCH] Bug 31743: Change condition for messaging tab Note for QA: The code for SMSnumber is still made dependent on EnhancedMessagingPreferencesOPAC in order to not disturb current behavior. This fixes Enhanced on, EnhancedOPAC off; the case of Enhanced off is not considered here. Test plan: Enable EnhancedMessaging, disable EnhancedMessagingOPAC. Enable TranslateNotices. Check if you can only change notice language on OPAC. Enable EnhancedMessagingOPAC. Check if you change messaging prefs too. Signed-off-by: Marcel de Rooy Signed-off-by: marie-luce Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../bootstrap/en/includes/usermenu.inc | 2 +- .../bootstrap/en/modules/opac-messaging.tt | 8 ++-- opac/opac-messaging.pl | 40 +++++++++++-------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index f81b58ffe4..c8bd1669ab 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -102,7 +102,7 @@ [% END %] [% IF ( EnhancedMessagingPreferences ) %] - [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' ) %] + [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' ) || Koha.Preference('TranslateNotices') %] [% IF ( messagingview ) %]
  • [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index 44e6ca4dfc..97e57a0ce3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -34,7 +34,7 @@
    - [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' ) %] + [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' ) || Koha.Preference('TranslateNotices') %]

    Your messaging settings

    [% IF ( settings_updated ) %] @@ -44,6 +44,7 @@ + [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' ) %] @@ -173,8 +174,9 @@ [% END # / FOREACH messaging_preferences%] - -
    Your messaging settings
    + + + [% END %] [% IF ( SMSSendDriver || Koha.Preference('TranslateNotices') ) %]
    diff --git a/opac/opac-messaging.pl b/opac/opac-messaging.pl index a221b39a83..3fef7eb862 100755 --- a/opac/opac-messaging.pl +++ b/opac/opac-messaging.pl @@ -31,8 +31,9 @@ use Koha::SMS::Providers; use Koha::Token; my $query = CGI->new(); +my $opac_messaging = C4::Context->preference('EnhancedMessagingPreferencesOPAC'); -unless ( C4::Context->preference('EnhancedMessagingPreferencesOPAC') and +unless ( ( $opac_messaging or C4::Context->preference('TranslateNotices') ) and C4::Context->preference('EnhancedMessagingPreferences') ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); exit; @@ -48,7 +49,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $patron = Koha::Patrons->find( $borrowernumber ); # FIXME and if borrowernumber is invalid? -my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); +my $messaging_options; +$messaging_options = C4::Members::Messaging::GetMessagingOptions() if $opac_messaging; if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) { die "Wrong CSRF token" unless Koha::Token->new->check_csrf({ @@ -56,33 +58,37 @@ if ( defined $query->param('modify') && $query->param('modify') eq 'yes' ) { token => scalar $query->param('csrf_token'), }); - my $sms = $query->param('SMSnumber'); - my $sms_provider_id = $query->param('sms_provider_id'); - $patron->set({ - smsalertnumber => $sms, - sms_provider_id => $sms_provider_id, - })->store; + if( $opac_messaging ) { + my $sms = $query->param('SMSnumber'); + my $sms_provider_id = $query->param('sms_provider_id'); + $patron->set({ + smsalertnumber => $sms, + sms_provider_id => $sms_provider_id, + })->store; - C4::Form::MessagingPreferences::handle_form_action($query, { borrowernumber => $patron->borrowernumber }, $template); + C4::Form::MessagingPreferences::handle_form_action($query, { borrowernumber => $patron->borrowernumber }, $template); + } if ( C4::Context->preference('TranslateNotices') ) { $patron->set({ lang => scalar $query->param('lang') })->store; } } -C4::Form::MessagingPreferences::set_form_values({ borrowernumber => $patron->borrowernumber }, $template); +C4::Form::MessagingPreferences::set_form_values({ borrowernumber => $patron->borrowernumber }, $template) if $opac_messaging; $template->param( - messagingview => 1, - SMSnumber => $patron->smsalertnumber, # FIXME This is already sent 2 lines above - SMSSendDriver => C4::Context->preference("SMSSendDriver"), - TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification") ); + messagingview => 1, + SMSnumber => $patron->smsalertnumber, # FIXME This is already sent 2 lines above + SMSSendDriver => C4::Context->preference("SMSSendDriver"), + TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"), +); -if ( C4::Context->preference("SMSSendDriver") eq 'Email' ) { +if( $opac_messaging && C4::Context->preference("SMSSendDriver") eq 'Email' ) { my @providers = Koha::SMS::Providers->search( {}, { order_by => 'name' } )->as_list; $template->param( - sms_providers => \@providers, - sms_provider_id => $patron->sms_provider_id ); + sms_providers => \@providers, + sms_provider_id => $patron->sms_provider_id, + ); } my $new_session_id = $query->cookie('CGISESSID'); -- 2.39.5