X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=members%2Fmember-password.pl;h=ac25da5ce701b02989ef82ec28145f93d55e7bca;hb=8ae61b6a2a6b2c6e27f33d1d32e1849265782530;hp=17416d7eb55f3c20475bff3d3d9dfe3daa8032e3;hpb=868b8cdbaa079a948a6015f713fa3384a7f404b5;p=koha.git diff --git a/members/member-password.pl b/members/member-password.pl index 17416d7eb5..ac25da5ce7 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -8,12 +8,14 @@ use strict; 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::Members::Attributes qw(GetBorrowerAttributes); use Digest::MD5 qw(md5_base64); @@ -34,23 +36,27 @@ my ($template, $loggedinuser, $cookie, $staffflags) 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 $errormsg; -my ($bor)=GetMember($member); +my @errors; +my ($bor)=GetMember('borrowernumber' => $member); 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'); +my $newpassword2 = $input->param('newpassword2'); + +push(@errors,'NOMATCH') if ( ( $newpassword && $newpassword2 ) && ($newpassword ne $newpassword2) ); + 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)) { @@ -61,24 +67,20 @@ if ( $newpassword && ! $errormsg ) { 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'; - 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); } - + + $template->param( defaultnewpassword => $defaultnewpassword ); +} 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' ); -my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'}); +my ($picture, $dberror) = GetPatronImage($bor->{'borrowernumber'}); $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'}, @@ -101,6 +111,7 @@ $template->param( picture => 1 ) if $picture; address => $bor->{'address'}, address2 => $bor->{'address2'}, city => $bor->{'city'}, + state => $bor->{'state'}, 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'), - 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;