View | Details | Raw Unified | Return to bug 15542
Collapse All | Expand All

(-)a/members/member-password.pl (-90 / +101 lines)
Lines 22-140 use Digest::MD5 qw(md5_base64); Link Here
22
my $input = new CGI;
22
my $input = new CGI;
23
23
24
my $theme = $input->param('theme') || "default";
24
my $theme = $input->param('theme') || "default";
25
			# only used if allowthemeoverride is set
26
25
27
my ($template, $loggedinuser, $cookie, $staffflags)
26
# only used if allowthemeoverride is set
28
    = get_template_and_user({template_name => "members/member-password.tt",
29
			     query => $input,
30
			     type => "intranet",
31
			     authnotrequired => 0,
32
			     flagsrequired => {borrowers => 1},
33
			     debug => 1,
34
			     });
35
27
36
my $flagsrequired;
28
my ( $template, $loggedinuser, $cookie, $staffflags ) = get_template_and_user(
37
$flagsrequired->{borrowers}=1;
29
    {
30
        template_name   => "members/member-password.tt",
31
        query           => $input,
32
        type            => "intranet",
33
        authnotrequired => 0,
34
        flagsrequired   => { borrowers => 1 },
35
        debug           => 1,
36
    }
37
);
38
38
39
#my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired, 'intranet');
39
my $flagsrequired;
40
$flagsrequired->{borrowers} = 1;
40
41
41
my $member=$input->param('member');
42
my $member      = $input->param('member');
42
my $cardnumber = $input->param('cardnumber');
43
my $cardnumber  = $input->param('cardnumber');
43
my $destination = $input->param('destination');
44
my $destination = $input->param('destination');
45
my $newpassword  = $input->param('newpassword');
46
my $newpassword2 = $input->param('newpassword2');
47
44
my @errors;
48
my @errors;
45
my ($bor)=GetMember('borrowernumber' => $member);
49
46
if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) {
50
my ($bor) = GetMember( 'borrowernumber' => $member );
47
	push(@errors,'NOPERMISSION') unless($staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
51
48
	# need superlibrarian for koha-conf.xml fakeuser.
52
if ( ( $member ne $loggedinuser ) && ( $bor->{'category_type'} eq 'S' ) ) {
53
    push( @errors, 'NOPERMISSION' )
54
      unless ( $staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
55
56
    # need superlibrarian for koha-conf.xml fakeuser.
49
}
57
}
50
my $newpassword = $input->param('newpassword');
51
my $newpassword2 = $input->param('newpassword2');
52
58
53
push(@errors,'NOMATCH') if ( ( $newpassword && $newpassword2 ) && ($newpassword ne $newpassword2) );
59
push( @errors, 'NOMATCH' ) if ( ( $newpassword && $newpassword2 ) && ( $newpassword ne $newpassword2 ) );
54
60
55
my $minpw = C4::Context->preference('minPasswordLength');
61
my $minpw = C4::Context->preference('minPasswordLength');
56
push(@errors,'SHORTPASSWORD') if( $newpassword && $minpw && (length($newpassword) < $minpw ) );
62
push( @errors, 'SHORTPASSWORD' ) if ( $newpassword && $minpw && ( length($newpassword) < $minpw ) );
57
63
58
if ( $newpassword  && !scalar(@errors) ) {
64
if ( $newpassword && !scalar(@errors) ) {
59
    my $digest=Koha::AuthUtils::hash_password($input->param('newpassword'));
65
    my $digest = Koha::AuthUtils::hash_password( $input->param('newpassword') );
60
    my $uid = $input->param('newuserid');
66
    my $uid    = $input->param('newuserid');
61
    my $dbh=C4::Context->dbh;
67
    my $dbh    = C4::Context->dbh;
62
    if (changepassword($uid,$member,$digest)) {
68
    if ( changepassword( $uid, $member, $digest ) ) {
63
		$template->param(newpassword => $newpassword);
69
        $template->param( newpassword => $newpassword );
64
		if ($destination eq 'circ') {
70
        if ( $destination eq 'circ' ) {
65
		    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber");		
71
            print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$cardnumber");
66
		} else {
72
        }
67
		    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
73
        else {
68
		}
74
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member");
69
    } else {
75
        }
70
			push(@errors,'BADUSERID');
71
    }
76
    }
72
} else {
77
    else {
78
        push( @errors, 'BADUSERID' );
79
    }
80
}
81
else {
73
    my $userid = $bor->{'userid'};
82
    my $userid = $bor->{'userid'};
74
83
75
    my $chars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
84
    my $chars              = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
76
    my $length=int(rand(2))+C4::Context->preference("minPasswordLength");
85
    my $length             = int( rand(2) ) + C4::Context->preference("minPasswordLength");
77
    my $defaultnewpassword='';
86
    my $defaultnewpassword = '';
78
    for (my $i=0; $i<$length; $i++) {
87
    for ( my $i = 0 ; $i < $length ; $i++ ) {
79
	$defaultnewpassword.=substr($chars, int(rand(length($chars))),1);
88
        $defaultnewpassword .= substr( $chars, int( rand( length($chars) ) ), 1 );
80
    }
89
    }
81
90
82
	$template->param( defaultnewpassword => $defaultnewpassword );
91
    $template->param( defaultnewpassword => $defaultnewpassword );
83
}
92
}
84
    if ( $bor->{'category_type'} eq 'C') {
93
85
        my  ( $catcodes, $labels ) =  GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
94
if ( $bor->{'category_type'} eq 'C' ) {
86
        my $cnt = scalar(@$catcodes);
95
    my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
87
        $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
96
    my $cnt = scalar(@$catcodes);
88
        $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
97
    $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
89
    }
98
    $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
90
	
99
}
100
91
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
101
$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' );
92
my ($picture, $dberror) = GetPatronImage($bor->{'borrowernumber'});
102
103
my ( $picture, $dberror ) = GetPatronImage( $bor->{'borrowernumber'} );
93
$template->param( picture => 1 ) if $picture;
104
$template->param( picture => 1 ) if $picture;
94
105
95
if (C4::Context->preference('ExtendedPatronAttributes')) {
106
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
96
    my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
107
    my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} );
97
    $template->param(
108
    $template->param(
98
        ExtendedPatronAttributes => 1,
109
        ExtendedPatronAttributes => 1,
99
        extendedattributes => $attributes
110
        extendedattributes       => $attributes
100
    );
111
    );
101
}
112
}
102
113
103
    $template->param( othernames => $bor->{'othernames'},
114
$template->param(
104
	    surname     => $bor->{'surname'},
115
    othernames                 => $bor->{'othernames'},
105
	    firstname   => $bor->{'firstname'},
116
    surname                    => $bor->{'surname'},
106
	    borrowernumber => $bor->{'borrowernumber'},
117
    firstname                  => $bor->{'firstname'},
107
	    cardnumber => $bor->{'cardnumber'},
118
    borrowernumber             => $bor->{'borrowernumber'},
108
	    categorycode => $bor->{'categorycode'},
119
    cardnumber                 => $bor->{'cardnumber'},
109
	    category_type => $bor->{'category_type'},
120
    categorycode               => $bor->{'categorycode'},
110
	    categoryname => $bor->{'description'},
121
    category_type              => $bor->{'category_type'},
111
        address => $bor->{address},
122
    categoryname               => $bor->{'description'},
112
	    address2 => $bor->{'address2'},
123
    address                    => $bor->{address},
113
        streettype => $bor->{streettype},
124
    address2                   => $bor->{'address2'},
114
	    city => $bor->{'city'},
125
    streettype                 => $bor->{streettype},
115
	    state => $bor->{'state'},
126
    city                       => $bor->{'city'},
116
	    zipcode => $bor->{'zipcode'},
127
    state                      => $bor->{'state'},
117
	    country => $bor->{'country'},
128
    zipcode                    => $bor->{'zipcode'},
118
	    phone => $bor->{'phone'},
129
    country                    => $bor->{'country'},
119
        phonepro => $bor->{'phonepro'},
130
    phone                      => $bor->{'phone'},
120
        mobile => $bor->{'mobile'},
131
    phonepro                   => $bor->{'phonepro'},
121
	    email => $bor->{'email'},
132
    mobile                     => $bor->{'mobile'},
122
        emailpro => $bor->{'emailpro'},
133
    email                      => $bor->{'email'},
123
	    branchcode => $bor->{'branchcode'},
134
    emailpro                   => $bor->{'emailpro'},
124
	    branchname => GetBranchName($bor->{'branchcode'}),
135
    branchcode                 => $bor->{'branchcode'},
125
	    userid      => $bor->{'userid'},
136
    branchname                 => GetBranchName( $bor->{'branchcode'} ),
126
	    destination => $destination,
137
    userid                     => $bor->{'userid'},
127
		is_child        => ($bor->{'category_type'} eq 'C'),
138
    destination                => $destination,
128
		activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
139
    is_child                   => ( $bor->{'category_type'} eq 'C' ),
129
        minPasswordLength => $minpw,
140
    activeBorrowerRelationship => ( C4::Context->preference('borrowerRelationship') ne '' ),
130
        RoutingSerials => C4::Context->preference('RoutingSerials'),
141
    minPasswordLength          => $minpw,
131
	);
142
    RoutingSerials             => C4::Context->preference('RoutingSerials'),
132
143
);
133
if( scalar(@errors )){
144
134
	$template->param( errormsg => 1 );
145
if ( scalar(@errors) ) {
135
	foreach my $error (@errors) {
146
    $template->param( errormsg => 1 );
136
        $template->param($error) || $template->param( $error => 1);
147
    foreach my $error (@errors) {
137
	}
148
        $template->param($error) || $template->param( $error => 1 );
149
    }
138
150
139
}
151
}
140
152
141
- 

Return to bug 15542