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

(-)a/C4/Circulation.pm (-7 / +9 lines)
Lines 63-80 use Koha::Config::SysPref; Link Here
63
use Koha::Checkouts::ReturnClaims;
63
use Koha::Checkouts::ReturnClaims;
64
use Koha::SearchEngine::Indexer;
64
use Koha::SearchEngine::Indexer;
65
use Koha::Exceptions::Checkout;
65
use Koha::Exceptions::Checkout;
66
use Koha::Plugins;
66
use Carp;
67
use Carp;
67
use List::MoreUtils qw( uniq any );
68
use List::MoreUtils qw( uniq any );
68
use Scalar::Util qw( looks_like_number );
69
use Scalar::Util qw( looks_like_number );
69
use Try::Tiny;
70
use Try::Tiny;
70
use Date::Calc qw(
71
use Date::Calc qw(
71
  Today
72
    Today
72
  Today_and_Now
73
    Today_and_Now
73
  Add_Delta_YM
74
    Add_Delta_YM
74
  Add_Delta_DHMS
75
    Add_Delta_DHMS
75
  Date_to_Days
76
    Date_to_Days
76
  Day_of_Week
77
    Day_of_Week
77
  Add_Delta_Days
78
    Add_Delta_Days
78
);
79
);
79
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
80
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
80
81
Lines 177-182 sub barcodedecode { Link Here
177
    my ($barcode, $filter) = @_;
178
    my ($barcode, $filter) = @_;
178
    my $branch = C4::Context::mybranch();
179
    my $branch = C4::Context::mybranch();
179
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
180
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
181
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
180
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
182
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
181
	if ($filter eq 'whitespace') {
183
	if ($filter eq 'whitespace') {
182
		$barcode =~ s/\s//g;
184
		$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 642-647 sub GetServices { Link Here
642
    # Issuing management
643
    # Issuing management
643
    my $barcode = $item->barcode || '';
644
    my $barcode = $item->barcode || '';
644
    $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') );
645
    $barcode = barcodedecode($barcode) if ( $barcode && C4::Context->preference('itemBarcodeInputFilter') );
646
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
645
    if ($barcode) {
647
    if ($barcode) {
646
        my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode );
648
        my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $barcode );
647
649
(-)a/C4/Items.pm (+1 lines)
Lines 74-79 use Koha::SearchEngine; Link Here
74
use Koha::SearchEngine::Indexer;
74
use Koha::SearchEngine::Indexer;
75
use Koha::SearchEngine::Search;
75
use Koha::SearchEngine::Search;
76
use Koha::Libraries;
76
use Koha::Libraries;
77
use Koha::Plugins;
77
78
78
=head1 NAME
79
=head1 NAME
79
80
(-)a/Koha/Item.pm (+3 lines)
Lines 90-95 sub store { Link Here
90
        $self->itype($self->biblio->biblioitem->itemtype);
90
        $self->itype($self->biblio->biblioitem->itemtype);
91
    }
91
    }
92
92
93
    my ($transformed_barcode) = Koha::Plugins->call( 'barcode_transform', 'item', $self->barcode ) || $self->barcode;
94
    $self->barcode($transformed_barcode);
95
93
    my $today  = dt_from_string;
96
    my $today  = dt_from_string;
94
    my $action = 'create';
97
    my $action = 'create';
95
98
(-)a/cataloguing/additem.pl (+4 lines)
Lines 36-41 use Koha::ItemTypes; Link Here
36
use Koha::Libraries;
36
use Koha::Libraries;
37
use Koha::Patrons;
37
use Koha::Patrons;
38
use Koha::SearchEngine::Indexer;
38
use Koha::SearchEngine::Indexer;
39
use Koha::Plugins;
39
use List::MoreUtils qw/any/;
40
use List::MoreUtils qw/any/;
40
use C4::Search;
41
use C4::Search;
41
use Storable qw(thaw freeze);
42
use Storable qw(thaw freeze);
Lines 509-514 if ($op eq "additem") { Link Here
509
510
510
    my $addedolditem = TransformMarcToKoha( $record );
511
    my $addedolditem = TransformMarcToKoha( $record );
511
512
513
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $addedolditem->{'barcode'} ) || $addedolditem->{'barcode'};
514
    $addedolditem->{'barcode'} = $new_barcode;
515
512
    # If we have to add or add & duplicate, we add the item
516
    # If we have to add or add & duplicate, we add the item
513
    if ( $add_submit || $add_duplicate_submit ) {
517
    if ( $add_submit || $add_duplicate_submit ) {
514
518
(-)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 165-170 for my $barcode ( @$barcodes ) { Link Here
165
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
166
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
166
    $barcode = barcodedecode($barcode)
167
    $barcode = barcodedecode($barcode)
167
        if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
168
        if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
169
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
168
}
170
}
169
171
170
my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
172
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 = CGI->new;
61
my $query = CGI->new;
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 ) || $barcode;
117
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
119
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
118
120
119
    ######################
121
    ######################
Lines 241-246 if ($canceltransfer){ Link Here
241
my $returnbranch;
243
my $returnbranch;
242
if ($barcode) {
244
if ($barcode) {
243
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
245
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
246
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
244
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
247
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
245
    my $item = Koha::Items->find({ barcode => $barcode });
248
    my $item = Koha::Items->find({ barcode => $barcode });
246
249
(-)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 246-251 sub kocIssueItem { Link Here
246
    my $circ = shift;
247
    my $circ = shift;
247
248
248
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
249
    $circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
250
251
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $circ->{barcode} ) || $circ->{barcode};
252
    $circ->{barcode} = $new_barcode;
253
249
    my $branchcode = C4::Context->userenv->{branch};
254
    my $branchcode = C4::Context->userenv->{branch};
250
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
255
    my $patron = Koha::Patrons->find( { cardnumber => $circ->{cardnumber} } );
251
    my $borrower = $patron->unblessed;
256
    my $borrower = $patron->unblessed;
Lines 326-331 sub kocIssueItem { Link Here
326
sub kocReturnItem {
331
sub kocReturnItem {
327
    my ( $circ ) = @_;
332
    my ( $circ ) = @_;
328
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
333
    $circ->{'barcode'} = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
334
335
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $circ->{barcode} ) || $circ->{barcode};
336
    $circ->{barcode} = $new_barcode;
337
329
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
338
    my $item = Koha::Items->find({ barcode => $circ->{barcode} });
330
    my $biblio = $item->biblio;
339
    my $biblio = $item->biblio;
331
    my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
340
    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 = CGI->new;
55
my $query = CGI->new;
Lines 109-114 my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = Link Here
109
    $query->param("newissues")  || '',
110
    $query->param("newissues")  || '',
110
);
111
);
111
112
113
( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
114
112
my @newissueslist = split /,/, $newissues;
115
my @newissueslist = split /,/, $newissues;
113
my $issuenoconfirm = 1; #don't need to confirm on issue.
116
my $issuenoconfirm = 1; #don't need to confirm on issue.
114
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
117
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 45-50 use Koha::Items; Link Here
45
use Koha::ItemTypes;
45
use Koha::ItemTypes;
46
use Koha::Patrons;
46
use Koha::Patrons;
47
use Koha::SearchEngine::Indexer;
47
use Koha::SearchEngine::Indexer;
48
use Koha::Plugins;
48
49
49
my $input = CGI->new;
50
my $input = CGI->new;
50
my $dbh = C4::Context->dbh;
51
my $dbh = C4::Context->dbh;
Lines 402-407 if ($op eq "show"){ Link Here
402
        if ( my $list = $input->param('barcodelist') ) {
403
        if ( my $list = $input->param('barcodelist') ) {
403
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
404
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
404
            @barcodelist = uniq @barcodelist;
405
            @barcodelist = uniq @barcodelist;
406
407
            @barcodelist = map { ( Koha::Plugins->call( 'barcode_transform', 'item', $_ ) )[0] || $_ } @barcodelist;
408
405
            # Note: adding lc for case insensitivity
409
            # Note: adding lc for case insensitivity
406
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
410
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
407
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
411
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
(-)a/tools/inventory.pl (-1 / +5 lines)
Lines 42-47 use Koha::AuthorisedValues; Link Here
42
use Koha::BiblioFrameworks;
42
use Koha::BiblioFrameworks;
43
use Koha::ClassSources;
43
use Koha::ClassSources;
44
use Koha::Items;
44
use Koha::Items;
45
use Koha::Plugins;
46
45
use List::MoreUtils qw( none );
47
use List::MoreUtils qw( none );
46
48
47
my $minlocation=$input->param('minlocation') || '';
49
my $minlocation=$input->param('minlocation') || '';
Lines 188-193 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
188
    }
190
    }
189
    for my $barcode (@uploadedbarcodes) {
191
    for my $barcode (@uploadedbarcodes) {
190
        next unless $barcode;
192
        next unless $barcode;
193
194
        ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
195
191
        ++$lines_read;
196
        ++$lines_read;
192
        if (length($barcode)>$barcode_size) {
197
        if (length($barcode)>$barcode_size) {
193
            $err_length += 1;
198
            $err_length += 1;
194
- 

Return to bug 26351