Bug 17600: Standardize our EXPORT_OK
[srvgit] / C4 / Barcodes.pm
index b08d660..957d60f 100644 (file)
@@ -4,43 +4,32 @@ package C4::Barcodes;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
 
-use Carp;
+use Carp qw( carp );
 
 use C4::Context;
-use C4::Debug;
-use C4::Dates;
 use C4::Barcodes::hbyymmincr;
 use C4::Barcodes::annual;
 use C4::Barcodes::incremental;
 use C4::Barcodes::EAN13;
 
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-use vars qw($debug $cgi_debug);        # from C4::Debug, of course
 use vars qw($max $prefformat);
 
-BEGIN {
-    $VERSION = 3.07.00.049;
-       require Exporter;
-    @ISA = qw(Exporter);
-    @EXPORT_OK = qw();
-}
-
 sub _prefformat {
        unless (defined $prefformat) {
                unless ($prefformat = C4::Context->preference('autoBarcode')) {
@@ -75,11 +64,8 @@ sub value {
        my $self = shift;
        if (@_) {
                my $value = shift;
-               if (defined $value) {
-                       $debug and print STDERR "    setting barcode value to $value\n";
-               } else {
-                       warn "Error: UNDEF argument to value";
-               }
+        warn "Error: UNDEF argument to value"
+            unless defined $value;
                $self->{value} = $value;
        }
        return $self->{value};
@@ -98,16 +84,13 @@ sub parse { # return 3 parts of barcode: non-incrementing, incrementing, non-inc
                carp "Barcode '$barcode' has no incrementing part!";
                return ($barcode,undef,undef);
        }
-       $debug and warn "Barcode '$barcode' parses into: '$1', '$2', ''";
        return ($1,$2,'');      # the third part is in anticipation of barcodes that include checkdigits
 }
 sub max {
        my $self = shift;
        if ($self->{is_max}) {
-               $debug and print STDERR "max taken from Barcodes value $self->value\n";
                return $self->value;
        }
-       $debug and print STDERR "Retrieving max database query.\n";
        return $self->db_max;
 }
 sub db_max {
@@ -125,7 +108,6 @@ sub next_value {
                warn "No max barcode ($self->autoBarcode format) found.  Using initial value.";
                return $self->initial;
        }
-       $debug and print STDERR "(current) max barcode found: $max\n";
        my ($head,$incr,$tail) = $self->parse($max);    # for incremental, you'd get ('',the_whole_barcode,'')
        unless (defined $incr) {
                warn "No incrementing part of barcode ($max) returned by parse.";
@@ -133,15 +115,13 @@ sub next_value {
        }
        my $x = length($incr);          # number of digits
        $incr =~ /^9+$/ and $x++;       # if they're all 9's, we need an extra.
-               # Note, this enlargement might be undesireable for some barcode formats.
+        # Note, this enlargement might be undesirable for some barcode formats.
                # Those should override next_value() to work accordingly.
        $incr++;
 
-       $debug and warn "$incr";
        $head = $self->process_head($head,$max,$specific);
     $tail = $self->process_tail($tail,$incr,$specific); # XXX use $incr and not $max!
        my $next_value = $head . $incr . $tail;
-       $debug and print STDERR "(  next ) max barcode found: $next_value\n";
        return $next_value;
 }
 sub next {
@@ -185,9 +165,6 @@ sub new {
        my $class_or_object = shift;
        my $type = ref($class_or_object) || $class_or_object;
        my $from_obj = ref($class_or_object) ? 1 : 0;   # are we building off another Barcodes object?
-       if ($from_obj) {
-               $debug and print STDERR "Building new(@_) from old Barcodes object\n"; 
-       }
        my $autoBarcodeType = (@_) ? shift : $from_obj ? $class_or_object->autoBarcode : _prefformat;
        $autoBarcodeType =~ s/^.*:://;  # in case we get C4::Barcodes::incremental, we just want 'incremental'
        unless ($autoBarcodeType) {
@@ -198,7 +175,6 @@ sub new {
                carp "The autoBarcode format '$autoBarcodeType' is unrecognized.";
                return;
        }
-       carp "autoBarcode format = $autoBarcodeType" if $debug;
        my $self;
        if ($autoBarcodeType eq 'OFF') {
                $self = $class_or_object->default_self($autoBarcodeType);
@@ -209,7 +185,6 @@ sub new {
                $self = $class_or_object->new_object(@_);
                $self->serial($class_or_object->serial + 1);
                if ($class_or_object->is_max) {
-                       $debug and print STDERR "old object was max: ", $class_or_object->value, "\n";
                        $self->previous($class_or_object);
                        $class_or_object->next($self);
                        $self->value($self->next_value($class_or_object->value));
@@ -218,7 +193,6 @@ sub new {
                        $self->value($self->next_value);
                }
        } else {
-               $debug and print STDERR "trying to create new $autoBarcodeType\n";
                $self = &{$types->{$autoBarcodeType}} (@_);
                $self->value($self->next_value) and $self->is_max(1);
                $self->serial(1);