X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=members%2Fmember-password.pl;h=fe24df3a4ba252eab818e4c571758dd311dd3083;hb=44ab1c531d1aca7bf5223ad011b7a1e848a291b7;hp=183d2d34842a7f8a53ea71ececb5d36f3dec8b41;hpb=de04e990f269ef00fe24cb2861b6fc48b6407779;p=koha_gimpoz diff --git a/members/member-password.pl b/members/member-password.pl index 183d2d3484..fe24df3a4b 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -5,12 +5,16 @@ #converted to using templates 3/16/03 by mwhansen@hmc.edu use strict; +use warnings; + use C4::Auth; 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); @@ -36,17 +40,21 @@ $flagsrequired->{borrowers}=1; 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 ) { +if ( $newpassword && !scalar(@errors) ) { my $digest=md5_base64($input->param('newpassword')); my $uid = $input->param('newuserid'); my $dbh=C4::Context->dbh; @@ -58,28 +66,39 @@ 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); + $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; + $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; + } - my $borrowercategory = GetBorrowercategory( $bor->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); - +$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' ); +my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'}); +$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'}, @@ -87,25 +106,30 @@ my $category_type = $borrowercategory->{'category_type'}; cardnumber => $bor->{'cardnumber'}, categorycode => $bor->{'categorycode'}, category_type => $bor->{'category_type'}, - category_description => $bor->{'description'}, + categoryname => $bor->{'description'}, address => $bor->{'address'}, address2 => $bor->{'address2'}, city => $bor->{'city'}, + state => $bor->{'state'}, zipcode => $bor->{'zipcode'}, + country => $bor->{'country'}, phone => $bor->{'phone'}, email => $bor->{'email'}, branchcode => $bor->{'branchcode'}, + branchname => GetBranchName($bor->{'branchcode'}), userid => $bor->{'userid'}, destination => $destination, - defaultnewpassword => $defaultnewpassword + is_child => ($bor->{'category_type'} eq 'C'), + activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), + minPasswordLength => $minpw ); +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;