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

(-)a/cataloguing/value_builder/validate_issn.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 <https://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::ISSN qw( is_valid_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
    issn = field.val();
36
    var url = '../cataloguing/plugin_launcher.pl?plugin_name=validate_issn.pl&issn=' + issn;
37
    var req = \$.get(url);
38
    req.done(function(resp){
39
        if ( resp != 1 ) {
40
           field.addClass("subfield_not_filled");
41
           alert("Invalid ISSN : " + issn);
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 $issn   = $cgi->param('issn');
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 = is_valid_checksum($issn);
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 4790-4796 tables: Link Here
4790
          tab: 0
4790
          tab: 0
4791
          authorised_value: ""
4791
          authorised_value: ""
4792
          authtypecode: ""
4792
          authtypecode: ""
4793
          value_builder: ""
4793
          value_builder: validate_issn.pl
4794
          isurl: 0
4794
          isurl: 0
4795
          hidden: 0
4795
          hidden: 0
4796
          frameworkcode: ""
4796
          frameworkcode: ""
(-)a/installer/data/mysql/en/marcflavour/unimarc/mandatory/unimarc_framework_DEFAULT.yml (-2 / +1 lines)
Lines 3230-3236 tables: Link Here
3230
          tab: 0
3230
          tab: 0
3231
          authorised_value:
3231
          authorised_value:
3232
          authtypecode: ""
3232
          authtypecode: ""
3233
          value_builder: ""
3233
          value_builder: validate_issn.pl
3234
          isurl: 0
3234
          isurl: 0
3235
          hidden: 0
3235
          hidden: 0
3236
          frameworkcode: ""
3236
          frameworkcode: ""
3237
- 

Return to bug 41060