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 (-40 / +42 lines)
Lines 52-59 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
}
59
elsif ( $op eq 'cud-add_validate' ) {
58
elsif ( $op eq 'cud-add_validate' ) {
Lines 83-98 elsif ( $op eq 'cud-add_validate' ) { Link Here
83
    my $can_be_guarantee = $input->param('can_be_guarantee');
82
    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');
83
    my $force_password_reset_when_set_by_staff = $input->param('force_password_reset_when_set_by_staff');
85
84
86
    $reset_password = undef if $reset_password eq -1;
85
    $reset_password                         = undef if $reset_password eq -1;
87
    $change_password = undef if $change_password eq -1;
86
    $change_password                        = undef if $change_password eq -1;
88
    $min_password_length = undef unless length($min_password_length);
87
    $min_password_length                    = undef unless length($min_password_length);
89
    $require_strong_password = undef if $require_strong_password eq -1;
88
    $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;
89
    $force_password_reset_when_set_by_staff = undef if $force_password_reset_when_set_by_staff eq -1;
91
90
92
    my $is_a_modif = $input->param("is_a_modif");
91
    my $is_a_modif = $input->param("is_a_modif");
93
92
94
    if ($is_a_modif) {
93
    if ($is_a_modif) {
95
        my $category = Koha::Patron::Categories->find( $categorycode );
94
        my $category = Koha::Patron::Categories->find($categorycode);
96
        $category->categorycode($categorycode);
95
        $category->categorycode($categorycode);
97
        $category->description($description);
96
        $category->description($description);
98
        $category->enrolmentperiod($enrolmentperiod);
97
        $category->enrolmentperiod($enrolmentperiod);
Lines 120-163 elsif ( $op eq 'cud-add_validate' ) { Link Here
120
            $category->store;
119
            $category->store;
121
            $category->replace_library_limits( \@branches );
120
            $category->replace_library_limits( \@branches );
122
        };
121
        };
123
        if ( $@ ) {
122
        if ($@) {
124
            push @messages, {type => 'error', code => 'error_on_update' };
123
            push @messages, { type => 'error', code => 'error_on_update' };
125
        } else {
124
        } else {
126
            push @messages, { type => 'message', code => 'success_on_update' };
125
            push @messages, { type => 'message', code => 'success_on_update' };
127
        }
126
        }
128
    }
127
    } else {
129
    else {
128
        my $category = Koha::Patron::Category->new(
130
        my $category = Koha::Patron::Category->new({
129
            {
131
            categorycode => $categorycode,
130
                categorycode                           => $categorycode,
132
            description => $description,
131
                description                            => $description,
133
            enrolmentperiod => $enrolmentperiod,
132
                enrolmentperiod                        => $enrolmentperiod,
134
            enrolmentperioddate => $enrolmentperioddate,
133
                enrolmentperioddate                    => $enrolmentperioddate,
135
            password_expiry_days => $password_expiry_days,
134
                password_expiry_days                   => $password_expiry_days,
136
            upperagelimit => $upperagelimit,
135
                upperagelimit                          => $upperagelimit,
137
            dateofbirthrequired => $dateofbirthrequired,
136
                dateofbirthrequired                    => $dateofbirthrequired,
138
            enrolmentfee => $enrolmentfee,
137
                enrolmentfee                           => $enrolmentfee,
139
            reservefee => $reservefee,
138
                reservefee                             => $reservefee,
140
            hidelostitems => $hidelostitems,
139
                hidelostitems                          => $hidelostitems,
141
            overduenoticerequired => $overduenoticerequired,
140
                overduenoticerequired                  => $overduenoticerequired,
142
            category_type => $category_type,
141
                category_type                          => $category_type,
143
            can_be_guarantee => $can_be_guarantee,
142
                can_be_guarantee                       => $can_be_guarantee,
144
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
143
                BlockExpiredPatronOpacActions          => $BlockExpiredPatronOpacActions,
145
            checkprevcheckout => $checkPrevCheckout,
144
                checkprevcheckout                      => $checkPrevCheckout,
146
            can_place_ill_in_opac => $can_place_ill_in_opac,
145
                can_place_ill_in_opac                  => $can_place_ill_in_opac,
147
            default_privacy => $default_privacy,
146
                default_privacy                        => $default_privacy,
148
            reset_password => $reset_password,
147
                reset_password                         => $reset_password,
149
            change_password => $change_password,
148
                change_password                        => $change_password,
150
            exclude_from_local_holds_priority => $exclude_from_local_holds_priority,
149
                exclude_from_local_holds_priority      => $exclude_from_local_holds_priority,
151
            min_password_length => $min_password_length,
150
                min_password_length                    => $min_password_length,
152
            require_strong_password => $require_strong_password,
151
                require_strong_password                => $require_strong_password,
153
            force_password_reset_when_set_by_staff => $force_password_reset_when_set_by_staff,
152
                force_password_reset_when_set_by_staff => $force_password_reset_when_set_by_staff,
154
        });
153
            }
154
        );
155
        eval {
155
        eval {
156
            $category->store;
156
            $category->store;
157
            $category->replace_library_limits( \@branches );
157
            $category->replace_library_limits( \@branches );
158
        };
158
        };
159
159
160
        if ( $@ ) {
160
        if ($@) {
161
            push @messages, { type => 'error', code => 'error_on_insert' };
161
            push @messages, { type => 'error', code => 'error_on_insert' };
162
        } else {
162
        } else {
163
            push @messages, { type => 'message', code => 'success_on_insert' };
163
            push @messages, { type => 'message', code => 'success_on_insert' };
Lines 165-176 elsif ( $op eq 'cud-add_validate' ) { Link Here
165
    }
165
    }
166
166
167
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
167
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
168
        C4::Form::MessagingPreferences::handle_form_action( $input,
168
        C4::Form::MessagingPreferences::handle_form_action(
169
            { categorycode => scalar $input->param('categorycode') }, $template );
169
            $input,
170
            { categorycode => scalar $input->param('categorycode') }, $template
171
        );
170
    }
172
    }
171
173
172
    $searchfield = q||;
174
    $searchfield = q||;
173
    $op = 'list';
175
    $op          = 'list';
174
}
176
}
175
elsif ( $op eq 'delete_confirm' ) {
177
elsif ( $op eq 'delete_confirm' ) {
176
178
(-)a/installer/data/mysql/atomicupdate/bug_33462.pl (-5 / +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'";
21
- 

Return to bug 33462