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

(-)a/C4/Circulation.pm (+2 lines)
Lines 58-63 use Koha::Config::SysPrefs; Link Here
58
use Koha::Charges::Fees;
58
use Koha::Charges::Fees;
59
use Koha::Util::SystemPreferences;
59
use Koha::Util::SystemPreferences;
60
use Koha::Checkouts::ReturnClaims;
60
use Koha::Checkouts::ReturnClaims;
61
use Koha::Plugins;
61
use Carp;
62
use Carp;
62
use List::MoreUtils qw( uniq any );
63
use List::MoreUtils qw( uniq any );
63
use Scalar::Util qw( looks_like_number );
64
use Scalar::Util qw( looks_like_number );
Lines 173-178 sub barcodedecode { Link Here
173
    my ($barcode, $filter) = @_;
174
    my ($barcode, $filter) = @_;
174
    my $branch = C4::Context::mybranch();
175
    my $branch = C4::Context::mybranch();
175
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
176
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
177
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode );
176
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
178
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
177
	if ($filter eq 'whitespace') {
179
	if ($filter eq 'whitespace') {
178
		$barcode =~ s/\s//g;
180
		$barcode =~ s/\s//g;
(-)a/C4/ILSDI/Services.pm (+2 lines)
Lines 34-39 use CGI qw ( -utf8 ); Link Here
34
use DateTime;
34
use DateTime;
35
use C4::Auth;
35
use C4::Auth;
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::Plugins;
37
38
38
use Koha::Biblios;
39
use Koha::Biblios;
39
use Koha::Checkouts;
40
use Koha::Checkouts;
Lines 613-618 sub GetServices { Link Here
613
    # Issuing management
614
    # Issuing management
614
    my $barcode = $item->barcode || '';
615
    my $barcode = $item->barcode || '';
615
    $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') );
616
    $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') );
617
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode );
616
    if ($barcode) {
618
    if ($barcode) {
617
        my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode );
619
        my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode );
618
620
(-)a/C4/Items.pm (+1 lines)
Lines 72-77 use Koha::ItemTypes; Link Here
72
use Koha::SearchEngine;
72
use Koha::SearchEngine;
73
use Koha::SearchEngine::Search;
73
use Koha::SearchEngine::Search;
74
use Koha::Libraries;
74
use Koha::Libraries;
75
use Koha::Plugins;
75
76
76
=head1 NAME
77
=head1 NAME
77
78
(-)a/Koha/Item.pm (+3 lines)
Lines 88-93 sub store { Link Here
88
        $self->itype($self->biblio->biblioitem->itemtype);
88
        $self->itype($self->biblio->biblioitem->itemtype);
89
    }
89
    }
90
90
91
    my ($transformed_barcode) = Koha::Plugins->call( 'barcode_transform', 'item', $self->barcode );
92
    $self->barcode($transformed_barcode);
93
91
    my $today = dt_from_string;
94
    my $today = dt_from_string;
92
    unless ( $self->in_storage ) { #AddItem
95
    unless ( $self->in_storage ) { #AddItem
93
        unless ( $self->permanent_location ) {
96
        unless ( $self->permanent_location ) {
(-)a/cataloguing/additem.pl (+4 lines)
Lines 35-40 use Koha::Items; Link Here
35
use Koha::ItemTypes;
35
use Koha::ItemTypes;
36
use Koha::Libraries;
36
use Koha::Libraries;
37
use Koha::Patrons;
37
use Koha::Patrons;
38
use Koha::Plugins;
38
use List::MoreUtils qw/any/;
39
use List::MoreUtils qw/any/;
39
use C4::Search;
40
use C4::Search;
40
use Storable qw(thaw freeze);
41
use Storable qw(thaw freeze);
Lines 506-511 if ($op eq "additem") { Link Here
506
507
507
    my $addedolditem = TransformMarcToKoha( $record );
508
    my $addedolditem = TransformMarcToKoha( $record );
508
509
510
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $addedolditem->{'barcode'} );
511
    $addedolditem->{'barcode'} = $new_barcode;
512
509
    # If we have to add or add & duplicate, we add the item
513
    # If we have to add or add & duplicate, we add the item
510
    if ( $add_submit || $add_duplicate_submit ) {
514
    if ( $add_submit || $add_duplicate_submit ) {
511
515
(-)a/circ/circulation.pl (+2 lines)
Lines 46-51 use Koha::AuthorisedValues; Link Here
46
use Koha::CsvProfiles;
46
use Koha::CsvProfiles;
47
use Koha::Patrons;
47
use Koha::Patrons;
48
use Koha::Patron::Debarments qw(GetDebarments);
48
use Koha::Patron::Debarments qw(GetDebarments);
49
use Koha::Plugins;
49
use Koha::DateUtils;
50
use Koha::DateUtils;
50
use Koha::Database;
51
use Koha::Database;
51
use Koha::BiblioFrameworks;
52
use Koha::BiblioFrameworks;
Lines 166-171 for my $barcode ( @$barcodes ) { Link Here
166
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
167
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
167
    $barcode = barcodedecode($barcode)
168
    $barcode = barcodedecode($barcode)
168
        if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
169
        if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
170
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode );
169
}
171
}
170
172
171
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
173
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
(-)a/circ/returns.pl (+3 lines)
Lines 56-61 use Koha::DateUtils; Link Here
56
use Koha::Holds;
56
use Koha::Holds;
57
use Koha::Items;
57
use Koha::Items;
58
use Koha::Patrons;
58
use Koha::Patrons;
59
use Koha::Plugins;
59
60
60
my $query = new CGI;
61
my $query = new CGI;
61
62
Lines 114-119 foreach ( $query->param ) { Link Here
114
115
115
    # decode barcode    ## Didn't we already decode them before passing them back last time??
116
    # decode barcode    ## Didn't we already decode them before passing them back last time??
116
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
117
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
118
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode );
117
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
119
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
118
120
119
    ######################
121
    ######################
Lines 246-251 if ($canceltransfer){ Link Here
246
my $returnbranch;
248
my $returnbranch;
247
if ($barcode) {
249
if ($barcode) {
248
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
250
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
251
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode );
249
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
252
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
250
    my $item = Koha::Items->find({ barcode => $barcode });
253
    my $item = Koha::Items->find({ barcode => $barcode });
251
254
(-)a/offline_circ/process_koc.pl (+9 lines)
Lines 38-43 use Koha::UploadedFiles; Link Here
38
use Koha::Account;
38
use Koha::Account;
39
use Koha::Checkouts;
39
use Koha::Checkouts;
40
use Koha::Patrons;
40
use Koha::Patrons;
41
use Koha::Plugins;
41
42
42
use Date::Calc qw( Add_Delta_Days Date_to_Days );
43
use Date::Calc qw( Add_Delta_Days Date_to_Days );
43
44
Lines 247-252 sub kocIssueItem { Link Here
247
    my $circ = shift;
248
    my $circ = shift;
248
249
249
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
250
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
251
252
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $circ->{barcode} );
253
    $circ->{barcode} = $new_barcode;
254
250
    my $branchcode = C4::Context->userenv->{branch};
255
    my $branchcode = C4::Context->userenv->{branch};
251
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
256
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
252
    my $borrower = $patron->unblessed;
257
    my $borrower = $patron->unblessed;
Lines 327-332 sub kocIssueItem { Link Here
327
sub kocReturnItem {
332
sub kocReturnItem {
328
    my ( $circ ) = @_;
333
    my ( $circ ) = @_;
329
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
334
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
335
336
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $circ->{barcode} );
337
    $circ->{barcode} = $new_barcode;
338
330
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
339
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
331
    my $biblio = $item->biblio;
340
    my $biblio = $item->biblio;
332
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
341
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
(-)a/opac/sco/sco-main.pl (+3 lines)
Lines 49-54 use Koha::Items; Link Here
49
use Koha::Patrons;
49
use Koha::Patrons;
50
use Koha::Patron::Images;
50
use Koha::Patron::Images;
51
use Koha::Patron::Messages;
51
use Koha::Patron::Messages;
52
use Koha::Plugins;
52
use Koha::Token;
53
use Koha::Token;
53
54
54
my $query = new CGI;
55
my $query = new CGI;
Lines 110-115 my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = Link Here
110
    $query->param("newissues")  || '',
111
    $query->param("newissues")  || '',
111
);
112
);
112
113
114
( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode );
115
113
my @newissueslist = split /,/, $newissues;
116
my @newissueslist = split /,/, $newissues;
114
my $issuenoconfirm = 1; #don't need to confirm on issue.
117
my $issuenoconfirm = 1; #don't need to confirm on issue.
115
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
118
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
(-)a/t/db_dependent/Koha/Plugins/Plugins.t (-1 / +3 lines)
Lines 25-31 use File::Temp qw( tempdir tempfile ); Link Here
25
use FindBin qw($Bin);
25
use FindBin qw($Bin);
26
use Module::Load::Conditional qw(can_load);
26
use Module::Load::Conditional qw(can_load);
27
use Test::MockModule;
27
use Test::MockModule;
28
use Test::More tests => 53;
28
use Test::More tests => 55;
29
29
30
use C4::Context;
30
use C4::Context;
31
use Koha::Database;
31
use Koha::Database;
Lines 181-186 ok( $plugin->can('opac_head'), 'Test plugin can opac_head' ); Link Here
181
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
181
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
182
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
182
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
183
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
183
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
184
ok( $plugin->can('barcode_transform'), 'Test plugin can barcode_transform' );
185
ok( $plugin->can('barcode_generate'), 'Test plugin can barcode_generate' );
184
ok( $plugin->can('configure'), 'Test plugin can configure' );
186
ok( $plugin->can('configure'), 'Test plugin can configure' );
185
ok( $plugin->can('install'), 'Test plugin can install' );
187
ok( $plugin->can('install'), 'Test plugin can install' );
186
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
188
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
(-)a/t/lib/Koha/Plugin/Test.pm (+9 lines)
Lines 93-98 sub intranet_js { Link Here
93
    return "Koha::Plugin::Test::intranet_js";
93
    return "Koha::Plugin::Test::intranet_js";
94
}
94
}
95
95
96
sub barcode_transform {
97
    my ( $self, $type, $barcode ) = @_;
98
    return "Koha::Plugin::Test::barcode_transform";
99
}
100
101
sub barcode_generate {
102
    my ( $self, $type, $object )
103
}
104
96
sub configure {
105
sub configure {
97
    my ( $self, $args ) = @_;
106
    my ( $self, $args ) = @_;
98
    return "Koha::Plugin::Test::configure";;
107
    return "Koha::Plugin::Test::configure";;
(-)a/tools/batchMod.pl (+4 lines)
Lines 44-49 use Koha::DateUtils; Link Here
44
use Koha::Items;
44
use Koha::Items;
45
use Koha::ItemTypes;
45
use Koha::ItemTypes;
46
use Koha::Patrons;
46
use Koha::Patrons;
47
use Koha::Plugins;
47
48
48
my $input = new CGI;
49
my $input = new CGI;
49
my $dbh = C4::Context->dbh;
50
my $dbh = C4::Context->dbh;
Lines 383-388 if ($op eq "show"){ Link Here
383
        if ( my $list = $input->param('barcodelist') ) {
384
        if ( my $list = $input->param('barcodelist') ) {
384
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
385
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
385
            @barcodelist = uniq @barcodelist;
386
            @barcodelist = uniq @barcodelist;
387
388
            @barcodelist = map { ( Koha::Plugins->call( 'barcode_transform', 'item', $_ ) )[0] } @barcodelist;
389
386
            # Note: adding lc for case insensitivity
390
            # Note: adding lc for case insensitivity
387
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
391
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
388
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
392
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
(-)a/tools/inventory.pl (-1 / +5 lines)
Lines 41-46 use Koha::AuthorisedValues; Link Here
41
use Koha::BiblioFrameworks;
41
use Koha::BiblioFrameworks;
42
use Koha::ClassSources;
42
use Koha::ClassSources;
43
use Koha::Items;
43
use Koha::Items;
44
use Koha::Plugins;
45
44
use List::MoreUtils qw( none );
46
use List::MoreUtils qw( none );
45
47
46
my $minlocation=$input->param('minlocation') || '';
48
my $minlocation=$input->param('minlocation') || '';
Lines 171-176 if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { Link Here
171
    }
173
    }
172
    for my $barcode (@uploadedbarcodes) {
174
    for my $barcode (@uploadedbarcodes) {
173
        next unless $barcode;
175
        next unless $barcode;
176
177
        ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode );
178
174
        ++$lines_read;
179
        ++$lines_read;
175
        if (length($barcode)>$barcode_size) {
180
        if (length($barcode)>$barcode_size) {
176
            $err_length += 1;
181
            $err_length += 1;
177
- 

Return to bug 26351