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

(-)a/C4/Circulation.pm (-7 / +9 lines)
Lines 62-79 use Koha::Config::SysPref; Link Here
62
use Koha::Checkouts::ReturnClaims;
62
use Koha::Checkouts::ReturnClaims;
63
use Koha::SearchEngine::Indexer;
63
use Koha::SearchEngine::Indexer;
64
use Koha::Exceptions::Checkout;
64
use Koha::Exceptions::Checkout;
65
use Koha::Plugins;
65
use Carp;
66
use Carp;
66
use List::MoreUtils qw( uniq any );
67
use List::MoreUtils qw( uniq any );
67
use Scalar::Util qw( looks_like_number );
68
use Scalar::Util qw( looks_like_number );
68
use Try::Tiny;
69
use Try::Tiny;
69
use Date::Calc qw(
70
use Date::Calc qw(
70
  Today
71
    Today
71
  Today_and_Now
72
    Today_and_Now
72
  Add_Delta_YM
73
    Add_Delta_YM
73
  Add_Delta_DHMS
74
    Add_Delta_DHMS
74
  Date_to_Days
75
    Date_to_Days
75
  Day_of_Week
76
    Day_of_Week
76
  Add_Delta_Days
77
    Add_Delta_Days
77
);
78
);
78
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
79
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
79
80
Lines 175-180 sub barcodedecode { Link Here
175
    my ($barcode, $filter) = @_;
176
    my ($barcode, $filter) = @_;
176
    my $branch = C4::Context::mybranch();
177
    my $branch = C4::Context::mybranch();
177
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
178
    $filter = C4::Context->preference('itemBarcodeInputFilter') unless $filter;
179
    ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
178
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
180
    $filter or return $barcode;     # ensure filter is defined, else return untouched barcode
179
	if ($filter eq 'whitespace') {
181
	if ($filter eq 'whitespace') {
180
		$barcode =~ s/\s//g;
182
		$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 72-77 use Koha::SearchEngine; Link Here
72
use Koha::SearchEngine::Indexer;
72
use Koha::SearchEngine::Indexer;
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 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 508-513 if ($op eq "additem") { Link Here
508
509
509
    my $addedolditem = TransformMarcToKoha( $record );
510
    my $addedolditem = TransformMarcToKoha( $record );
510
511
512
    my ( $new_barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $addedolditem->{'barcode'} ) || $addedolditem->{'barcode'};
513
    $addedolditem->{'barcode'} = $new_barcode;
514
511
    # If we have to add or add & duplicate, we add the item
515
    # If we have to add or add & duplicate, we add the item
512
    if ( $add_submit || $add_duplicate_submit ) {
516
    if ( $add_submit || $add_duplicate_submit ) {
513
517
(-)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 57-62 use Koha::Holds; Link Here
57
use Koha::Items;
57
use Koha::Items;
58
use Koha::Item::Transfers;
58
use Koha::Item::Transfers;
59
use Koha::Patrons;
59
use Koha::Patrons;
60
use Koha::Plugins;
60
61
61
my $query = CGI->new;
62
my $query = CGI->new;
62
63
Lines 115-120 foreach ( $query->param ) { Link Here
115
116
116
    # decode barcode    ## Didn't we already decode them before passing them back last time??
117
    # decode barcode    ## Didn't we already decode them before passing them back last time??
117
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
118
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
119
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
118
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
120
    $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter'));
119
121
120
    ######################
122
    ######################
Lines 249-254 if ($transit) { Link Here
249
my $returnbranch;
251
my $returnbranch;
250
if ($barcode) {
252
if ($barcode) {
251
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
253
    $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
254
    ( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
252
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
255
    $barcode = barcodedecode($barcode) if C4::Context->preference('itemBarcodeInputFilter');
253
    my $item = Koha::Items->find({ barcode => $barcode });
256
    my $item = Koha::Items->find({ barcode => $barcode });
254
257
(-)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 108-113 my ($op, $patronid, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = Link Here
108
    $query->param("newissues")  || '',
109
    $query->param("newissues")  || '',
109
);
110
);
110
111
112
( $barcode ) = Koha::Plugins->call( 'barcode_transform', 'item', $barcode ) || $barcode;
113
111
my @newissueslist = split /,/, $newissues;
114
my @newissueslist = split /,/, $newissues;
112
my $issuenoconfirm = 1; #don't need to confirm on issue.
115
my $issuenoconfirm = 1; #don't need to confirm on issue.
113
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
116
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 => 54;
28
use Test::More tests => 56;
29
29
30
use C4::Context;
30
use C4::Context;
31
use Koha::Database;
31
use Koha::Database;
Lines 211-216 ok( $plugin->can('opac_head'), 'Test plugin can opac_head' ); Link Here
211
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
211
ok( $plugin->can('opac_js'), 'Test plugin can opac_js' );
212
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
212
ok( $plugin->can('intranet_head'), 'Test plugin can intranet_head' );
213
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
213
ok( $plugin->can('intranet_js'), 'Test plugin can intranet_js' );
214
ok( $plugin->can('barcode_transform'), 'Test plugin can barcode_transform' );
215
ok( $plugin->can('barcode_generate'), 'Test plugin can barcode_generate' );
214
ok( $plugin->can('configure'), 'Test plugin can configure' );
216
ok( $plugin->can('configure'), 'Test plugin can configure' );
215
ok( $plugin->can('install'), 'Test plugin can install' );
217
ok( $plugin->can('install'), 'Test plugin can install' );
216
ok( $plugin->can('upgrade'), 'Test plugin can upgrade' );
218
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::Items; Link Here
44
use Koha::ItemTypes;
44
use Koha::ItemTypes;
45
use Koha::Patrons;
45
use Koha::Patrons;
46
use Koha::SearchEngine::Indexer;
46
use Koha::SearchEngine::Indexer;
47
use Koha::Plugins;
47
48
48
my $input = CGI->new;
49
my $input = CGI->new;
49
my $dbh = C4::Context->dbh;
50
my $dbh = C4::Context->dbh;
Lines 372-377 if ($op eq "show"){ Link Here
372
        if ( my $list = $input->param('barcodelist') ) {
373
        if ( my $list = $input->param('barcodelist') ) {
373
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
374
            my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list );
374
            @barcodelist = uniq @barcodelist;
375
            @barcodelist = uniq @barcodelist;
376
377
            @barcodelist = map { ( Koha::Plugins->call( 'barcode_transform', 'item', $_ ) )[0] || $_ } @barcodelist;
378
375
            # Note: adding lc for case insensitivity
379
            # Note: adding lc for case insensitivity
376
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
380
            my %itemdata = map { lc($_->{barcode}) => $_->{itemnumber} } @{ Koha::Items->search({ barcode => \@barcodelist }, { columns => [ 'itemnumber', 'barcode' ] } )->unblessed };
377
            @itemnumbers = map { exists $itemdata{lc $_} ? $itemdata{lc $_} : () } @barcodelist;
381
            @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 187-192 if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length Link Here
187
    }
189
    }
188
    for my $barcode (@uploadedbarcodes) {
190
    for my $barcode (@uploadedbarcodes) {
189
        next unless $barcode;
191
        next unless $barcode;
192
193
        ($barcode) = Koha::Plugins->call('barcode_transform', 'item', $barcode ) || $barcode;
194
190
        ++$lines_read;
195
        ++$lines_read;
191
        if (length($barcode)>$barcode_size) {
196
        if (length($barcode)>$barcode_size) {
192
            $err_length += 1;
197
            $err_length += 1;
193
- 

Return to bug 26351