Lines 1-11
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
|
|
2 |
|
2 |
#script to set the password, and optionally a userid, for a borrower |
3 |
#script to set the password, and optionally a userid, for a borrower |
3 |
#written 2/5/00 |
|
|
4 |
#by chris@katipo.co.nz |
5 |
#converted to using templates 3/16/03 by mwhansen@hmc.edu |
6 |
|
4 |
|
7 |
use strict; |
5 |
# Copyright 2000 chris@katipo.co.nz |
8 |
use warnings; |
6 |
# Copyright 2005 mwhansen@hmc.edu (converted to using templates) |
|
|
7 |
# |
8 |
# This file is part of Koha. |
9 |
# |
10 |
# Koha is free software; you can redistribute it and/or modify it under the |
11 |
# terms of the GNU General Public License as published by the Free Software |
12 |
# Foundation; either version 3 of the License, or (at your option) any later |
13 |
# version. |
14 |
# |
15 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
16 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
17 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
18 |
# |
19 |
# You should have received a copy of the GNU General Public License along |
20 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
21 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
22 |
|
23 |
use Modern::Perl; |
9 |
|
24 |
|
10 |
use C4::Auth; |
25 |
use C4::Auth; |
11 |
use Koha::AuthUtils; |
26 |
use Koha::AuthUtils; |
Lines 36-46
my ($template, $loggedinuser, $cookie, $staffflags)
Link Here
|
36 |
my $flagsrequired; |
51 |
my $flagsrequired; |
37 |
$flagsrequired->{borrowers}=1; |
52 |
$flagsrequired->{borrowers}=1; |
38 |
|
53 |
|
39 |
#my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired, 'intranet'); |
|
|
40 |
|
41 |
my $member=$input->param('member'); |
54 |
my $member=$input->param('member'); |
42 |
my $cardnumber = $input->param('cardnumber'); |
|
|
43 |
my $destination = $input->param('destination'); |
44 |
my @errors; |
55 |
my @errors; |
45 |
my ($bor)=GetMember('borrowernumber' => $member); |
56 |
my ($bor)=GetMember('borrowernumber' => $member); |
46 |
if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) { |
57 |
if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) { |
Lines 55-73
push(@errors,'NOMATCH') if ( ( $newpassword && $newpassword2 ) && ($newpassword
Link Here
|
55 |
my $minpw = C4::Context->preference('minPasswordLength'); |
66 |
my $minpw = C4::Context->preference('minPasswordLength'); |
56 |
push(@errors,'SHORTPASSWORD') if( $newpassword && $minpw && (length($newpassword) < $minpw ) ); |
67 |
push(@errors,'SHORTPASSWORD') if( $newpassword && $minpw && (length($newpassword) < $minpw ) ); |
57 |
|
68 |
|
58 |
if ( $newpassword && !scalar(@errors) ) { |
69 |
my $op = $input->param('op')//''; |
59 |
my $digest=Koha::AuthUtils::hash_password($input->param('newpassword')); |
70 |
if ( $op eq 'save' && !@errors ) { |
60 |
my $uid = $input->param('newuserid'); |
71 |
my $digest; |
61 |
my $dbh=C4::Context->dbh; |
72 |
if( $newpassword ) { |
62 |
if (changepassword($uid,$member,$digest)) { |
73 |
$digest=Koha::AuthUtils::hash_password($input->param('newpassword')); |
63 |
$template->param(newpassword => $newpassword); |
74 |
} else { |
64 |
if ($destination eq 'circ') { |
75 |
$digest = $bor->{password}; # unchanged password |
65 |
print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber"); |
76 |
} |
66 |
} else { |
77 |
my $uid = $input->param('newuserid')//''; |
67 |
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member"); |
78 |
my $olduid = $input->param('olduserid')//''; |
68 |
} |
79 |
my $rv = 1; |
|
|
80 |
if( $uid ne $olduid || $newpassword ) { #something changed? |
81 |
$rv = changepassword( $uid, $member, $digest ); |
82 |
} |
83 |
if( $rv ) { |
84 |
$bor->{password} = $newpassword || '****'; # ONLY FOR PRESENTATION |
85 |
C4::Members::SendAutoEmail( $bor, $template ) if $input->param('mailacctdetails'); |
86 |
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member"); |
87 |
exit 1; |
69 |
} else { |
88 |
} else { |
70 |
push(@errors,'BADUSERID'); |
89 |
push @errors, 'BADUSERID'; |
71 |
} |
90 |
} |
72 |
} else { |
91 |
} else { |
73 |
my $userid = $bor->{'userid'}; |
92 |
my $userid = $bor->{'userid'}; |
Lines 81-92
if ( $newpassword && !scalar(@errors) ) {
Link Here
|
81 |
|
100 |
|
82 |
$template->param( defaultnewpassword => $defaultnewpassword ); |
101 |
$template->param( defaultnewpassword => $defaultnewpassword ); |
83 |
} |
102 |
} |
84 |
if ( $bor->{'category_type'} eq 'C') { |
103 |
|
|
|
104 |
if ( $bor->{'category_type'} eq 'C') { |
85 |
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); |
105 |
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); |
86 |
my $cnt = scalar(@$catcodes); |
106 |
my $cnt = scalar(@$catcodes); |
87 |
$template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; |
107 |
$template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; |
88 |
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; |
108 |
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; |
89 |
} |
109 |
} |
90 |
|
110 |
|
91 |
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' ); |
111 |
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' ); |
92 |
my ($picture, $dberror) = GetPatronImage($bor->{'borrowernumber'}); |
112 |
my ($picture, $dberror) = GetPatronImage($bor->{'borrowernumber'}); |
Lines 101-110
if (C4::Context->preference('ExtendedPatronAttributes')) {
Link Here
|
101 |
} |
121 |
} |
102 |
|
122 |
|
103 |
# Computes full borrower address |
123 |
# Computes full borrower address |
104 |
my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $bor->{streettype} ); |
124 |
my $roadtype = C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $bor->{streettype} ) // ''; |
105 |
my $address = $bor->{'streetnumber'} . " $roadtype " . $bor->{'address'}; |
125 |
my $address = $bor->{'streetnumber'} . " $roadtype " . $bor->{'address'}; |
106 |
|
126 |
|
107 |
$template->param( othernames => $bor->{'othernames'}, |
127 |
$template->param( othernames => $bor->{'othernames'}, |
108 |
surname => $bor->{'surname'}, |
128 |
surname => $bor->{'surname'}, |
109 |
firstname => $bor->{'firstname'}, |
129 |
firstname => $bor->{'firstname'}, |
110 |
borrowernumber => $bor->{'borrowernumber'}, |
130 |
borrowernumber => $bor->{'borrowernumber'}, |
Lines 126-144
my $address = $bor->{'streetnumber'} . " $roadtype " . $bor->{'address'};
Link Here
|
126 |
branchcode => $bor->{'branchcode'}, |
146 |
branchcode => $bor->{'branchcode'}, |
127 |
branchname => GetBranchName($bor->{'branchcode'}), |
147 |
branchname => GetBranchName($bor->{'branchcode'}), |
128 |
userid => $bor->{'userid'}, |
148 |
userid => $bor->{'userid'}, |
129 |
destination => $destination, |
|
|
130 |
is_child => ($bor->{'category_type'} eq 'C'), |
149 |
is_child => ($bor->{'category_type'} eq 'C'), |
131 |
activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), |
150 |
activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''), |
132 |
minPasswordLength => $minpw, |
151 |
minPasswordLength => $minpw, |
133 |
RoutingSerials => C4::Context->preference('RoutingSerials'), |
152 |
RoutingSerials => C4::Context->preference('RoutingSerials'), |
134 |
); |
153 |
); |
135 |
|
154 |
|
136 |
if( scalar(@errors )){ |
155 |
if( scalar(@errors )){ |
137 |
$template->param( errormsg => 1 ); |
156 |
$template->param( errormsg => 1 ); |
138 |
foreach my $error (@errors) { |
157 |
foreach my $error (@errors) { |
139 |
$template->param($error) || $template->param( $error => 1); |
158 |
$template->param($error) || $template->param( $error => 1); |
140 |
} |
159 |
} |
141 |
|
|
|
142 |
} |
160 |
} |
143 |
|
161 |
|
144 |
output_html_with_http_headers $input, $cookie, $template->output; |
162 |
output_html_with_http_headers $input, $cookie, $template->output; |
145 |
- |
|
|