Bugzilla – Attachment 33161 Details for
Bug 13096
Send account notice with login details in more situations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13096: Send account notice when changing password with member-password
Bug-13096-Send-account-notice-when-changing-passwo.patch (text/plain), 10.17 KB, created by
Marcel de Rooy
on 2014-11-03 14:29:41 UTC
(
hide
)
Description:
Bug 13096: Send account notice when changing password with member-password
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-11-03 14:29:41 UTC
Size:
10.17 KB
patch
obsolete
>From 025ff251cafaf0ac3071be72c277ae1f937b297d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 30 Oct 2014 12:27:48 +0100 >Subject: [PATCH] Bug 13096: Send account notice when changing password with > member-password >Content-Type: text/plain; charset=utf-8 > >Send an alert with account details if AutoEmailOpacUser is enabled and the >checkbox was not unchecked. >Added license statement and modern perl line to the code. > >Fixed some other minor issues too: >When changing password, the ajax call used userid instead of borrowernumber. >Current master does not allow you to change userid only. >Test on newpassword in the template was dead. >Removed dead destination parameter. > >Test plan: >Disable AutoEmailOpacUser. >Goto a patron. Click the Change Password button. No checkbox, no mail. >Enable AutoEmailOpacUser. >Click Change Password again. Do you receive a mail when saving? >Uncheck the checkbox: no mail? >Test changing the userid only. >Test saving without any changes. >--- > .../prog/en/modules/members/member-password.tt | 25 ++++--- > members/member-password.pl | 74 ++++++++++++-------- > 2 files changed, 61 insertions(+), 38 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt >index 96544e0..3b5918b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt >@@ -1,5 +1,6 @@ >+[% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Patrons › [% IF ( newpassword ) %]Password updated [% ELSE %]Update password for [% surname %], [% firstname %][% END %]</title> >+<title>Koha › Patrons › Update password for [% surname %], [% firstname %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/JavaScript"> > //<![CDATA[ >@@ -14,7 +15,7 @@ > }); > $("body").on('click', "#fillrandom",function(e) { > e.preventDefault(); >- $.get("/cgi-bin/koha/members/member-password.pl?member=[% userid %]", function(response) { >+ $.get("/cgi-bin/koha/members/member-password.pl?member=[% borrowernumber %]", function(response) { > var defaultnewpass = $(response).find("#defaultnewpassfield").val(); > $("#newpassword").after("<input type=\"text\" name=\"newpassword\" id=\"newpassword\" value=\"" + defaultnewpass + "\">").remove(); > $("#newpassword2").after("<input type=\"text\" name=\"newpassword2\" id=\"newpassword2\" value=\"" + defaultnewpass + "\">").remove(); >@@ -40,7 +41,7 @@ > [% INCLUDE 'header.inc' %] > [% INCLUDE 'patron-search.inc' %] > >-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% firstname %] [% surname %]</a> › [% IF ( newpassword ) %]Password Updated[% ELSE %]Change username and/or password[% END %]</div> >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% firstname %] [% surname %]</a> › Change username and/or password</div> > > <div id="doc3" class="yui-t2"> > >@@ -49,13 +50,9 @@ > <div class="yui-b"> > [% INCLUDE 'members-toolbar.inc' %] > >-[% IF ( newpassword ) %] >-<h1>Password Updated</h1> >- >-[% ELSE %] >- > <form method="post" id="changepasswordf" action="/cgi-bin/koha/members/member-password.pl"> >-<input type="hidden" name="destination" value="[% destination %]" /> >+<input type="hidden" name="op" value="save" /> >+<input type="hidden" name="olduserid" value="[% userid %]" /> > <input type="hidden" name="cardnumber" value="[% cardnumber %]" /> > <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /> > [% IF ( errormsg ) %] >@@ -98,10 +95,18 @@ > <input name="newpassword2" id="newpassword2" type="password" size="20" /> > <input name="newpassword2" id="newpassword2_random" readonly="readonly" disabled="disabled" type="hidden" /> > </li> >+ >+ [% IF Koha.Preference('AutoEmailOpacUser') %] >+ <li> >+ <label for="mailacctdetails"> </label> >+ <input type="checkbox" id="mailacctdetails" name="mailacctdetails" checked> Mail account details to patron when you save</input> >+ </li> >+ [% END %] >+ > </ol> > </fieldset> > <fieldset class="action"><input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset> >-</form>[% END %] >+</form> > > </div> > </div> >diff --git a/members/member-password.pl b/members/member-password.pl >index eb37b99..f8de825 100755 >--- a/members/member-password.pl >+++ b/members/member-password.pl >@@ -1,11 +1,26 @@ > #!/usr/bin/perl >+ > #script to set the password, and optionally a userid, for a borrower >-#written 2/5/00 >-#by chris@katipo.co.nz >-#converted to using templates 3/16/03 by mwhansen@hmc.edu > >-use strict; >-use warnings; >+# Copyright 2000 chris@katipo.co.nz >+# Copyright 2005 mwhansen@hmc.edu (converted to using templates) >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; > > use C4::Auth; > use Koha::AuthUtils; >@@ -36,11 +51,7 @@ my ($template, $loggedinuser, $cookie, $staffflags) > my $flagsrequired; > $flagsrequired->{borrowers}=1; > >-#my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired, 'intranet'); >- > my $member=$input->param('member'); >-my $cardnumber = $input->param('cardnumber'); >-my $destination = $input->param('destination'); > my @errors; > my ($bor)=GetMember('borrowernumber' => $member); > if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) { >@@ -55,19 +66,27 @@ push(@errors,'NOMATCH') if ( ( $newpassword && $newpassword2 ) && ($newpassword > my $minpw = C4::Context->preference('minPasswordLength'); > push(@errors,'SHORTPASSWORD') if( $newpassword && $minpw && (length($newpassword) < $minpw ) ); > >-if ( $newpassword && !scalar(@errors) ) { >- my $digest=Koha::AuthUtils::hash_password($input->param('newpassword')); >- my $uid = $input->param('newuserid'); >- my $dbh=C4::Context->dbh; >- if (changepassword($uid,$member,$digest)) { >- $template->param(newpassword => $newpassword); >- if ($destination eq 'circ') { >- print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber"); >- } else { >- print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member"); >- } >+my $op = $input->param('op')//''; >+if ( $op eq 'save' && !@errors ) { >+ my $digest; >+ if( $newpassword ) { >+ $digest=Koha::AuthUtils::hash_password($input->param('newpassword')); >+ } else { >+ $digest = $bor->{password}; # unchanged password >+ } >+ my $uid = $input->param('newuserid')//''; >+ my $olduid = $input->param('olduserid')//''; >+ my $rv = 1; >+ if( $uid ne $olduid || $newpassword ) { #something changed? >+ $rv = changepassword( $uid, $member, $digest ); >+ } >+ if( $rv ) { >+ $bor->{password} = $newpassword || '****'; # ONLY FOR PRESENTATION >+ C4::Members::SendAutoEmail( $bor, $template ) if $input->param('mailacctdetails'); >+ print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member"); >+ exit 1; > } else { >- push(@errors,'BADUSERID'); >+ push @errors, 'BADUSERID'; > } > } else { > my $userid = $bor->{'userid'}; >@@ -81,12 +100,13 @@ if ( $newpassword && !scalar(@errors) ) { > > $template->param( defaultnewpassword => $defaultnewpassword ); > } >- if ( $bor->{'category_type'} eq 'C') { >+ >+if ( $bor->{'category_type'} eq 'C') { > my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); > my $cnt = scalar(@$catcodes); > $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; > $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; >- } >+} > > $template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' ); > my ($picture, $dberror) = GetPatronImage($bor->{'borrowernumber'}); >@@ -101,10 +121,10 @@ if (C4::Context->preference('ExtendedPatronAttributes')) { > } > > # Computes full borrower address >-my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $bor->{streettype} ); >+my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $bor->{streettype} ) // ''; > my $address = $bor->{'streetnumber'} . " $roadtype " . $bor->{'address'}; > >- $template->param( othernames => $bor->{'othernames'}, >+$template->param( othernames => $bor->{'othernames'}, > surname => $bor->{'surname'}, > firstname => $bor->{'firstname'}, > borrowernumber => $bor->{'borrowernumber'}, >@@ -126,19 +146,17 @@ my $address = $bor->{'streetnumber'} . " $roadtype " . $bor->{'address'}; > branchcode => $bor->{'branchcode'}, > branchname => GetBranchName($bor->{'branchcode'}), > userid => $bor->{'userid'}, >- destination => $destination, > is_child => ($bor->{'category_type'} eq 'C'), > activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), > minPasswordLength => $minpw, > RoutingSerials => C4::Context->preference('RoutingSerials'), >- ); >+); > > if( scalar(@errors )){ > $template->param( errormsg => 1 ); > foreach my $error (@errors) { > $template->param($error) || $template->param( $error => 1); > } >- > } > > output_html_with_http_headers $input, $cookie, $template->output; >-- >1.7.7.6
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 13096
:
32475
|
32476
|
33028
|
33158
|
33159
|
33160
|
33161
|
33162
|
40073