Bug 10796: Use $category->effective_change_password in the OPAC
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 20 Feb 2019 16:58:35 +0000 (13:58 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 12 Apr 2019 02:32:07 +0000 (02:32 +0000)
This patch makes the OPAC pages that rely on OpacPasswordChange use the
current patron's category to make the decision to allow password change
or not.

It does so by making sure all the places in which OpacPasswordChange was
used, use $logged_in_user->category->effective_change_password instead.

Special attention is required on the case of opac-registration-verify.pl
in which the use of an unblessed Koha::Patron object is changed in
favour of the blessed object, so we can actually use the new method to
make a decision on the text to display.

To test:
- Go through the OPAC pages, check that the password change strings and
links are displayed only whne appropriate.
- Sign off :-D

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-passwd.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt
opac/opac-memberentry.pl
opac/opac-passwd.pl
opac/opac-registration-verify.pl

index 42f073b..976fc13 100644 (file)
@@ -40,7 +40,7 @@
                 <a href="/cgi-bin/koha/opac-tags.pl?mine=1">your tags</a></li>
             [% END %]
 
-            [% IF ( OpacPasswordChange ) %]
+            [% IF logged_in_user.category.effective_change_password %]
                 [% IF ( passwdview ) %]
                     <li class="active">
                 [% ELSE %]
index 2126742..929e221 100644 (file)
@@ -51,7 +51,7 @@
                         </div>
                     [% END # /IF Error_messages %]
 
-                    [% IF ( OpacPasswordChange ) %]
+                    [% IF logged_in_user.category.effective_change_password %]
                         [% IF ( Ask_data ) %]
 
 
@@ -71,7 +71,7 @@
                         [% END # /IF Ask_data %]
                     [% ELSE %]
                         <div class="alert">You can't change your password.</div>
-                    [% END # /IF OpacPasswordChange %]
+                    [% END # /IF logged_in_user.category.effective_change_password %]
 
                     [% IF ( password_updated ) %]
                         <div class="alert alert-success">
index c788de1..5a62324 100644 (file)
                                 </p>
                             [% END %]
 
-                            <p id="patron-instructions">For your convenience, the login box on this page has been pre-filled with this data. Please log in[% IF OpacPasswordChange %] and change your password[% END %].</p>
+                            <p id="patron-instructions">
+                            [% IF borrower.category.effective_change_password %]
+                                <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in and change your password.</span>
+                            [% ELSE %]
+                                <span>For your convenience, the login box on this page has been pre-filled with this data. Please log in.</span>
+                            [% END %]
+                            </p>
                         [% END %]
 
                         <div id="PatronSelfRegistrationAdditionalInstructions">[% PatronSelfRegistrationAdditionalInstructions | $raw %]</div>
index dbb6d99..7fc9226 100755 (executable)
@@ -205,9 +205,6 @@ if ( $action eq 'create' ) {
                 }
             );
 
-            $template->param( OpacPasswordChange =>
-                  C4::Context->preference('OpacPasswordChange') );
-
             $borrower{categorycode}     ||= C4::Context->preference('PatronSelfRegistrationDefaultCategory');
             $borrower{password}         ||= Koha::AuthUtils::generate_password;
             my $consent_dt = delete $borrower{gdpr_proc_consent};
index 4c72d30..bff0214 100755 (executable)
@@ -44,7 +44,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 );
 
 my $patron = Koha::Patrons->find( $borrowernumber );
-if ( C4::Context->preference("OpacPasswordChange") ) {
+if ( $patron->category->effective_change_password ) {
     if (   $query->param('Oldkey')
         && $query->param('Newkey')
         && $query->param('Confirm') )
index ce78ffa..91e31c0 100755 (executable)
@@ -58,9 +58,6 @@ if (
         }
     );
 
-    $template->param(
-        OpacPasswordChange => C4::Context->preference('OpacPasswordChange') );
-
     my $patron_attrs = $m->unblessed;
     $patron_attrs->{password} ||= Koha::AuthUtils::generate_password;
     my $consent_dt = delete $patron_attrs->{gdpr_proc_consent};
@@ -76,7 +73,7 @@ if (
         C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $patron->borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
 
         $template->param( password_cleartext => $patron->plain_text_password );
-        $template->param( borrower => $patron->unblessed );
+        $template->param( borrower => $patron );
         $template->param(
             PatronSelfRegistrationAdditionalInstructions =>
               C4::Context->preference(