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

(-)a/cataloguing/value_builder/validate_isbn.pl (+68 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2025 BibLibre SARL
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
23
use C4::Auth       qw( get_template_and_user );
24
use C4::Output     qw( output_html_with_http_headers );
25
use Business::ISBN qw( valid_isbn_checksum );
26
27
my $builder = sub {
28
    my $params = shift;
29
    my $id     = $params->{id};
30
31
    return qq|
32
<script>
33
function Blur$id(event) {
34
    field = \$('#'+event.data.id);
35
    isbn = field.val();
36
    var url = '../cataloguing/plugin_launcher.pl?plugin_name=validate_isbn.pl&isbn=' + isbn;
37
    var req = \$.get(url);
38
    req.done(function(resp){
39
        if ( resp != 1 ) {
40
           field.addClass("subfield_not_filled");
41
           alert("Invalid ISBN : " + isbn);
42
           return;
43
        }
44
        field.removeClass("subfield_not_filled");
45
    });
46
}
47
</script>|;
48
};
49
50
my $launcher = sub {
51
    my $params = shift;
52
    my $cgi    = $params->{cgi};
53
    my $isbn   = $cgi->param('isbn');
54
55
    my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
56
        {
57
            template_name => "cataloguing/value_builder/ajax.tt",
58
            query         => $cgi,
59
            type          => "intranet",
60
            flagsrequired => { editcatalogue => '*' },
61
        }
62
    );
63
    my $is_valid = valid_isbn_checksum($isbn);
64
    $template->param( return => $is_valid );
65
    output_html_with_http_headers $cgi, $cookie, $template->output;
66
};
67
68
return { builder => $builder, launcher => $launcher };
(-)a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.yml (-1 / +1 lines)
Lines 4628-4634 tables: Link Here
4628
          tab: 0
4628
          tab: 0
4629
          authorised_value: ""
4629
          authorised_value: ""
4630
          authtypecode: ""
4630
          authtypecode: ""
4631
          value_builder: ""
4631
          value_builder: validate_isbn.pl
4632
          isurl: 0
4632
          isurl: 0
4633
          hidden: 0
4633
          hidden: 0
4634
          frameworkcode: ""
4634
          frameworkcode: ""
(-)a/installer/data/mysql/en/marcflavour/unimarc/mandatory/unimarc_framework_DEFAULT.yml (-2 / +1 lines)
Lines 3158-3164 tables: Link Here
3158
          tab: 0
3158
          tab: 0
3159
          authorised_value:
3159
          authorised_value:
3160
          authtypecode: ""
3160
          authtypecode: ""
3161
          value_builder: ""
3161
          value_builder: validate_isbn.pl
3162
          isurl: 0
3162
          isurl: 0
3163
          hidden: 0
3163
          hidden: 0
3164
          frameworkcode: ""
3164
          frameworkcode: ""
3165
- 

Return to bug 29980