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

(-)a/installer/data/mysql/atomicupdate/bug_39579-patronselfregistrationagerestriction.pl (+17 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => '39579',
6
    description => "Add system preference 'patronSelfRegistrationAgeRestriction'",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        $dbh->do( "
12
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
13
            ('PatronSelfRegistrationAgeRestriction', '', NULL, 'Patron\'s maximum age during self registration. If empty, no age restriction is applied.', 'Integer')
14
        " );
15
        say_success( $out, "Added new system preference 'PatronSelfRegistrationAgeRestriction'" );
16
    },
17
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 623-628 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
623
('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'),
623
('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'),
624
('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'),
624
('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'),
625
('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'),
625
('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'),
626
('PatronSelfRegistrationAgeRestriction', '', NULL, 'Patron\'s maximum age during self registration. If empty, no age restriction is applied.', 'Integer'),
626
('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo'),
627
('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo'),
627
('PatronSelfRegistrationBorrowerMandatoryField','surname|firstname',NULL,'Choose the mandatory fields for a patron\'s account, when registering via the OPAC.','free'),
628
('PatronSelfRegistrationBorrowerMandatoryField','surname|firstname',NULL,'Choose the mandatory fields for a patron\'s account, when registering via the OPAC.','free'),
628
('PatronSelfRegistrationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when registering a new patron via the OPAC.','free'),
629
('PatronSelfRegistrationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when registering a new patron via the OPAC.','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+5 lines)
Lines 924-929 OPAC: Link Here
924
                0: "Don't show"
924
                0: "Don't show"
925
                1: "Show"
925
                1: "Show"
926
            - an alert on staff interface home page when there are patrons in the category defined by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>.
926
            - an alert on staff interface home page when there are patrons in the category defined by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=PatronSelfRegistrationDefaultCategory">PatronSelfRegistrationDefaultCategory</a>.
927
        -
928
            - "Patron's maximum age when registering: "
929
            - pref: PatronSelfRegistrationAgeRestriction
930
              class: integer
931
            - "<br />Note: If empty, do not restrict patron's age during self registration"
927
    Suggestions:
932
    Suggestions:
928
        -
933
        -
929
            - pref: OpacSuggestionManagedBy
934
            - pref: OpacSuggestionManagedBy
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (+3 lines)
Lines 115-120 Link Here
115
                                    [% IF field == "ERROR_age_limitations" %]
115
                                    [% IF field == "ERROR_age_limitations" %]
116
                                        <li>Patron's age is incorrect for their category.</li>
116
                                        <li>Patron's age is incorrect for their category.</li>
117
                                    [% END %]
117
                                    [% END %]
118
                                    [% IF field == "ERROR_age_limitations_self_registration" %]
119
                                        <li> Patron's age exceeds the maximum age allowed.</li>
120
                                    [% END %]
118
                                [% END %]
121
                                [% END %]
119
                            </ul>
122
                            </ul>
120
                            <span>Please correct and resubmit.</span>
123
                            <span>Please correct and resubmit.</span>
(-)a/opac/opac-memberentry.pl (-1 / +4 lines)
Lines 545-553 sub CheckForInvalidFields { Link Here
545
        my $age              = $patron->get_age;
545
        my $age              = $patron->get_age;
546
        my $borrowercategory = Koha::Patron::Categories->find( $borrower->{'categorycode'} );
546
        my $borrowercategory = Koha::Patron::Categories->find( $borrower->{'categorycode'} );
547
        my ( $low, $high ) = ( $borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit );
547
        my ( $low, $high ) = ( $borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit );
548
        my $upper_registration_age_restriction = C4::Context->preference("PatronSelfRegistrationAgeRestriction");
548
        if ( ( $high && ( $age > $high ) ) or ( $age < $low ) ) {
549
        if ( ( $high && ( $age > $high ) ) or ( $age < $low ) ) {
549
            push @invalidFields, 'ERROR_age_limitations';
550
            push @invalidFields, 'ERROR_age_limitations';
550
        }
551
        }
552
        if ( $upper_registration_age_restriction && $age > $upper_registration_age_restriction ) {
553
            push @invalidFields, 'ERROR_age_limitations_self_registration';
554
        }
551
    }
555
    }
552
556
553
    return \@invalidFields;
557
    return \@invalidFields;
554
- 

Return to bug 39579