2 #script to set the password, and optionally a userid, for a borrower
5 #converted to using templates 3/16/03 by mwhansen@hmc.edu
15 use Digest
::MD5
qw(md5_base64);
19 my $theme = $input->param('theme') || "default";
20 # only used if allowthemeoverride is set
22 my ($template, $loggedinuser, $cookie)
23 = get_template_and_user
({template_name
=> "members/member-password.tmpl",
27 flagsrequired
=> {borrowers
=> 1},
32 $flagsrequired->{borrowers
}=1;
33 my ($loggedinuser, $cookie, $sessionID) = checkauth
($input, 0, $flagsrequired);
35 my $member=$input->param('member');
37 $member2{'borrowernumber'}=$member;
38 # my $issues=GetBorrowerIssues(\%member2);
40 # foreach (sort keys %$issues) {
44 my ($bor,$flags)=GetMemberDetails
( $member,'');
45 my $newpassword = $input->param('newpassword');
48 my $digest=md5_base64
($input->param('newpassword'));
49 my $uid = $input->param('newuserid');
50 my $dbh=C4
::Context
->dbh;
51 if (changepassword
($uid,$member,$digest)) {
52 $template->param(newpassword
=> $newpassword);
53 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
55 $template->param(othernames
=> $bor->{'othernames'},
56 surname
=> $bor->{'surname'},
57 firstname
=> $bor->{'firstname'},
58 userid
=> $bor->{'userid'},
59 defaultnewpassword
=> $newpassword );
62 my $userid = $bor->{'userid'};
64 my $chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
65 my $length=int(rand(2))+4;
66 my $defaultnewpassword='';
67 for (my $i=0; $i<$length; $i++) {
68 $defaultnewpassword.=substr($chars, int(rand(length($chars))),1);
70 $template->param( othernames
=> $bor->{'othernames'},
71 surname
=> $bor->{'surname'},
72 firstname
=> $bor->{'firstname'},
73 borrowernumber
=> $bor->{'borrowernumber'},
74 userid
=> $bor->{'userid'},
75 defaultnewpassword
=> $defaultnewpassword );
80 $template->param( member
=> $member,
82 output_html_with_http_headers
$input, $cookie, $template->output;