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

(-)a/Koha/Patron.pm (-3 / +4 lines)
Lines 291-300 sub store { Link Here
291
                # Make a copy of the plain text password for later use
291
                # Make a copy of the plain text password for later use
292
                $self->plain_text_password( $self->password );
292
                $self->plain_text_password( $self->password );
293
293
294
                if($self->category->effective_force_password_reset_when_set_by_staff and ($self->categorycode ne C4::Context->preference("PatronSelfRegistrationDefaultCategory"))){
294
                if ( $self->category->effective_force_password_reset_when_set_by_staff
295
                    and ( $self->categorycode ne C4::Context->preference("PatronSelfRegistrationDefaultCategory") ) )
296
                {
295
                    $self->password_expiration_date(dt_from_string);
297
                    $self->password_expiration_date(dt_from_string);
296
                }
298
                } else {
297
                else {
298
                    $self->password_expiration_date(
299
                    $self->password_expiration_date(
299
                          $self->password
300
                          $self->password
300
                        ? $self->category->get_password_expiry_date || undef
301
                        ? $self->category->get_password_expiry_date || undef
(-)a/admin/categories.pl (-66 / +67 lines)
Lines 52-98 if ( $op eq 'add_form' ) { Link Here
52
    );
52
    );
53
53
54
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
54
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
55
        C4::Form::MessagingPreferences::set_form_values(
55
        C4::Form::MessagingPreferences::set_form_values( { categorycode => $categorycode }, $template );
56
            { categorycode => $categorycode }, $template );
57
    }
56
    }
58
}
57
} elsif ( $op eq 'cud-add_validate' ) {
59
elsif ( $op eq 'cud-add_validate' ) {
58
60
59
    my $categorycode                           = $input->param('categorycode');
61
    my $categorycode = $input->param('categorycode');
60
    my $description                            = $input->param('description');
62
    my $description = $input->param('description');
61
    my $enrolmentperiod                        = $input->param('enrolmentperiod');
63
    my $enrolmentperiod = $input->param('enrolmentperiod');
62
    my $enrolmentperioddate                    = $input->param('enrolmentperioddate')  || undef;
64
    my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef;
63
    my $password_expiry_days                   = $input->param('password_expiry_days') || undef;
65
    my $password_expiry_days = $input->param('password_expiry_days') || undef;
64
    my $upperagelimit                          = $input->param('upperagelimit');
66
    my $upperagelimit = $input->param('upperagelimit');
65
    my $dateofbirthrequired                    = $input->param('dateofbirthrequired');
67
    my $dateofbirthrequired = $input->param('dateofbirthrequired');
66
    my $enrolmentfee                           = $input->param('enrolmentfee');
68
    my $enrolmentfee = $input->param('enrolmentfee');
67
    my $reservefee                             = $input->param('reservefee');
69
    my $reservefee = $input->param('reservefee');
68
    my $hidelostitems                          = $input->param('hidelostitems');
70
    my $hidelostitems = $input->param('hidelostitems');
69
    my $overduenoticerequired                  = $input->param('overduenoticerequired');
71
    my $overduenoticerequired = $input->param('overduenoticerequired');
70
    my $category_type                          = $input->param('category_type');
72
    my $category_type = $input->param('category_type');
71
    my $BlockExpiredPatronOpacActions          = $input->param('BlockExpiredPatronOpacActions');
73
    my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions');
72
    my $checkPrevCheckout                      = $input->param('checkprevcheckout');
74
    my $checkPrevCheckout = $input->param('checkprevcheckout');
73
    my $can_place_ill_in_opac                  = $input->param('can_place_ill_in_opac') // 1;
75
    my $can_place_ill_in_opac = $input->param('can_place_ill_in_opac') // 1;
74
    my $default_privacy                        = $input->param('default_privacy');
76
    my $default_privacy = $input->param('default_privacy');
75
    my $reset_password                         = $input->param('reset_password');
77
    my $reset_password = $input->param('reset_password');
76
    my $change_password                        = $input->param('cud-change_password');
78
    my $change_password = $input->param('cud-change_password');
77
    my $exclude_from_local_holds_priority      = $input->param('exclude_from_local_holds_priority');
79
    my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority');
78
    my $min_password_length                    = $input->param('min_password_length');
80
    my $min_password_length = $input->param('min_password_length');
79
    my $require_strong_password                = $input->param('require_strong_password');
81
    my $require_strong_password = $input->param('require_strong_password');
80
    my @branches                               = grep { $_ ne q{} } $input->multi_param('branches');
82
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
81
    my $can_be_guarantee                       = $input->param('can_be_guarantee');
83
    my $can_be_guarantee = $input->param('can_be_guarantee');
84
    my $force_password_reset_when_set_by_staff = $input->param('force_password_reset_when_set_by_staff');
82
    my $force_password_reset_when_set_by_staff = $input->param('force_password_reset_when_set_by_staff');
85
83
86
    $reset_password = undef if $reset_password eq -1;
84
    $reset_password                         = undef if $reset_password eq -1;
87
    $change_password = undef if $change_password eq -1;
85
    $change_password                        = undef if $change_password eq -1;
88
    $min_password_length = undef unless length($min_password_length);
86
    $min_password_length                    = undef unless length($min_password_length);
89
    $require_strong_password = undef if $require_strong_password eq -1;
87
    $require_strong_password                = undef if $require_strong_password eq -1;
90
    $force_password_reset_when_set_by_staff = undef if $force_password_reset_when_set_by_staff eq -1;
88
    $force_password_reset_when_set_by_staff = undef if $force_password_reset_when_set_by_staff eq -1;
91
89
92
    my $is_a_modif = $input->param("is_a_modif");
90
    my $is_a_modif = $input->param("is_a_modif");
93
91
94
    if ($is_a_modif) {
92
    if ($is_a_modif) {
95
        my $category = Koha::Patron::Categories->find( $categorycode );
93
        my $category = Koha::Patron::Categories->find($categorycode);
96
        $category->categorycode($categorycode);
94
        $category->categorycode($categorycode);
97
        $category->description($description);
95
        $category->description($description);
98
        $category->enrolmentperiod($enrolmentperiod);
96
        $category->enrolmentperiod($enrolmentperiod);
Lines 120-163 elsif ( $op eq 'cud-add_validate' ) { Link Here
120
            $category->store;
118
            $category->store;
121
            $category->replace_library_limits( \@branches );
119
            $category->replace_library_limits( \@branches );
122
        };
120
        };
123
        if ( $@ ) {
121
        if ($@) {
124
            push @messages, {type => 'error', code => 'error_on_update' };
122
            push @messages, { type => 'error', code => 'error_on_update' };
125
        } else {
123
        } else {
126
            push @messages, { type => 'message', code => 'success_on_update' };
124
            push @messages, { type => 'message', code => 'success_on_update' };
127
        }
125
        }
128
    }
126
    } else {
129
    else {
127
        my $category = Koha::Patron::Category->new(
130
        my $category = Koha::Patron::Category->new({
128
            {
131
            categorycode => $categorycode,
129
                categorycode                           => $categorycode,
132
            description => $description,
130
                description                            => $description,
133
            enrolmentperiod => $enrolmentperiod,
131
                enrolmentperiod                        => $enrolmentperiod,
134
            enrolmentperioddate => $enrolmentperioddate,
132
                enrolmentperioddate                    => $enrolmentperioddate,
135
            password_expiry_days => $password_expiry_days,
133
                password_expiry_days                   => $password_expiry_days,
136
            upperagelimit => $upperagelimit,
134
                upperagelimit                          => $upperagelimit,
137
            dateofbirthrequired => $dateofbirthrequired,
135
                dateofbirthrequired                    => $dateofbirthrequired,
138
            enrolmentfee => $enrolmentfee,
136
                enrolmentfee                           => $enrolmentfee,
139
            reservefee => $reservefee,
137
                reservefee                             => $reservefee,
140
            hidelostitems => $hidelostitems,
138
                hidelostitems                          => $hidelostitems,
141
            overduenoticerequired => $overduenoticerequired,
139
                overduenoticerequired                  => $overduenoticerequired,
142
            category_type => $category_type,
140
                category_type                          => $category_type,
143
            can_be_guarantee => $can_be_guarantee,
141
                can_be_guarantee                       => $can_be_guarantee,
144
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
142
                BlockExpiredPatronOpacActions          => $BlockExpiredPatronOpacActions,
145
            checkprevcheckout => $checkPrevCheckout,
143
                checkprevcheckout                      => $checkPrevCheckout,
146
            can_place_ill_in_opac => $can_place_ill_in_opac,
144
                can_place_ill_in_opac                  => $can_place_ill_in_opac,
147
            default_privacy => $default_privacy,
145
                default_privacy                        => $default_privacy,
148
            reset_password => $reset_password,
146
                reset_password                         => $reset_password,
149
            change_password => $change_password,
147
                change_password                        => $change_password,
150
            exclude_from_local_holds_priority => $exclude_from_local_holds_priority,
148
                exclude_from_local_holds_priority      => $exclude_from_local_holds_priority,
151
            min_password_length => $min_password_length,
149
                min_password_length                    => $min_password_length,
152
            require_strong_password => $require_strong_password,
150
                require_strong_password                => $require_strong_password,
153
            force_password_reset_when_set_by_staff => $force_password_reset_when_set_by_staff,
151
                force_password_reset_when_set_by_staff => $force_password_reset_when_set_by_staff,
154
        });
152
            }
153
        );
155
        eval {
154
        eval {
156
            $category->store;
155
            $category->store;
157
            $category->replace_library_limits( \@branches );
156
            $category->replace_library_limits( \@branches );
158
        };
157
        };
159
158
160
        if ( $@ ) {
159
        if ($@) {
161
            push @messages, { type => 'error', code => 'error_on_insert' };
160
            push @messages, { type => 'error', code => 'error_on_insert' };
162
        } else {
161
        } else {
163
            push @messages, { type => 'message', code => 'success_on_insert' };
162
            push @messages, { type => 'message', code => 'success_on_insert' };
Lines 165-176 elsif ( $op eq 'cud-add_validate' ) { Link Here
165
    }
164
    }
166
165
167
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
166
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
168
        C4::Form::MessagingPreferences::handle_form_action( $input,
167
        C4::Form::MessagingPreferences::handle_form_action(
169
            { categorycode => scalar $input->param('categorycode') }, $template );
168
            $input,
169
            { categorycode => scalar $input->param('categorycode') }, $template
170
        );
170
    }
171
    }
171
172
172
    $searchfield = q||;
173
    $searchfield = q||;
173
    $op = 'list';
174
    $op          = 'list';
174
}
175
}
175
elsif ( $op eq 'cud-delete_confirm' ) {
176
elsif ( $op eq 'cud-delete_confirm' ) {
176
177
(-)a/installer/data/mysql/atomicupdate/bug_33462.pl (-4 / +8 lines)
Lines 7-20 return { Link Here
7
    up          => sub {
7
    up          => sub {
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
        $dbh->do(q{
10
        $dbh->do(
11
            q{
11
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
12
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
12
VALUES ('ForcePasswordResetWhenSetByStaff', '0', NULL,'Force a staff created patron account to reset its password after its first OPAC login.', 'YesNo')
13
VALUES ('ForcePasswordResetWhenSetByStaff', '0', NULL,'Force a staff created patron account to reset its password after its first OPAC login.', 'YesNo')
13
        });
14
        }
15
        );
14
        say $out "Added new system preference 'ForcePasswordResetWhenSetByStaff'";
16
        say $out "Added new system preference 'ForcePasswordResetWhenSetByStaff'";
15
17
16
        if( !column_exists( 'categories', 'force_password_reset_when_set_by_staff' ) ) {
18
        if ( !column_exists( 'categories', 'force_password_reset_when_set_by_staff' ) ) {
17
            $dbh->do("ALTER TABLE categories ADD COLUMN `force_password_reset_when_set_by_staff` TINYINT(1) NULL DEFAULT NULL AFTER `require_strong_password` -- if patrons of this category are required to reset password after being created by a staff member");
19
            $dbh->do(
20
                "ALTER TABLE categories ADD COLUMN `force_password_reset_when_set_by_staff` TINYINT(1) NULL DEFAULT NULL AFTER `require_strong_password` -- if patrons of this category are required to reset password after being created by a staff member"
21
            );
18
        }
22
        }
19
23
20
        say $out "Added column to categories 'force_password_reset_when_set_by_staff'";
24
        say $out "Added column to categories 'force_password_reset_when_set_by_staff'";
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt (-2 / +1 lines)
Lines 189-195 Link Here
189
                        [% END # /UNLESS OPACShibOnly %]
189
                        [% END # /UNLESS OPACShibOnly %]
190
190
191
                        [% IF !(invalid_username_or_password || too_many_login_attempts) and password_has_expired %]
191
                        [% IF !(invalid_username_or_password || too_many_login_attempts) and password_has_expired %]
192
                            [% IF date_enrolled == password_expiration_date %]     
192
                            [% IF date_enrolled == password_expiration_date %]
193
                                <div class="alert alert-info">
193
                                <div class="alert alert-info">
194
                                    <p><strong>Error: </strong>It's your first login! You need to reset your password.</p>
194
                                    <p><strong>Error: </strong>It's your first login! You need to reset your password.</p>
195
                                </div>
195
                                </div>
196
- 

Return to bug 33462