projects
/
koha.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug 9374: (follow-up) add FIXME suggesting that use of a regexp is not the long-term...
[koha.git]
/
members
/
member-password.pl
diff --git
a/members/member-password.pl
b/members/member-password.pl
index
17416d7
..
ac25da5
100755
(executable)
--- a/
members/member-password.pl
+++ b/
members/member-password.pl
@@
-8,12
+8,14
@@
use strict;
use warnings;
use C4::Auth;
use warnings;
use C4::Auth;
+use Koha::AuthUtils;
use C4::Output;
use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Circulation;
use CGI;
use C4::Output;
use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Circulation;
use CGI;
+use C4::Members::Attributes qw(GetBorrowerAttributes);
use Digest::MD5 qw(md5_base64);
use Digest::MD5 qw(md5_base64);
@@
-34,23
+36,27
@@
my ($template, $loggedinuser, $cookie, $staffflags)
my $flagsrequired;
$flagsrequired->{borrowers}=1;
my $flagsrequired;
$flagsrequired->{borrowers}=1;
-#my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
+#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 $member=$input->param('member');
my $cardnumber = $input->param('cardnumber');
my $destination = $input->param('destination');
-my
$errormsg
;
-my ($bor)=GetMember($member);
+my
@errors
;
+my ($bor)=GetMember(
'borrowernumber' =>
$member);
if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) {
if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) {
-
$errormsg = 'NOPERMISSION'
unless($staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
+
push(@errors,'NOPERMISSION')
unless($staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
# need superlibrarian for koha-conf.xml fakeuser.
}
my $newpassword = $input->param('newpassword');
# need superlibrarian for koha-conf.xml fakeuser.
}
my $newpassword = $input->param('newpassword');
+my $newpassword2 = $input->param('newpassword2');
+
+push(@errors,'NOMATCH') if ( ( $newpassword && $newpassword2 ) && ($newpassword ne $newpassword2) );
+
my $minpw = C4::Context->preference('minPasswordLength');
my $minpw = C4::Context->preference('minPasswordLength');
-
$errormsg = 'SHORTPASSWORD'
if( $newpassword && $minpw && (length($newpassword) < $minpw ) );
+
push(@errors,'SHORTPASSWORD')
if( $newpassword && $minpw && (length($newpassword) < $minpw ) );
-if ( $newpassword && !
$errormsg
) {
- my $digest=
md5_base64
($input->param('newpassword'));
+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)) {
my $uid = $input->param('newuserid');
my $dbh=C4::Context->dbh;
if (changepassword($uid,$member,$digest)) {
@@
-61,24
+67,20
@@
if ( $newpassword && ! $errormsg ) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
}
} else {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
}
} else {
- $errormsg = 'BADUSERID';
- $template->param(othernames => $bor->{'othernames'},
- surname => $bor->{'surname'},
- firstname => $bor->{'firstname'},
- userid => $bor->{'userid'},
- defaultnewpassword => $newpassword
- );
+ push(@errors,'BADUSERID');
}
} else {
my $userid = $bor->{'userid'};
my $chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
}
} else {
my $userid = $bor->{'userid'};
my $chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
- my $length=int(rand(2))+
4
;
+ my $length=int(rand(2))+
C4::Context->preference("minPasswordLength")
;
my $defaultnewpassword='';
for (my $i=0; $i<$length; $i++) {
$defaultnewpassword.=substr($chars, int(rand(length($chars))),1);
}
my $defaultnewpassword='';
for (my $i=0; $i<$length; $i++) {
$defaultnewpassword.=substr($chars, int(rand(length($chars))),1);
}
-
+
+ $template->param( defaultnewpassword => $defaultnewpassword );
+}
if ( $bor->{'category_type'} eq 'C') {
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
my $cnt = scalar(@$catcodes);
if ( $bor->{'category_type'} eq 'C') {
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
my $cnt = scalar(@$catcodes);
@@
-87,9
+89,17
@@
if ( $newpassword && ! $errormsg ) {
}
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
}
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
-my ($picture, $dberror) = GetPatronImage($bor->{'
card
number'});
+my ($picture, $dberror) = GetPatronImage($bor->{'
borrower
number'});
$template->param( picture => 1 ) if $picture;
$template->param( picture => 1 ) if $picture;
-
+
+if (C4::Context->preference('ExtendedPatronAttributes')) {
+ my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
+ $template->param(
+ ExtendedPatronAttributes => 1,
+ extendedattributes => $attributes
+ );
+}
+
$template->param( othernames => $bor->{'othernames'},
surname => $bor->{'surname'},
firstname => $bor->{'firstname'},
$template->param( othernames => $bor->{'othernames'},
surname => $bor->{'surname'},
firstname => $bor->{'firstname'},
@@
-101,6
+111,7
@@
$template->param( picture => 1 ) if $picture;
address => $bor->{'address'},
address2 => $bor->{'address2'},
city => $bor->{'city'},
address => $bor->{'address'},
address2 => $bor->{'address2'},
city => $bor->{'city'},
+ state => $bor->{'state'},
zipcode => $bor->{'zipcode'},
country => $bor->{'country'},
phone => $bor->{'phone'},
zipcode => $bor->{'zipcode'},
country => $bor->{'country'},
phone => $bor->{'phone'},
@@
-110,15
+121,17
@@
$template->param( picture => 1 ) if $picture;
userid => $bor->{'userid'},
destination => $destination,
is_child => ($bor->{'category_type'} eq 'C'),
userid => $bor->{'userid'},
destination => $destination,
is_child => ($bor->{'category_type'} eq 'C'),
- defaultnewpassword => $defaultnewpassword
+ 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);
+ }
}
}
-$template->param( member => $member,
- errormsg => $errormsg,
- $errormsg => 1 ,
- minPasswordLength => $minpw );
-
output_html_with_http_headers $input, $cookie, $template->output;
output_html_with_http_headers $input, $cookie, $template->output;