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

(-)a/t/perlcriticrc (+2 lines)
Lines 10-12 equivalent_modules = Modern::Perl Link Here
10
10
11
[TestingAndDebugging::RequireUseWarnings]
11
[TestingAndDebugging::RequireUseWarnings]
12
equivalent_modules = Modern::Perl
12
equivalent_modules = Modern::Perl
13
14
[-Modules::RequireBarewordIncludes]
(-)a/C4/Accounts.pm (-1 lines)
Lines 148-154 sub manualinvoice { Link Here
148
148
149
    my $manager_id = C4::Context->userenv ? C4::Context->userenv->{'number'} : undef;
149
    my $manager_id = C4::Context->userenv ? C4::Context->userenv->{'number'} : undef;
150
    my $dbh      = C4::Context->dbh;
150
    my $dbh      = C4::Context->dbh;
151
    my $insert;
152
    my $amountleft = $amount;
151
    my $amountleft = $amount;
153
152
154
    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
153
    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
(-)a/C4/Acquisition.pm (-1 lines)
Lines 2275-2281 sub GetHistory { Link Here
2275
    my $ordernumbers = $params{ordernumbers} || [];
2275
    my $ordernumbers = $params{ordernumbers} || [];
2276
    my $additional_fields = $params{additional_fields} // [];
2276
    my $additional_fields = $params{additional_fields} // [];
2277
2277
2278
    my @order_loop;
2279
    my $total_qty         = 0;
2278
    my $total_qty         = 0;
2280
    my $total_qtyreceived = 0;
2279
    my $total_qtyreceived = 0;
2281
    my $total_price       = 0;
2280
    my $total_price       = 0;
(-)a/C4/Auth_with_cas.pm (-9 / +9 lines)
Lines 257-275 sub logout_if_required { Link Here
257
    my $params = C4::Auth::_get_session_params();
257
    my $params = C4::Auth::_get_session_params();
258
    my $success = CGI::Session->find( $params->{dsn}, sub {delete_cas_session(@_, $ticket)}, $params->{dsn_args} );
258
    my $success = CGI::Session->find( $params->{dsn}, sub {delete_cas_session(@_, $ticket)}, $params->{dsn_args} );
259
259
260
    sub delete_cas_session {
261
        my $session = shift;
262
        my $ticket = shift;
263
        if ($session->param('cas_ticket') && $session->param('cas_ticket') eq $ticket ) {
264
            $session->delete;
265
            $session->flush;
266
        }
267
    }
268
269
    print $query->header;
260
    print $query->header;
270
    exit;
261
    exit;
271
}
262
}
272
263
264
sub delete_cas_session {
265
    my $session = shift;
266
    my $ticket = shift;
267
    if ($session->param('cas_ticket') && $session->param('cas_ticket') eq $ticket ) {
268
        $session->delete;
269
        $session->flush;
270
    }
271
}
272
273
1;
273
1;
274
__END__
274
__END__
275
275
(-)a/C4/AuthoritiesMarc.pm (-1 lines)
Lines 117-123 sub SearchAuthorities { Link Here
117
        # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
117
        # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
118
        # the authtypecode. Then, search on $a of this tag_to_report
118
        # the authtypecode. Then, search on $a of this tag_to_report
119
        # also store main entry MARC tag, to extract it at end of search
119
        # also store main entry MARC tag, to extract it at end of search
120
    my $mainentrytag;
121
    ##first set the authtype search and may be multiple authorities
120
    ##first set the authtype search and may be multiple authorities
122
    if ($authtypecode) {
121
    if ($authtypecode) {
123
        my $n=0;
122
        my $n=0;
(-)a/C4/Barcodes/ValueBuilder.pm (+2 lines)
Lines 19-24 Link Here
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
package C4::Barcodes::ValueBuilder::incremental;
21
package C4::Barcodes::ValueBuilder::incremental;
22
23
use Modern::Perl;
22
use C4::Context;
24
use C4::Context;
23
my $DEBUG = 0;
25
my $DEBUG = 0;
24
26
(-)a/C4/Barcodes/annual.pm (-4 / +4 lines)
Lines 36-42 BEGIN { Link Here
36
	$width = 4;
36
	$width = 4;
37
}
37
}
38
38
39
sub db_max ($;$) {
39
sub db_max {
40
	my $self = shift;
40
	my $self = shift;
41
	my $query = "SELECT substring_index(barcode,'-',-1) AS chunk,barcode FROM items WHERE barcode LIKE ? ORDER BY chunk DESC LIMIT 1";
41
	my $query = "SELECT substring_index(barcode,'-',-1) AS chunk,barcode FROM items WHERE barcode LIKE ? ORDER BY chunk DESC LIMIT 1";
42
		# FIXME: unreasonably expensive query on large datasets (I think removal of group by does this?)
42
		# FIXME: unreasonably expensive query on large datasets (I think removal of group by does this?)
Lines 64-70 sub initial () { Link Here
64
    return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1);
64
    return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) .'-'. sprintf('%'."$width.$width".'d', 1);
65
}
65
}
66
66
67
sub parse ($;$) {
67
sub parse {
68
	my $self = shift;
68
	my $self = shift;
69
    my $barcode = (@_) ? shift : $self->value;
69
    my $barcode = (@_) ? shift : $self->value;
70
	unless ($barcode =~ /(\d{4}-)(\d+)$/) {    # non-greedy match in first part
70
	unless ($barcode =~ /(\d{4}-)(\d+)$/) {    # non-greedy match in first part
Lines 74-85 sub parse ($;$) { Link Here
74
	$debug and warn "Barcode '$barcode' parses into: '$1', '$2', ''";
74
	$debug and warn "Barcode '$barcode' parses into: '$1', '$2', ''";
75
	return ($1,$2,'');  # the third part is in anticipation of barcodes that include checkdigits
75
	return ($1,$2,'');  # the third part is in anticipation of barcodes that include checkdigits
76
}
76
}
77
sub width ($;$) {
77
sub width {
78
	my $self = shift;
78
	my $self = shift;
79
	(@_) and $width = shift;	# hitting the class variable.
79
	(@_) and $width = shift;	# hitting the class variable.
80
	return $width;
80
	return $width;
81
}
81
}
82
sub process_head($$;$$) {	# (self,head,whole,specific)
82
sub process_head {
83
	my ($self,$head,$whole,$specific) = @_;
83
	my ($self,$head,$whole,$specific) = @_;
84
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
84
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
85
    return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY-
85
    return substr(output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 0, 4 ) . '-'; # else get new YYYY-
(-)a/C4/Biblio.pm (-1 lines)
Lines 2146-2152 sub TransformHtmlToXml { Link Here
2146
    # MARC::Record->new_from_xml will fail (and Koha will die)
2146
    # MARC::Record->new_from_xml will fail (and Koha will die)
2147
    my $unimarc_and_100_exist = 0;
2147
    my $unimarc_and_100_exist = 0;
2148
    $unimarc_and_100_exist = 1 if $auth_type eq 'ITEM';    # if we rebuild an item, no need of a 100 field
2148
    $unimarc_and_100_exist = 1 if $auth_type eq 'ITEM';    # if we rebuild an item, no need of a 100 field
2149
    my $prevvalue;
2150
    my $prevtag = -1;
2149
    my $prevtag = -1;
2151
    my $first   = 1;
2150
    my $first   = 1;
2152
    my $j       = -1;
2151
    my $j       = -1;
(-)a/C4/ClassSortRoutine.pm (-2 / +2 lines)
Lines 52-59 my @sort_routines = GetSortRoutineNames(); Link Here
52
foreach my $sort_routine (@sort_routines) {
52
foreach my $sort_routine (@sort_routines) {
53
    if (eval "require C4::ClassSortRoutine::$sort_routine") {
53
    if (eval "require C4::ClassSortRoutine::$sort_routine") {
54
        my $ref;
54
        my $ref;
55
        eval "\$ref = \\\&C4::ClassSortRoutine::${sort_routine}::get_class_sort_key";
55
        $ref = \&{"C4::ClassSortRoutine::${sort_routine}::get_class_sort_key"};
56
        if (eval "\$ref->(\"a\", \"b\")") {
56
        if (eval { $ref->("a", "b") }) {
57
            $loaded_routines{$sort_routine} = $ref;
57
            $loaded_routines{$sort_routine} = $ref;
58
        } else {
58
        } else {
59
            $loaded_routines{$sort_routine} = \&_get_class_sort_key;
59
            $loaded_routines{$sort_routine} = \&_get_class_sort_key;
(-)a/C4/ClassSplitRoutine/RegEx.pm (-1 / +1 lines)
Lines 43-49 sub split_callnumber { Link Here
43
    my ($cn_item, $regexs) = @_;
43
    my ($cn_item, $regexs) = @_;
44
44
45
    for my $regex ( @$regexs ) {
45
    for my $regex ( @$regexs ) {
46
        eval "\$cn_item =~ $regex";
46
        eval "\$cn_item =~ $regex"; ## no critic (StringyEval)
47
    }
47
    }
48
    my @lines = split "\n", $cn_item;
48
    my @lines = split "\n", $cn_item;
49
49
(-)a/C4/Context.pm (-2 lines)
Lines 248-254 sub new { Link Here
248
    }
248
    }
249
249
250
    my $conf_cache = Koha::Caches->get_instance('config');
250
    my $conf_cache = Koha::Caches->get_instance('config');
251
    my $config_from_cache;
252
    if ( $conf_cache->cache ) {
251
    if ( $conf_cache->cache ) {
253
        $self = $conf_cache->get_from_cache('koha_conf');
252
        $self = $conf_cache->get_from_cache('koha_conf');
254
    }
253
    }
Lines 695-701 sub dbh Link Here
695
{
694
{
696
    my $self = shift;
695
    my $self = shift;
697
    my $params = shift;
696
    my $params = shift;
698
    my $sth;
699
697
700
    unless ( $params->{new} ) {
698
    unless ( $params->{new} ) {
701
        return Koha::Database->schema->storage->dbh;
699
        return Koha::Database->schema->storage->dbh;
(-)a/C4/CourseReserves.pm (-1 / +1 lines)
Lines 84-90 sub GetCourse { Link Here
84
    warn whoami() . "( $course_id )" if $DEBUG;
84
    warn whoami() . "( $course_id )" if $DEBUG;
85
85
86
    my $course = Koha::Courses->find( $course_id );
86
    my $course = Koha::Courses->find( $course_id );
87
    return undef unless $course;
87
    return unless $course;
88
    $course = $course->unblessed;
88
    $course = $course->unblessed;
89
89
90
    my $dbh = C4::Context->dbh;
90
    my $dbh = C4::Context->dbh;
(-)a/C4/Creators.pm (+2 lines)
Lines 17-22 package C4::Creators; Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
21
20
BEGIN {
22
BEGIN {
21
    use vars qw(@EXPORT @ISA);
23
    use vars qw(@EXPORT @ISA);
22
    @ISA = qw(Exporter);
24
    @ISA = qw(Exporter);
(-)a/C4/Creators/Lib.pm (-1 / +1 lines)
Lines 527-533 be passed off as a template parameter and used to build an html table. Link Here
527
sub html_table {
527
sub html_table {
528
    my $headers = shift;
528
    my $headers = shift;
529
    my $data = shift;
529
    my $data = shift;
530
    return undef if scalar(@$data) == 0;      # no need to generate a table if there is not data to display
530
    return if scalar(@$data) == 0;      # no need to generate a table if there is not data to display
531
    my $table = [];
531
    my $table = [];
532
    my $fields = [];
532
    my $fields = [];
533
    my @table_columns = ();
533
    my @table_columns = ();
(-)a/C4/ImportBatch.pm (-6 / +6 lines)
Lines 1502-1511 sub RecordsFromISO2709File { Link Here
1502
    my $marc_type = C4::Context->preference('marcflavour');
1502
    my $marc_type = C4::Context->preference('marcflavour');
1503
    $marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth');
1503
    $marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth');
1504
1504
1505
    open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
1505
    open my $fh, '<', $input_file or die "$0: cannot open input file $input_file: $!\n";
1506
    my @marc_records;
1506
    my @marc_records;
1507
    $/ = "\035";
1507
    $/ = "\035";
1508
    while (<IN>) {
1508
    while (<$fh>) {
1509
        s/^\s+//;
1509
        s/^\s+//;
1510
        s/\s+$//;
1510
        s/\s+$//;
1511
        next unless $_; # skip if record has only whitespace, as might occur
1511
        next unless $_; # skip if record has only whitespace, as might occur
Lines 1517-1523 sub RecordsFromISO2709File { Link Here
1517
                "Unexpected charset $charset_guessed, expecting $encoding";
1517
                "Unexpected charset $charset_guessed, expecting $encoding";
1518
        }
1518
        }
1519
    }
1519
    }
1520
    close IN;
1520
    close $fh;
1521
    return ( \@errors, \@marc_records );
1521
    return ( \@errors, \@marc_records );
1522
}
1522
}
1523
1523
Lines 1560-1574 sub RecordsFromMarcPlugin { Link Here
1560
    return \@return if !$input_file || !$plugin_class;
1560
    return \@return if !$input_file || !$plugin_class;
1561
1561
1562
    # Read input file
1562
    # Read input file
1563
    open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
1563
    open my $fh, '<', $input_file or die "$0: cannot open input file $input_file: $!\n";
1564
    $/ = "\035";
1564
    $/ = "\035";
1565
    while (<IN>) {
1565
    while (<$fh>) {
1566
        s/^\s+//;
1566
        s/^\s+//;
1567
        s/\s+$//;
1567
        s/\s+$//;
1568
        next unless $_;
1568
        next unless $_;
1569
        $text .= $_;
1569
        $text .= $_;
1570
    }
1570
    }
1571
    close IN;
1571
    close $fh;
1572
1572
1573
    # Convert to large MARC blob with plugin
1573
    # Convert to large MARC blob with plugin
1574
    $text = Koha::Plugins::Handler->run({
1574
    $text = Koha::Plugins::Handler->run({
(-)a/C4/InstallAuth.pm (-1 lines)
Lines 270-276 sub checkauth { Link Here
270
            $loggedin = 1;
270
            $loggedin = 1;
271
            $userid   = $session->param('cardnumber');
271
            $userid   = $session->param('cardnumber');
272
        }
272
        }
273
        my ( $ip, $lasttime );
274
273
275
        if ($logout) {
274
        if ($logout) {
276
275
(-)a/C4/Items.pm (-1 lines)
Lines 224-230 Additional information appropriate to the error condition. Link Here
224
224
225
sub AddItemBatchFromMarc {
225
sub AddItemBatchFromMarc {
226
    my ($record, $biblionumber, $biblioitemnumber, $frameworkcode) = @_;
226
    my ($record, $biblionumber, $biblioitemnumber, $frameworkcode) = @_;
227
    my $error;
228
    my @itemnumbers = ();
227
    my @itemnumbers = ();
229
    my @errors = ();
228
    my @errors = ();
230
    my $dbh = C4::Context->dbh;
229
    my $dbh = C4::Context->dbh;
(-)a/C4/Labels.pm (+2 lines)
Lines 1-5 Link Here
1
package C4::Labels;
1
package C4::Labels;
2
2
3
use Modern::Perl;
4
3
BEGIN {
5
BEGIN {
4
6
5
    use C4::Labels::Batch;
7
    use C4::Labels::Batch;
(-)a/C4/Labels/Label.pm (-3 / +2 lines)
Lines 163-169 sub _get_barcode_data { Link Here
163
        }
163
        }
164
        elsif ( $f =~ /^([0-9a-z]{3})(\w)(\W?).*?/ ) {
164
        elsif ( $f =~ /^([0-9a-z]{3})(\w)(\W?).*?/ ) {
165
            my ($field,$subf,$ws) = ($1,$2,$3);
165
            my ($field,$subf,$ws) = ($1,$2,$3);
166
            my $subf_data;
167
            my ($itemtag, $itemsubfieldcode) = &GetMarcFromKohaField( "items.itemnumber" );
166
            my ($itemtag, $itemsubfieldcode) = &GetMarcFromKohaField( "items.itemnumber" );
168
            my @marcfield = $record->field($field);
167
            my @marcfield = $record->field($field);
169
            if(@marcfield) {
168
            if(@marcfield) {
Lines 313-320 sub create_label { Link Here
313
    my $label_text = '';
312
    my $label_text = '';
314
    my ($text_llx, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor);
313
    my ($text_llx, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor);
315
    {
314
    {
316
        no strict 'refs';
315
        my $sub = \&{'_' . $self->{printing_type}};
317
        ($text_llx, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor) = &{"_$self->{'printing_type'}"}($self); # an obfuscated call to the correct printing type sub
316
        ($text_llx, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor) = $sub->($self); # an obfuscated call to the correct printing type sub
318
    }
317
    }
319
    if ($self->{'printing_type'} =~ /BIB/) {
318
    if ($self->{'printing_type'} =~ /BIB/) {
320
        $label_text = draw_label_text(  $self,
319
        $label_text = draw_label_text(  $self,
(-)a/C4/Languages.pm (-3 / +1 lines)
Lines 344-351 sub _build_languages_arrayref { Link Here
344
        my @languages_loop; # the final reference to an array of hashrefs
344
        my @languages_loop; # the final reference to an array of hashrefs
345
        my @enabled_languages = @$enabled_languages;
345
        my @enabled_languages = @$enabled_languages;
346
        # how many languages are enabled, if one, take note, some contexts won't need to display it
346
        # how many languages are enabled, if one, take note, some contexts won't need to display it
347
        my %seen_languages; # the language tags we've seen
348
        my %found_languages;
349
        my $language_groups;
347
        my $language_groups;
350
        my $track_language_groups;
348
        my $track_language_groups;
351
        my $current_language_regex = regex_lang_subtags($current_language);
349
        my $current_language_regex = regex_lang_subtags($current_language);
Lines 585-591 sub accept_language { Link Here
585
    }
583
    }
586
    # No primary matches. Secondary? (ie, en-us requested and en supported)
584
    # No primary matches. Secondary? (ie, en-us requested and en supported)
587
    return $secondaryMatch if $secondaryMatch;
585
    return $secondaryMatch if $secondaryMatch;
588
    return undef;   # else, we got nothing.
586
    return;   # else, we got nothing.
589
}
587
}
590
588
591
=head2 getlanguage
589
=head2 getlanguage
(-)a/C4/Letters.pm (-1 lines)
Lines 313-319 sub SendAlerts { Link Here
313
          or warn( "No biblionumber for '$subscriptionid'" ),
313
          or warn( "No biblionumber for '$subscriptionid'" ),
314
             return;
314
             return;
315
315
316
        my %letter;
317
        # find the list of subscribers to notify
316
        # find the list of subscribers to notify
318
        my $subscription = Koha::Subscriptions->find( $subscriptionid );
317
        my $subscription = Koha::Subscriptions->find( $subscriptionid );
319
        my $subscribers = $subscription->subscribers;
318
        my $subscribers = $subscription->subscribers;
(-)a/C4/Matcher.pm (-1 / +1 lines)
Lines 165-171 sub fetch { Link Here
165
    $sth->execute($id);
165
    $sth->execute($id);
166
    my $row = $sth->fetchrow_hashref;
166
    my $row = $sth->fetchrow_hashref;
167
    $sth->finish();
167
    $sth->finish();
168
    return undef unless defined $row;
168
    return unless defined $row;
169
169
170
    my $self = {};
170
    my $self = {};
171
    $self->{'id'} = $row->{'matcher_id'};
171
    $self->{'id'} = $row->{'matcher_id'};
(-)a/C4/Members/Messaging.pm (-1 lines)
Lines 88-94 END_SQL Link Here
88
    my $sth = C4::Context->dbh->prepare($sql);
88
    my $sth = C4::Context->dbh->prepare($sql);
89
    $sth->execute(@bind_params);
89
    $sth->execute(@bind_params);
90
    my $return;
90
    my $return;
91
    my %transports; # helps build a list of unique message_transport_types
92
    ROW: while ( my $row = $sth->fetchrow_hashref() ) {
91
    ROW: while ( my $row = $sth->fetchrow_hashref() ) {
93
        next ROW unless $row->{'message_attribute_id'};
92
        next ROW unless $row->{'message_attribute_id'};
94
        $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
93
        $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
(-)a/C4/Patroncards.pm (+2 lines)
Lines 1-5 Link Here
1
package C4::Patroncards;
1
package C4::Patroncards;
2
2
3
use Modern::Perl;
4
3
BEGIN {
5
BEGIN {
4
    use vars qw(@EXPORT @ISA);
6
    use vars qw(@EXPORT @ISA);
5
    @ISA = qw(Exporter);
7
    @ISA = qw(Exporter);
(-)a/C4/Patroncards/Patroncard.pm (-3 / +5 lines)
Lines 227-237 sub draw_text { Link Here
227
                $parse_line = $2;
227
                $parse_line = $2;
228
            }
228
            }
229
            my $borrower_attributes = get_borrower_attributes($self->{'borrower_number'},@fields);
229
            my $borrower_attributes = get_borrower_attributes($self->{'borrower_number'},@fields);
230
            grep{ # substitute data for db fields
230
            @orig_line = map { # substitute data for db fields
231
                if ($_ =~ m/<([A-Za-z0-9_]+)>/) {
231
                my $l = $_;
232
                if ($l =~ m/<([A-Za-z0-9_]+)>/) {
232
                    my $field = $1;
233
                    my $field = $1;
233
                    $_ =~ s/$_/$borrower_attributes->{$field}/;
234
                    $l =~ s/$l/$borrower_attributes->{$field}/;
234
                }
235
                }
236
                $l;
235
            } @orig_line;
237
            } @orig_line;
236
            $line = join(' ',@orig_line);
238
            $line = join(' ',@orig_line);
237
        }
239
        }
(-)a/C4/Record.pm (-5 / +3 lines)
Lines 375-381 sub marc2endnote { Link Here
375
        Year => $marc_rec_obj->publication_date,
375
        Year => $marc_rec_obj->publication_date,
376
        Abstract => $abstract,
376
        Abstract => $abstract,
377
    };
377
    };
378
    my $endnote;
379
    my $style = new Biblio::EndnoteStyle();
378
    my $style = new Biblio::EndnoteStyle();
380
    my $template;
379
    my $template;
381
    $template.= "DB - DB\n" if C4::Context->preference("LibraryName");
380
    $template.= "DB - DB\n" if C4::Context->preference("LibraryName");
Lines 420-426 sub marc2csv { Link Here
420
    }
419
    }
421
420
422
    # Preprocessing
421
    # Preprocessing
423
    eval $preprocess if ($preprocess);
422
    eval $preprocess if ($preprocess); ## no critic (StringyEval)
424
423
425
    my $firstpass = 1;
424
    my $firstpass = 1;
426
    if ( @$itemnumbers ) {
425
    if ( @$itemnumbers ) {
Lines 438-444 sub marc2csv { Link Here
438
    }
437
    }
439
438
440
    # Postprocessing
439
    # Postprocessing
441
    eval $postprocess if ($postprocess);
440
    eval $postprocess if ($postprocess); ## no critic (StringyEval)
442
441
443
    return $output;
442
    return $output;
444
}
443
}
Lines 575-581 sub marcrecord2csv { Link Here
575
        if ( $content =~ m|\[\%.*\%\]| ) {
574
        if ( $content =~ m|\[\%.*\%\]| ) {
576
            my $tt = Template->new();
575
            my $tt = Template->new();
577
            my $template = $content;
576
            my $template = $content;
578
            my $vars;
579
            # Replace 00X and 0XX with X or XX
577
            # Replace 00X and 0XX with X or XX
580
            $content =~ s|fields.00(\d)|fields.$1|g;
578
            $content =~ s|fields.00(\d)|fields.$1|g;
581
            $content =~ s|fields.0(\d{2})|fields.$1|g;
579
            $content =~ s|fields.0(\d{2})|fields.$1|g;
Lines 624-630 sub marcrecord2csv { Link Here
624
                        # Field processing
622
                        # Field processing
625
                        my $marcfield = $tag->{fieldtag}; # This line fixes a retrocompatibility concern
623
                        my $marcfield = $tag->{fieldtag}; # This line fixes a retrocompatibility concern
626
                                                          # The "processing" could be based on the $marcfield variable.
624
                                                          # The "processing" could be based on the $marcfield variable.
627
                        eval $fieldprocessing if ($fieldprocessing);
625
                        eval $fieldprocessing if ($fieldprocessing); ## no critic (StringyEval)
628
626
629
                        push @loop_values, $value;
627
                        push @loop_values, $value;
630
                    }
628
                    }
(-)a/C4/Ris.pm (-1 lines)
Lines 90-96 C<$record> - a MARC::Record object Link Here
90
90
91
sub marc2ris {
91
sub marc2ris {
92
    my ($record) = @_;
92
    my ($record) = @_;
93
    my $output;
94
93
95
    my $marcflavour = C4::Context->preference("marcflavour");
94
    my $marcflavour = C4::Context->preference("marcflavour");
96
    my $intype = lc($marcflavour);
95
    my $intype = lc($marcflavour);
(-)a/C4/Search.pm (-5 lines)
Lines 87-95 sub FindDuplicate { Link Here
87
    my $result = TransformMarcToKoha( $record, '' );
87
    my $result = TransformMarcToKoha( $record, '' );
88
    my $sth;
88
    my $sth;
89
    my $query;
89
    my $query;
90
    my $search;
91
    my $type;
92
    my ( $biblionumber, $title );
93
90
94
    # search duplicate on ISBN, easy and fast..
91
    # search duplicate on ISBN, easy and fast..
95
    # ... normalize first
92
    # ... normalize first
Lines 309-315 sub getRecords { Link Here
309
    $offset = 0 if $offset < 0;
306
    $offset = 0 if $offset < 0;
310
307
311
    # Initialize variables for the ZOOM connection and results object
308
    # Initialize variables for the ZOOM connection and results object
312
    my $zconn;
313
    my @zconns;
309
    my @zconns;
314
    my @results;
310
    my @results;
315
    my $results_hashref = ();
311
    my $results_hashref = ();
Lines 428-434 sub getRecords { Link Here
428
                }
424
                }
429
425
430
                for ( my $j = $offset ; $j < $times ; $j++ ) {
426
                for ( my $j = $offset ; $j < $times ; $j++ ) {
431
                    my $records_hash;
432
                    my $record;
427
                    my $record;
433
428
434
                    ## Check if it's an index scan
429
                    ## Check if it's an index scan
(-)a/C4/Serials.pm (-9 / +12 lines)
Lines 324-333 sub GetFullSubscription { Link Here
324
    my $sth = $dbh->prepare($query);
324
    my $sth = $dbh->prepare($query);
325
    $sth->execute($subscriptionid);
325
    $sth->execute($subscriptionid);
326
    my $subscriptions = $sth->fetchall_arrayref( {} );
326
    my $subscriptions = $sth->fetchall_arrayref( {} );
327
    my $cannotedit = not can_edit_subscription( $subscriptions->[0] ) if scalar @$subscriptions;
327
    if (scalar @$subscriptions) {
328
    for my $subscription ( @$subscriptions ) {
328
        my $cannotedit = not can_edit_subscription( $subscriptions->[0] );
329
        $subscription->{cannotedit} = $cannotedit;
329
        for my $subscription ( @$subscriptions ) {
330
            $subscription->{cannotedit} = $cannotedit;
331
        }
330
    }
332
    }
333
331
    return $subscriptions;
334
    return $subscriptions;
332
}
335
}
333
336
Lines 347-355 sub PrepareSerialsData { Link Here
347
    my $year;
350
    my $year;
348
    my @res;
351
    my @res;
349
    my $startdate;
352
    my $startdate;
350
    my $aqbooksellername;
351
    my $bibliotitle;
352
    my @loopissues;
353
    my $first;
353
    my $first;
354
    my $previousnote = "";
354
    my $previousnote = "";
355
355
Lines 482-491 sub GetFullSubscriptionsFromBiblionumber { Link Here
482
    my $sth = $dbh->prepare($query);
482
    my $sth = $dbh->prepare($query);
483
    $sth->execute($biblionumber);
483
    $sth->execute($biblionumber);
484
    my $subscriptions = $sth->fetchall_arrayref( {} );
484
    my $subscriptions = $sth->fetchall_arrayref( {} );
485
    my $cannotedit = not can_edit_subscription( $subscriptions->[0] ) if scalar @$subscriptions;
485
    if (scalar @$subscriptions) {
486
    for my $subscription ( @$subscriptions ) {
486
        my $cannotedit = not can_edit_subscription( $subscriptions->[0] );
487
        $subscription->{cannotedit} = $cannotedit;
487
        for my $subscription ( @$subscriptions ) {
488
            $subscription->{cannotedit} = $cannotedit;
489
        }
488
    }
490
    }
491
489
    return $subscriptions;
492
    return $subscriptions;
490
}
493
}
491
494
(-)a/C4/Templates.pm (-1 / +1 lines)
Lines 118-124 sub output { Link Here
118
    $vars = { %$vars, %{ $self->{VARS} } };
118
    $vars = { %$vars, %{ $self->{VARS} } };
119
119
120
    my $data;
120
    my $data;
121
    binmode( STDOUT, ":utf8" );
121
    binmode( STDOUT, ":encoding(UTF-8)" );
122
    $template->process( $self->filename, $vars, \$data )
122
    $template->process( $self->filename, $vars, \$data )
123
      || die "Template process failed: ", $template->error();
123
      || die "Template process failed: ", $template->error();
124
    return $data;
124
    return $data;
(-)a/Makefile.PL (-3 / +3 lines)
Lines 888-895 sub get_install_log_values { Link Here
888
    my $install_log = shift;
888
    my $install_log = shift;
889
    my $values = shift;
889
    my $values = shift;
890
890
891
    open LOG, "<$install_log" or die "Cannot open install log $install_log: $!\n";
891
    open my $log, '<', $install_log or die "Cannot open install log $install_log: $!\n";
892
    while (<LOG>) {
892
    while (<$log>) {
893
        chomp;
893
        chomp;
894
        next if /^#/ or /^\s*$/;
894
        next if /^#/ or /^\s*$/;
895
        next if /^=/;
895
        next if /^=/;
Lines 898-904 sub get_install_log_values { Link Here
898
        my ($key, $value) = split /=/, $_, 2;
898
        my ($key, $value) = split /=/, $_, 2;
899
        $values->{$key} = $value;
899
        $values->{$key} = $value;
900
    }
900
    }
901
    close LOG;
901
    close $log;
902
902
903
    print <<_EXPLAIN_INSTALL_LOG_;
903
    print <<_EXPLAIN_INSTALL_LOG_;
904
Reading values from install log $install_log.  You
904
Reading values from install log $install_log.  You
(-)a/docs/CAS/CASProxy/examples/koha_webservice.pl (-1 / +1 lines)
Lines 33-39 The Proxy Ticket, needed for check_api_auth, that will try to make the CAS Serve Link Here
33
33
34
use utf8;
34
use utf8;
35
use Modern::Perl;
35
use Modern::Perl;
36
binmode(STDOUT, ":utf8");
36
binmode(STDOUT, ":encoding(UTF-8)");
37
37
38
use C4::Auth qw(check_api_auth);
38
use C4::Auth qw(check_api_auth);
39
use C4::Output;
39
use C4::Output;
(-)a/docs/CAS/CASProxy/examples/proxy_cas_callback.pl (-3 / +3 lines)
Lines 49-57 if ($cgi->param('pgtId')) { Link Here
49
49
50
    # Now we store the pgtIou and the pgtId in the application vars (in our case a storable object in a file), 
50
    # Now we store the pgtIou and the pgtId in the application vars (in our case a storable object in a file), 
51
    # so that the page requesting the webservice can retrieve the pgtId matching it's PgtIou 
51
    # so that the page requesting the webservice can retrieve the pgtId matching it's PgtIou 
52
    open FILE, ">", "casSession.tmp" or die "Unable to open file";
52
    open my $fh, ">", "casSession.tmp" or die "Unable to open file";
53
    nstore_fd({$pgtIou => $pgtId}, \*FILE);
53
    nstore_fd({$pgtIou => $pgtId}, $fh);
54
    close FILE;
54
    close $fh;
55
55
56
} else {
56
} else {
57
    warn "Failed to get a Proxy Ticket\n";
57
    warn "Failed to get a Proxy Ticket\n";
(-)a/docs/CAS/CASProxy/examples/proxy_cas_data.pl (-3 / +3 lines)
Lines 54-63 if ($cgi->param('PGTIOU')) { Link Here
54
      # At this point, we must retrieve the PgtId by matching the PgtIou we
54
      # At this point, we must retrieve the PgtId by matching the PgtIou we
55
      # just received and the PgtIou given by the CAS Server to the callback URL
55
      # just received and the PgtIou given by the CAS Server to the callback URL
56
      # The callback page stored it in the application vars (in our case a storable object in a file)
56
      # The callback page stored it in the application vars (in our case a storable object in a file)
57
      open FILE, "casSession.tmp" or die "Unable to open file";
57
      open my $fh, '<', "casSession.tmp" or die "Unable to open file";
58
      my $hashref = fd_retrieve(\*FILE);
58
      my $hashref = fd_retrieve($fh);
59
      my $pgtId = %{$hashref->{$cgi->param('PGTIOU')}};
59
      my $pgtId = %{$hashref->{$cgi->param('PGTIOU')}};
60
      close FILE;
60
      close $fh;
61
61
62
      # Now that we have a PgtId, we can ask the cas server for a proxy ticket...
62
      # Now that we have a PgtId, we can ask the cas server for a proxy ticket...
63
      my $rp = $cas->proxy( $pgtId, $target_service );
63
      my $rp = $cas->proxy( $pgtId, $target_service );
(-)a/fix-perl-path.PL (-2 / +2 lines)
Lines 77-84 sub fixshebang{ Link Here
77
            # to make it writable.  Note that stat and chmod
77
            # to make it writable.  Note that stat and chmod
78
            # (the Perl functions) should work on Win32
78
            # (the Perl functions) should work on Win32
79
            my $old_perm;
79
            my $old_perm;
80
            $old_perm = (stat $pathfile)[2] & 07777;
80
            $old_perm = (stat $pathfile)[2] & oct(7777);
81
            my $new_perm = $old_perm | 0200;
81
            my $new_perm = $old_perm | oct(200);
82
            chmod $new_perm, $pathfile;
82
            chmod $new_perm, $pathfile;
83
83
84
            # tie the file -- note that we're explicitly setting the line (record)
84
            # tie the file -- note that we're explicitly setting the line (record)
(-)a/installer/data/mysql/labels_upgrade.pl (+2 lines)
Lines 17-22 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
21
20
use C4::Context;
22
use C4::Context;
21
23
22
my $sth = C4::Context->dbh;
24
my $sth = C4::Context->dbh;
(-)a/installer/data/mysql/patroncards_upgrade.pl (+2 lines)
Lines 17-22 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
21
20
use C4::Context;
22
use C4::Context;
21
23
22
my $sth = C4::Context->dbh;
24
my $sth = C4::Context->dbh;
(-)a/installer/data/mysql/update22to30.pl (-9 / +7 lines)
Lines 35-41 my ( Link Here
35
    $table,
35
    $table,
36
    $column,
36
    $column,
37
    $type, $null, $key, $default, $extra,
37
    $type, $null, $key, $default, $extra,
38
    $prefitem,          # preference item in systempreferences table
39
);
38
);
40
39
41
my $silent;
40
my $silent;
Lines 3048-3054 my $DBversion = "3.00.00.000"; Link Here
3048
                             ],
3047
                             ],
3049
    );
3048
    );
3050
3049
3051
    foreach $table ( keys %required_prereq_fields ) {
3050
    foreach my $table ( keys %required_prereq_fields ) {
3052
        print "Check table $table\n" if $debug and not $silent;
3051
        print "Check table $table\n" if $debug and not $silent;
3053
        $sth = $dbh->prepare("show columns from $table");
3052
        $sth = $dbh->prepare("show columns from $table");
3054
        $sth->execute();
3053
        $sth->execute();
Lines 3157-3163 my $DBversion = "3.00.00.000"; Link Here
3157
    
3156
    
3158
    
3157
    
3159
    # Now add any missing tables
3158
    # Now add any missing tables
3160
    foreach $table ( keys %requiretables ) {
3159
    foreach my $table ( keys %requiretables ) {
3161
        unless ( $existingtables{$table} ) {
3160
        unless ( $existingtables{$table} ) {
3162
        print "Adding $table table...\n" unless $silent;
3161
        print "Adding $table table...\n" unless $silent;
3163
            my $sth = $dbh->prepare("create table $table $requiretables{$table} ENGINE=InnoDB DEFAULT CHARSET=utf8");
3162
            my $sth = $dbh->prepare("create table $table $requiretables{$table} ENGINE=InnoDB DEFAULT CHARSET=utf8");
Lines 3172-3178 my $DBversion = "3.00.00.000"; Link Here
3172
    #---------------------------------
3171
    #---------------------------------
3173
    # Columns
3172
    # Columns
3174
    
3173
    
3175
    foreach $table ( keys %requirefields ) {
3174
    foreach my $table ( keys %requirefields ) {
3176
        print "Check table $table\n" if $debug and not $silent;
3175
        print "Check table $table\n" if $debug and not $silent;
3177
        $sth = $dbh->prepare("show columns from $table");
3176
        $sth = $dbh->prepare("show columns from $table");
3178
        $sth->execute();
3177
        $sth->execute();
Lines 3181-3187 my $DBversion = "3.00.00.000"; Link Here
3181
        {
3180
        {
3182
            $types{$column} = $type;
3181
            $types{$column} = $type;
3183
        }    # while
3182
        }    # while
3184
        foreach $column ( keys %{ $requirefields{$table} } ) {
3183
        foreach my $column ( keys %{ $requirefields{$table} } ) {
3185
            print "  Check column $column  [$types{$column}]\n" if $debug and not $silent;
3184
            print "  Check column $column  [$types{$column}]\n" if $debug and not $silent;
3186
            if ( !$types{$column} ) {
3185
            if ( !$types{$column} ) {
3187
    
3186
    
Lines 3200-3206 my $DBversion = "3.00.00.000"; Link Here
3200
        }    # foreach column
3199
        }    # foreach column
3201
    }    # foreach table
3200
    }    # foreach table
3202
    
3201
    
3203
    foreach $table ( sort keys %fielddefinitions ) {
3202
    foreach my $table ( sort keys %fielddefinitions ) {
3204
        print "Check table $table\n" if $debug;
3203
        print "Check table $table\n" if $debug;
3205
        $sth = $dbh->prepare("show columns from $table");
3204
        $sth = $dbh->prepare("show columns from $table");
3206
        $sth->execute();
3205
        $sth->execute();
Lines 3454-3460 my $DBversion = "3.00.00.000"; Link Here
3454
        }
3453
        }
3455
    }
3454
    }
3456
    # now drop useless tables
3455
    # now drop useless tables
3457
    foreach $table ( @TableToDelete ) {
3456
    foreach my $table ( @TableToDelete ) {
3458
        if ( $existingtables{$table} ) {
3457
        if ( $existingtables{$table} ) {
3459
            print "Dropping unused table $table\n" if $debug and not $silent;
3458
            print "Dropping unused table $table\n" if $debug and not $silent;
3460
            $dbh->do("drop table $table");
3459
            $dbh->do("drop table $table");
Lines 3499-3507 my $DBversion = "3.00.00.000"; Link Here
3499
    }
3498
    }
3500
    
3499
    
3501
    # at last, remove useless fields
3500
    # at last, remove useless fields
3502
    foreach $table ( keys %uselessfields ) {
3501
    foreach my $table ( keys %uselessfields ) {
3503
        my @fields = split (/,/,$uselessfields{$table});
3502
        my @fields = split (/,/,$uselessfields{$table});
3504
        my $fields;
3505
        my $exists;
3503
        my $exists;
3506
        foreach my $fieldtodrop (@fields) {
3504
        foreach my $fieldtodrop (@fields) {
3507
            $fieldtodrop =~ s/\t//g;
3505
            $fieldtodrop =~ s/\t//g;
(-)a/installer/data/mysql/updatedatabase.pl (-7 / +3 lines)
Lines 53-66 use File::Slurp; Link Here
53
my $debug = 0;
53
my $debug = 0;
54
54
55
my (
55
my (
56
    $sth, $sti,
56
    $sth,
57
    $query,
57
    $query,
58
    %existingtables,    # tables already in database
59
    %types,
60
    $table,
58
    $table,
61
    $column,
59
    $type,
62
    $type, $null, $key, $default, $extra,
63
    $prefitem,          # preference item in systempreferences table
64
);
60
);
65
61
66
my $schema = Koha::Database->new()->schema();
62
my $schema = Koha::Database->new()->schema();
Lines 21850-21856 foreach my $file ( sort readdir $dirh ) { Link Here
21850
        my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
21846
        my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
21851
    } elsif ( $file =~ /\.perl$/ ) {
21847
    } elsif ( $file =~ /\.perl$/ ) {
21852
        my $code = read_file( $update_dir . $file );
21848
        my $code = read_file( $update_dir . $file );
21853
        eval $code;
21849
        eval $code; ## no critic (StringyEval)
21854
        say "Atomic update generated errors: $@" if $@;
21850
        say "Atomic update generated errors: $@" if $@;
21855
    }
21851
    }
21856
}
21852
}
(-)a/installer/externalmodules.pl (-3 / +3 lines)
Lines 12-20 qx(grep -r "^ *use" $dir | grep -v "C4\|strict\|vars" >/tmp/modulesKoha.log); Link Here
12
$dir=C4::Context->config('opacdir');
12
$dir=C4::Context->config('opacdir');
13
qx(grep -r "^ *use" $dir | grep -v "C4\|strict\|vars" >>/tmp/modulesKoha.log);
13
qx(grep -r "^ *use" $dir | grep -v "C4\|strict\|vars" >>/tmp/modulesKoha.log);
14
14
15
open FILE, "< /tmp/modulesKoha.log" ||die "unable to open file /tmp/modulesKoha.log";
15
open my $fh, '<', '/tmp/modulesKoha.log' ||die "unable to open file /tmp/modulesKoha.log";
16
my %modulehash;
16
my %modulehash;
17
while (my $line=<FILE>){
17
while (my $line=<$fh>){
18
  if ( $line=~m#(.*)\:\s*use\s+([A-Z][^\s;]+)# ){
18
  if ( $line=~m#(.*)\:\s*use\s+([A-Z][^\s;]+)# ){
19
    my ($file,$module)=($1,$2);
19
    my ($file,$module)=($1,$2);
20
    my @filename = split /\//, $file;
20
    my @filename = split /\//, $file;
Lines 23-27 while (my $line=<FILE>){ Link Here
23
}
23
}
24
print "external modules used in Koha ARE :\n";
24
print "external modules used in Koha ARE :\n";
25
map {print "* $_ \t in files ",join (",",@{$modulehash{$_}}),"\n" } sort keys %modulehash;
25
map {print "* $_ \t in files ",join (",",@{$modulehash{$_}}),"\n" } sort keys %modulehash;
26
close FILE;
26
close $fh;
27
unlink "/tmp/modulesKoha.log";
27
unlink "/tmp/modulesKoha.log";
(-)a/installer/install.pl (-1 / +1 lines)
Lines 403-409 elsif ( $step && $step == 3 ) { Link Here
403
        close $fh;
403
        close $fh;
404
        if (@report) {
404
        if (@report) {
405
            $template->param( update_report =>
405
            $template->param( update_report =>
406
                  [ map { local $_ = $_; $_ =~ s/\t/&emsp;&emsp;/g; { line => $_ } } split( /\n/, join( '', @report ) ) ]
406
                  [ map { { line => $_ =~ s/\t/&emsp;&emsp;/gr } } split( /\n/, join( '', @report ) ) ]
407
            );
407
            );
408
            $template->param( has_update_succeeds => 1 );
408
            $template->param( has_update_succeeds => 1 );
409
        }
409
        }
(-)a/misc/admin/koha-preferences (+1 lines)
Lines 18-23 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
19
#
20
20
21
use Modern::Perl;
21
use Koha::Script;
22
use Koha::Script;
22
use C4::Boolean;
23
use C4::Boolean;
23
use C4::Context;
24
use C4::Context;
(-)a/misc/batchRepairMissingBiblionumbers.pl (-1 lines)
Lines 18-24 use C4::Biblio; Link Here
18
18
19
19
20
my $dbh = C4::Context->dbh;
20
my $dbh = C4::Context->dbh;
21
my %kohafields;
22
21
23
my $sth=$dbh->prepare("SELECT biblio.biblionumber, biblioitemnumber, frameworkcode FROM biblio JOIN biblioitems USING (biblionumber)");
22
my $sth=$dbh->prepare("SELECT biblio.biblionumber, biblioitemnumber, frameworkcode FROM biblio JOIN biblioitems USING (biblionumber)");
24
$sth->execute();
23
$sth->execute();
(-)a/misc/batchdeletebiblios.pl (-1 / +1 lines)
Lines 8-14 use IO::File; Link Here
8
use Koha::Script;
8
use Koha::Script;
9
use C4::Biblio;
9
use C4::Biblio;
10
10
11
my ($help, $files);
11
my $help;
12
GetOptions(
12
GetOptions(
13
    'h|help' => \$help,
13
    'h|help' => \$help,
14
);
14
);
(-)a/misc/bin/connexion_import_daemon.pl (+1 lines)
Lines 132-137 sub parse_config { Link Here
132
        die "Invalid config line $line: $_" unless defined $v;
132
        die "Invalid config line $line: $_" unless defined $v;
133
        $param{$p} = $v;
133
        $param{$p} = $v;
134
    }
134
    }
135
    close($conf_fh);
135
136
136
    $self->{koha} = delete( $param{koha} )
137
    $self->{koha} = delete( $param{koha} )
137
      or die "No koha base url in config file";
138
      or die "No koha base url in config file";
(-)a/misc/check_sysprefs.pl (-3 / +3 lines)
Lines 22-29 sub check_sys_pref { Link Here
22
    if ( !-d _ ) {
22
    if ( !-d _ ) {
23
        my $name = $File::Find::name;
23
        my $name = $File::Find::name;
24
        if ( $name =~ /(\.pl|\.pm)$/ ) {
24
        if ( $name =~ /(\.pl|\.pm)$/ ) {
25
            open( FILE, "$_" ) || die "can't open $name";
25
            open( my $fh, '<', $_ ) || die "can't open $name";
26
            while ( my $inp = <FILE> ) {
26
            while ( my $inp = <$fh> ) {
27
                if ( $inp =~ /C4::Context->preference\((.*?)\)/ ) {
27
                if ( $inp =~ /C4::Context->preference\((.*?)\)/ ) {
28
                    my $variable = $1;
28
                    my $variable = $1;
29
                    $variable =~ s /\'|\"//g;
29
                    $variable =~ s /\'|\"//g;
Lines 37-43 sub check_sys_pref { Link Here
37
"$name has a reference to $variable, this does not exist in the database\n";
37
"$name has a reference to $variable, this does not exist in the database\n";
38
                }
38
                }
39
            }
39
            }
40
            close FILE;
40
            close $fh;
41
        }
41
        }
42
    }
42
    }
43
    $sth->finish();
43
    $sth->finish();
(-)a/misc/cronjobs/build_browser_and_cloud.pl (-1 / +1 lines)
Lines 22-28 use Getopt::Long; Link Here
22
use C4::Log;
22
use C4::Log;
23
23
24
my ( $input_marc_file, $number) = ('',0);
24
my ( $input_marc_file, $number) = ('',0);
25
my ($version, $confirm,$test_parameter,$field,$batch,$max_digits,$cloud_tag);
25
my ($version, $confirm,$field,$batch,$max_digits,$cloud_tag);
26
GetOptions(
26
GetOptions(
27
	'c' => \$confirm,
27
	'c' => \$confirm,
28
	'h' => \$version,
28
	'h' => \$version,
(-)a/misc/cronjobs/gather_print_notices.pl (-2 / +1 lines)
Lines 25-31 use Koha::Util::OpenDocument; Link Here
25
use MIME::Lite;
25
use MIME::Lite;
26
26
27
my (
27
my (
28
    $stylesheet,
29
    $help,
28
    $help,
30
    $split,
29
    $split,
31
    $html,
30
    $html,
Lines 231-237 sub generate_csv { Link Here
231
230
232
    open my $OUTPUT, '>encoding(utf-8)', $filepath
231
    open my $OUTPUT, '>encoding(utf-8)', $filepath
233
        or die "Could not open $filepath: $!";
232
        or die "Could not open $filepath: $!";
234
    my ( @csv_lines, $headers );
233
    my $headers;
235
    foreach my $message ( @$messages ) {
234
    foreach my $message ( @$messages ) {
236
        my @lines = split /\n/, $message->{content};
235
        my @lines = split /\n/, $message->{content};
237
        chomp for @lines;
236
        chomp for @lines;
(-)a/misc/cronjobs/holds/cancel_expired_holds.pl (-2 / +1 lines)
Lines 17-24 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
#use strict;
20
use Modern::Perl;
21
#use warnings; FIXME - Bug 2505
22
21
23
BEGIN {
22
BEGIN {
24
    # find Koha's Perl modules
23
    # find Koha's Perl modules
(-)a/misc/cronjobs/longoverdue.pl (-3 / +3 lines)
Lines 275-281 cronlogaction(); Link Here
275
# In my opinion, this line is safe SQL to have outside the API. --atz
275
# In my opinion, this line is safe SQL to have outside the API. --atz
276
our $bounds_sth = C4::Context->dbh->prepare("SELECT DATE_SUB(CURDATE(), INTERVAL ? DAY)");
276
our $bounds_sth = C4::Context->dbh->prepare("SELECT DATE_SUB(CURDATE(), INTERVAL ? DAY)");
277
277
278
sub bounds ($) {
278
sub bounds {
279
    $bounds_sth->execute(shift);
279
    $bounds_sth->execute(shift);
280
    return $bounds_sth->fetchrow;
280
    return $bounds_sth->fetchrow;
281
}
281
}
Lines 408-417 foreach my $startrange (sort keys %$lost) { Link Here
408
    $endrange = $startrange;
408
    $endrange = $startrange;
409
}
409
}
410
410
411
sub summarize ($$) {
411
sub summarize {
412
    my $arg = shift;    # ref to array
412
    my $arg = shift;    # ref to array
413
    my $got_items = shift || 0;     # print "count" line for items
413
    my $got_items = shift || 0;     # print "count" line for items
414
    my @report = @$arg or return undef;
414
    my @report = @$arg or return;
415
    my $i = 0;
415
    my $i = 0;
416
    for my $range (@report) {
416
    for my $range (@report) {
417
        printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i,
417
        printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i,
(-)a/misc/cronjobs/rss/rss.pl (-3 / +3 lines)
Lines 74-81 sub getConf { Link Here
74
    my %return;
74
    my %return;
75
    my $inSection = 0;
75
    my $inSection = 0;
76
76
77
    open( FILE, $file ) or die "can't open $file";
77
    open( my $fh, '<', $file ) or die "can't open $file";
78
    while (<FILE>) {
78
    while (<$fh>) {
79
        if ($inSection) {
79
        if ($inSection) {
80
            my @line = split( /=/, $_, 2 );
80
            my @line = split( /=/, $_, 2 );
81
            unless ( $line[1] ) {
81
            unless ( $line[1] ) {
Lines 91-97 sub getConf { Link Here
91
            if ( $_ eq "$section\n" ) { $inSection = 1 }
91
            if ( $_ eq "$section\n" ) { $inSection = 1 }
92
        }
92
        }
93
    }
93
    }
94
    close FILE;
94
    close $fh;
95
    return %return;
95
    return %return;
96
}
96
}
97
97
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl (+1 lines)
Lines 77-82 if ( defined $infile ) { Link Here
77
        $updated += $result;
77
        $updated += $result;
78
        $total++;
78
        $total++;
79
    }
79
    }
80
    close($IN);
80
}
81
}
81
else {
82
else {
82
    die pod2usage( -verbose => 1 );
83
    die pod2usage( -verbose => 1 );
(-)a/misc/cronjobs/update_totalissues.pl (-1 / +1 lines)
Lines 72-78 my $result = GetOptions( Link Here
72
    'h|help'       => \$want_help
72
    'h|help'       => \$want_help
73
);
73
);
74
74
75
binmode( STDOUT, ":utf8" );
75
binmode( STDOUT, ":encoding(UTF-8)" );
76
76
77
if ( defined $since && defined $interval ) {
77
if ( defined $since && defined $interval ) {
78
    print "The --since and --interval options are mutually exclusive.\n\n";
78
    print "The --since and --interval options are mutually exclusive.\n\n";
(-)a/misc/exportauth.pl (-3 / +3 lines)
Lines 17-23 use C4::Context; Link Here
17
use C4::Biblio;
17
use C4::Biblio;
18
use C4::Auth;
18
use C4::Auth;
19
my $outfile = $ARGV[0];
19
my $outfile = $ARGV[0];
20
open(OUT,">$outfile") or die $!;
20
open(my $fh, '>', $outfile) or die $!;
21
my $dbh=C4::Context->dbh;
21
my $dbh=C4::Context->dbh;
22
#$dbh->do("set character_set_client='latin5'"); 
22
#$dbh->do("set character_set_client='latin5'"); 
23
$dbh->do("set character_set_connection='utf8'");
23
$dbh->do("set character_set_connection='utf8'");
Lines 25-30 $dbh->do("set character_set_connection='utf8'"); Link Here
25
my $sth=$dbh->prepare("select marc from auth_header order by authid");
25
my $sth=$dbh->prepare("select marc from auth_header order by authid");
26
$sth->execute();
26
$sth->execute();
27
while (my ($marc) = $sth->fetchrow) {
27
while (my ($marc) = $sth->fetchrow) {
28
    print OUT $marc;
28
    print $fh $marc;
29
 }
29
 }
30
close(OUT);
30
close($fh);
(-)a/misc/link_bibs_to_authorities.pl (-1 / +1 lines)
Lines 47-53 my $result = GetOptions( Link Here
47
    'h|help'         => \$want_help
47
    'h|help'         => \$want_help
48
);
48
);
49
49
50
binmode( STDOUT, ":utf8" );
50
binmode( STDOUT, ":encoding(UTF-8)" );
51
51
52
if ( not $result or $want_help ) {
52
if ( not $result or $want_help ) {
53
    usage();
53
    usage();
(-)a/misc/maintenance/cmp_sysprefs.pl (-1 / +1 lines)
Lines 34-40 use Koha::Script; Link Here
34
use C4::Context;
34
use C4::Context;
35
my $dbh = C4::Context->dbh;
35
my $dbh = C4::Context->dbh;
36
36
37
my ( $help, $cmd, $filename, $override, $compare_add, $compare_del, $compare_upd, $ignore_opt, $partial );
37
my ( $help, $cmd, $filename, $compare_add, $compare_del, $compare_upd, $ignore_opt, $partial );
38
GetOptions(
38
GetOptions(
39
    'help'    => \$help,
39
    'help'    => \$help,
40
    'cmd:s'   => \$cmd,
40
    'cmd:s'   => \$cmd,
(-)a/misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl (-1 lines)
Lines 76-82 $query = Link Here
76
"SELECT * FROM accountlines WHERE description LIKE ? AND description NOT LIKE ?";
76
"SELECT * FROM accountlines WHERE description LIKE ? AND description NOT LIKE ?";
77
$sth = $dbh->prepare($query);
77
$sth = $dbh->prepare($query);
78
78
79
my @fines;
80
foreach my $keeper (@$results) {
79
foreach my $keeper (@$results) {
81
80
82
    warn "WORKING ON KEEPER: " . Data::Dumper::Dumper( $keeper );
81
    warn "WORKING ON KEEPER: " . Data::Dumper::Dumper( $keeper );
(-)a/misc/maintenance/touch_all_biblios.pl (-4 / +6 lines)
Lines 69-78 if ($whereclause) { Link Here
69
}
69
}
70
70
71
# output log or STDOUT
71
# output log or STDOUT
72
my $fh;
72
if (defined $outfile) {
73
if (defined $outfile) {
73
   open (OUT, ">$outfile") || die ("Cannot open output file");
74
   open ($fh, '>', $outfile) || die ("Cannot open output file");
74
} else {
75
} else {
75
   open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
76
   open($fh, '>&', \*STDOUT) || die ("Couldn't duplicate STDOUT: $!");
76
}
77
}
77
78
78
my $sth1 = $dbh->prepare("SELECT biblionumber, frameworkcode FROM biblio $whereclause");
79
my $sth1 = $dbh->prepare("SELECT biblionumber, frameworkcode FROM biblio $whereclause");
Lines 86-100 while (my ($biblionumber, $frameworkcode) = $sth1->fetchrow_array){ Link Here
86
87
87
  if ($modok) {
88
  if ($modok) {
88
     $goodcount++;
89
     $goodcount++;
89
     print OUT "Touched biblio $biblionumber\n" if (defined $verbose);
90
     print $fh "Touched biblio $biblionumber\n" if (defined $verbose);
90
  } else {
91
  } else {
91
     $badcount++;
92
     $badcount++;
92
     print OUT "ERROR WITH BIBLIO $biblionumber !!!!\n";
93
     print $fh "ERROR WITH BIBLIO $biblionumber !!!!\n";
93
  }
94
  }
94
95
95
  $totalcount++;
96
  $totalcount++;
96
97
97
}
98
}
99
close($fh);
98
100
99
# Benchmarking
101
# Benchmarking
100
my $endtime = time();
102
my $endtime = time();
(-)a/misc/maintenance/touch_all_items.pl (-4 / +6 lines)
Lines 70-79 if ($whereclause) { Link Here
70
}
70
}
71
71
72
# output log or STDOUT
72
# output log or STDOUT
73
my $fh;
73
if (defined $outfile) {
74
if (defined $outfile) {
74
   open (OUT, ">$outfile") || die ("Cannot open output file");
75
   open ($fh, '>', $outfile) || die ("Cannot open output file");
75
} else {
76
} else {
76
   open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
77
   open($fh, '>&', \*STDOUT) || die ("Couldn't duplicate STDOUT: $!");
77
}
78
}
78
79
79
# FIXME Would be better to call Koha::Items->search here
80
# FIXME Would be better to call Koha::Items->search here
Lines 88-102 while (my ($biblionumber, $itemnumber, $itemcallnumber) = $sth_fetch->fetchrow_a Link Here
88
89
89
  if ($modok) {
90
  if ($modok) {
90
     $goodcount++;
91
     $goodcount++;
91
     print OUT "Touched item $itemnumber\n" if (defined $verbose);
92
     print $fh "Touched item $itemnumber\n" if (defined $verbose);
92
  } else {
93
  } else {
93
     $badcount++;
94
     $badcount++;
94
     print OUT "ERROR WITH ITEM $itemnumber !!!!\n";
95
     print $fh "ERROR WITH ITEM $itemnumber !!!!\n";
95
  }
96
  }
96
97
97
  $totalcount++;
98
  $totalcount++;
98
99
99
}
100
}
101
close($fh);
100
102
101
# Benchmarking
103
# Benchmarking
102
my $endtime = time();
104
my $endtime = time();
(-)a/misc/migration_tools/22_to_30/export_Authorities.pl (-3 / +2 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#use strict;
2
use Modern::Perl;
3
#use warnings; FIXME - Bug 2505
4
BEGIN {
3
BEGIN {
5
    # find Koha's Perl modules
4
    # find Koha's Perl modules
6
    # test carefully before changing this
5
    # test carefully before changing this
Lines 32-38 while (my ($authid,$authtypecode)=$rq->fetchrow){ Link Here
32
  
31
  
33
  if (C4::Context->preference('marcflavour') eq "UNIMARC"){
32
  if (C4::Context->preference('marcflavour') eq "UNIMARC"){
34
	$record->leader('     nac  22     1u 4500');
33
	$record->leader('     nac  22     1u 4500');
35
    my $string=$1 if $time=~m/([0-9\-]+)/;
34
    my $string= ($time=~m/([0-9\-]+)/) ? $1 : undef
36
    $string=~s/\-//g;
35
    $string=~s/\-//g;
37
     $string = sprintf("%-*s",26, $string);
36
     $string = sprintf("%-*s",26, $string);
38
     substr($string,9,6,"frey50");
37
     substr($string,9,6,"frey50");
(-)a/misc/migration_tools/22_to_30/export_Authorities_xml.pl (-3 / +2 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#use strict;
2
use Modern::Perl;
3
#use warnings; FIXME - Bug 2505
4
BEGIN {
3
BEGIN {
5
    # find Koha's Perl modules
4
    # find Koha's Perl modules
6
    # test carefully before changing this
5
    # test carefully before changing this
Lines 31-37 open my $fileoutput, '>:encoding(UTF-8)', "./$filename/$authid.xml" or die "unab Link Here
31
			
30
			
32
#  if (C4::Context->preference('marcflavour') eq "UNIMARC"){
31
#  if (C4::Context->preference('marcflavour') eq "UNIMARC"){
33
	$record->leader('     nac  22     1u 4500');
32
	$record->leader('     nac  22     1u 4500');
34
    my $string=$1 if $time=~m/([0-9\-]+)/;
33
    my $string = ($time=~m/([0-9\-]+)/) ? $1 : undef
35
    $string=~s/\-//g;
34
    $string=~s/\-//g;
36
     $string = sprintf("%-*s",26, $string);
35
     $string = sprintf("%-*s",26, $string);
37
     substr($string,9,6,"frey50");
36
     substr($string,9,6,"frey50");
(-)a/misc/migration_tools/22_to_30/move_marc_to_biblioitems.pl (-2 / +1 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#use strict;
2
use Modern::Perl;
3
#use warnings; FIXME - Bug 2505
4
# script to shift marc to biblioitems
3
# script to shift marc to biblioitems
5
# scraped from updatedatabase for dev week by chris@katipo.co.nz
4
# scraped from updatedatabase for dev week by chris@katipo.co.nz
6
BEGIN {
5
BEGIN {
(-)a/misc/migration_tools/buildCOUNTRY.pl (-1 / +1 lines)
Lines 14-20 use Time::HiRes qw(gettimeofday); Link Here
14
14
15
use Getopt::Long;
15
use Getopt::Long;
16
my ( $fields, $number,$language) = ('',0);
16
my ( $fields, $number,$language) = ('',0);
17
my ($version, $verbose, $test_parameter, $field,$delete,$subfields);
17
my ($version, $verbose, $test_parameter, $delete);
18
GetOptions(
18
GetOptions(
19
    'h' => \$version,
19
    'h' => \$version,
20
    'd' => \$delete,
20
    'd' => \$delete,
(-)a/misc/migration_tools/buildEDITORS.pl (-1 lines)
Lines 67-73 my $starttime = gettimeofday; Link Here
67
my $sth = $dbh->prepare("select bibid from marc_biblio");
67
my $sth = $dbh->prepare("select bibid from marc_biblio");
68
$sth->execute;
68
$sth->execute;
69
my $i=1;
69
my $i=1;
70
my %alreadydone;
71
my $counter;
70
my $counter;
72
my %hash;
71
my %hash;
73
while (my ($bibid) = $sth->fetchrow) {
72
while (my ($bibid) = $sth->fetchrow) {
(-)a/misc/migration_tools/buildLANG.pl (-1 / +1 lines)
Lines 14-20 use Time::HiRes qw(gettimeofday); Link Here
14
14
15
use Getopt::Long;
15
use Getopt::Long;
16
my ( $fields, $number,$language) = ('',0);
16
my ( $fields, $number,$language) = ('',0);
17
my ($version, $verbose, $test_parameter, $field,$delete,$subfields);
17
my ($version, $verbose, $test_parameter, $delete);
18
GetOptions(
18
GetOptions(
19
    'h' => \$version,
19
    'h' => \$version,
20
    'd' => \$delete,
20
    'd' => \$delete,
(-)a/misc/migration_tools/bulkmarcimport.pl (-3 / +4 lines)
Lines 147-154 if($marc_mod_template ne '') { Link Here
147
my $dbh = C4::Context->dbh;
147
my $dbh = C4::Context->dbh;
148
my $heading_fields=get_heading_fields();
148
my $heading_fields=get_heading_fields();
149
149
150
my $idmapfh;
150
if (defined $idmapfl) {
151
if (defined $idmapfl) {
151
  open(IDMAP,">$idmapfl") or die "cannot open $idmapfl \n";
152
  open($idmapfh, '>', $idmapfl) or die "cannot open $idmapfl \n";
152
}
153
}
153
154
154
if ((not defined $sourcesubfield) && (not defined $sourcetag)){
155
if ((not defined $sourcesubfield) && (not defined $sourcetag)){
Lines 441-451 RECORD: while ( ) { Link Here
441
			 	if ($sourcetag < "010"){
442
			 	if ($sourcetag < "010"){
442
					if ($record->field($sourcetag)){
443
					if ($record->field($sourcetag)){
443
					  my $source = $record->field($sourcetag)->data();
444
					  my $source = $record->field($sourcetag)->data();
444
					  printf(IDMAP "%s|%s\n",$source,$biblionumber);
445
					  printf($idmapfh "%s|%s\n",$source,$biblionumber);
445
					}
446
					}
446
			    } else {
447
			    } else {
447
					my $source=$record->subfield($sourcetag,$sourcesubfield);
448
					my $source=$record->subfield($sourcetag,$sourcesubfield);
448
					printf(IDMAP "%s|%s\n",$source,$biblionumber);
449
					printf($idmapfh "%s|%s\n",$source,$biblionumber);
449
			  }
450
			  }
450
			}
451
			}
451
					# create biblio, unless we already have it ( either match or isbn )
452
					# create biblio, unless we already have it ( either match or isbn )
(-)a/misc/migration_tools/remove_unused_authorities.pl (-1 lines)
Lines 71-77 unless ($nb > 0) { Link Here
71
}
71
}
72
72
73
my $dbh=C4::Context->dbh;
73
my $dbh=C4::Context->dbh;
74
my @results;
75
# prepare the request to retrieve all authorities of the requested types
74
# prepare the request to retrieve all authorities of the requested types
76
my $rqsql = q{ SELECT authid,authtypecode FROM auth_header };
75
my $rqsql = q{ SELECT authid,authtypecode FROM auth_header };
77
$rqsql .= q{ WHERE authtypecode IN (}.join(',',map{ '?' }@authtypes).')' if @authtypes;
76
$rqsql .= q{ WHERE authtypecode IN (}.join(',',map{ '?' }@authtypes).')' if @authtypes;
(-)a/misc/perlmodule_rm.pl (-1 / +1 lines)
Lines 2-8 Link Here
2
2
3
# Remove a perl module
3
# Remove a perl module
4
4
5
use warnings;
5
use Modern::Perl;
6
use ExtUtils::Packlist;
6
use ExtUtils::Packlist;
7
use ExtUtils::Installed;
7
use ExtUtils::Installed;
8
8
(-)a/misc/translator/LangInstaller.pm (-1 / +1 lines)
Lines 1087-1093 sub get_all_langs { Link Here
1087
    opendir( my $dh, $self->{path_po} );
1087
    opendir( my $dh, $self->{path_po} );
1088
    my @files = grep { $_ =~ /-pref.(po|po.gz)$/ }
1088
    my @files = grep { $_ =~ /-pref.(po|po.gz)$/ }
1089
        readdir $dh;
1089
        readdir $dh;
1090
    @files = map { $_ =~ s/-pref.(po|po.gz)$//; $_ } @files;
1090
    @files = map { $_ =~ s/-pref.(po|po.gz)$//r } @files;
1091
}
1091
}
1092
1092
1093
1093
(-)a/misc/translator/TmplTokenizer.pm (-28 / +28 lines)
Lines 138-144 BEGIN { Link Here
138
sub parenleft  () { '(' }
138
sub parenleft  () { '(' }
139
sub parenright () { ')' }
139
sub parenright () { ')' }
140
140
141
sub _split_js ($) {
141
sub _split_js {
142
    my ($s0) = @_;
142
    my ($s0) = @_;
143
    my @it = ();
143
    my @it = ();
144
    while (length $s0) {
144
    while (length $s0) {
Lines 190-196 sub STATE_STRING_LITERAL () { 3 } Link Here
190
190
191
# XXX This is a crazy hack. I don't want to write an ECMAScript parser.
191
# XXX This is a crazy hack. I don't want to write an ECMAScript parser.
192
# XXX A scanner is one thing; a parser another thing.
192
# XXX A scanner is one thing; a parser another thing.
193
sub _identify_js_translatables (@) {
193
sub _identify_js_translatables {
194
    my @input = @_;
194
    my @input = @_;
195
    my @output = ();
195
    my @output = ();
196
    # We mark a JavaScript translatable string as in C, i.e., _("literal")
196
    # We mark a JavaScript translatable string as in C, i.e., _("literal")
Lines 227-233 sub _identify_js_translatables (@) { Link Here
227
227
228
###############################################################################
228
###############################################################################
229
229
230
sub string_canon ($) {
230
sub string_canon {
231
  my $s = shift;
231
  my $s = shift;
232
  # Fold all whitespace into single blanks
232
  # Fold all whitespace into single blanks
233
  $s =~ s/\s+/ /g;
233
  $s =~ s/\s+/ /g;
Lines 236-242 sub string_canon ($) { Link Here
236
}
236
}
237
237
238
# safer version used internally, preserves new lines
238
# safer version used internally, preserves new lines
239
sub string_canon_safe ($) {
239
sub string_canon_safe {
240
  my $s = shift;
240
  my $s = shift;
241
  # fold tabs and spaces into single spaces
241
  # fold tabs and spaces into single spaces
242
  $s =~ s/[\ \t]+/ /gs;
242
  $s =~ s/[\ \t]+/ /gs;
Lines 252-258 sub _quote_cformat{ Link Here
252
252
253
sub _formalize_string_cformat{
253
sub _formalize_string_cformat{
254
  my $s = shift;
254
  my $s = shift;
255
  return _quote_cformat( string_canon_safe $s );
255
  return _quote_cformat( string_canon_safe($s) );
256
}
256
}
257
257
258
sub _formalize{
258
sub _formalize{
Lines 314-320 sub next_token { Link Here
314
                return $self->_parametrize_internal(@parts);
314
                return $self->_parametrize_internal(@parts);
315
            }
315
            }
316
            else {
316
            else {
317
                return undef;
317
                return;
318
            }
318
            }
319
        }
319
        }
320
        # if cformat mode is off, dont bother parametrizing, just return them as they come
320
        # if cformat mode is off, dont bother parametrizing, just return them as they come
Lines 337-343 sub next_token { Link Here
337
                 push @tail, $3;
337
                 push @tail, $3;
338
                $s0 = $2;
338
                $s0 = $2;
339
            }
339
            }
340
            push @head, _split_js $s0;
340
            push @head, _split_js($s0);
341
            $next->set_js_data(_identify_js_translatables(@head, @tail) );
341
            $next->set_js_data(_identify_js_translatables(@head, @tail) );
342
	    return $next unless @parts;	    
342
	    return $next unless @parts;	    
343
	    $self->{_parser}->unshift_token($next);
343
	    $self->{_parser}->unshift_token($next);
Lines 359-365 sub next_token { Link Here
359
359
360
# function taken from old version
360
# function taken from old version
361
# used by tmpl_process3
361
# used by tmpl_process3
362
sub parametrize ($$$$) {
362
sub parametrize {
363
    my($fmt_0, $cformat_p, $t, $f) = @_;
363
    my($fmt_0, $cformat_p, $t, $f) = @_;
364
    my $it = '';
364
    my $it = '';
365
    if ($cformat_p) {
365
    if ($cformat_p) {
Lines 379-391 sub parametrize ($$$$) { Link Here
379
		    ;
379
		    ;
380
		} elsif (defined $params[$i - 1]) {
380
		} elsif (defined $params[$i - 1]) {
381
		    my $param = $params[$i - 1];
381
		    my $param = $params[$i - 1];
382
		    warn_normal "$fmt_0: $&: Expected a TMPL_VAR, but found a "
382
		    warn_normal("$fmt_0: $&: Expected a TMPL_VAR, but found a "
383
			    . $param->type->to_string . "\n", undef
383
			    . $param->type->to_string . "\n", undef)
384
			    if $param->type != C4::TmplTokenType::DIRECTIVE;
384
			    if $param->type != C4::TmplTokenType::DIRECTIVE;
385
		    warn_normal "$fmt_0: $&: Unsupported "
385
		    warn_normal("$fmt_0: $&: Unsupported "
386
				. "field width or precision\n", undef
386
				. "field width or precision\n", undef)
387
			    if defined $width || defined $prec;
387
			    if defined $width || defined $prec;
388
		    warn_normal "$fmt_0: $&: Parameter $i not known", undef
388
		    warn_normal("$fmt_0: $&: Parameter $i not known", undef)
389
			    unless defined $param;
389
			    unless defined $param;
390
		    $it .= defined $f? &$f( $param ): $param->string;
390
		    $it .= defined $f? &$f( $param ): $param->string;
391
		}
391
		}
Lines 396-422 sub parametrize ($$$$) { Link Here
396
396
397
		my $param = $params[$i - 1];
397
		my $param = $params[$i - 1];
398
		if (!defined $param) {
398
		if (!defined $param) {
399
		    warn_normal "$fmt_0: $&: Parameter $i not known", undef;
399
		    warn_normal("$fmt_0: $&: Parameter $i not known", undef);
400
		} else {
400
		} else {
401
		    if ($param->type == C4::TmplTokenType::TAG
401
		    if ($param->type == C4::TmplTokenType::TAG
402
			    && $param->string =~ /^<input\b/is) {
402
			    && $param->string =~ /^<input\b/is) {
403
			my $type = defined $param->attributes?
403
			my $type = defined $param->attributes?
404
				lc($param->attributes->{'type'}->[1]): undef;
404
				lc($param->attributes->{'type'}->[1]): undef;
405
			if ($conv eq 'S') {
405
			if ($conv eq 'S') {
406
			    warn_normal "$fmt_0: $&: Expected type=text, "
406
			    warn_normal("$fmt_0: $&: Expected type=text, "
407
					. "but found type=$type", undef
407
					. "but found type=$type", undef)
408
				    unless $type eq 'text';
408
				    unless $type eq 'text';
409
			} elsif ($conv eq 'p') {
409
			} elsif ($conv eq 'p') {
410
			    warn_normal "$fmt_0: $&: Expected type=radio, "
410
			    warn_normal("$fmt_0: $&: Expected type=radio, "
411
					. "but found type=$type", undef
411
					. "but found type=$type", undef)
412
				    unless $type eq 'radio';
412
				    unless $type eq 'radio';
413
			}
413
			}
414
		    } else {
414
		    } else {
415
			warn_normal "$&: Expected an INPUT, but found a "
415
			warn_normal("$&: Expected an INPUT, but found a "
416
				. $param->type->to_string . "\n", undef
416
				. $param->type->to_string . "\n", undef)
417
		    }
417
		    }
418
		    warn_normal "$fmt_0: $&: Unsupported "
418
		    warn_normal("$fmt_0: $&: Unsupported "
419
				. "field width or precision\n", undef
419
				. "field width or precision\n", undef)
420
			    if defined $width || defined $prec;
420
			    if defined $width || defined $prec;
421
		    $it .= defined $f? &$f( $param ): $param->string;
421
		    $it .= defined $f? &$f( $param ): $param->string;
422
		}
422
		}
Lines 439-445 sub parametrize ($$$$) { Link Here
439
	    my $i  = $1;
439
	    my $i  = $1;
440
	    $fmt = $';
440
	    $fmt = $';
441
	    my $anchor = $anchors[$i - 1];
441
	    my $anchor = $anchors[$i - 1];
442
	    warn_normal "$&: Anchor $1 not found for msgid \"$fmt_0\"", undef #FIXME
442
	    warn_normal("$&: Anchor $1 not found for msgid \"$fmt_0\"", undef) #FIXME
443
		    unless defined $anchor;
443
		    unless defined $anchor;
444
	    $it .= $anchor->string;
444
	    $it .= $anchor->string;
445
	} else {
445
	} else {
Lines 452-463 sub parametrize ($$$$) { Link Here
452
452
453
# Other simple functions (These are not methods)
453
# Other simple functions (These are not methods)
454
454
455
sub blank_p ($) {
455
sub blank_p {
456
    my($s) = @_;
456
    my($s) = @_;
457
    return $s =~ /^(?:\s|\&nbsp$re_end_entity|$re_tmpl_var|$re_xsl)*$/osi;
457
    return $s =~ /^(?:\s|\&nbsp$re_end_entity|$re_tmpl_var|$re_xsl)*$/osi;
458
}
458
}
459
459
460
sub trim ($) {
460
sub trim {
461
    my($s0) = @_;
461
    my($s0) = @_;
462
    my $l0 = length $s0;
462
    my $l0 = length $s0;
463
    my $s = $s0;
463
    my $s = $s0;
Lines 466-472 sub trim ($) { Link Here
466
    return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s;
466
    return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s;
467
}
467
}
468
468
469
sub quote_po ($) {
469
sub quote_po {
470
    my($s) = @_;
470
    my($s) = @_;
471
    # Locale::PO->quote is buggy, it doesn't quote newlines :-/
471
    # Locale::PO->quote is buggy, it doesn't quote newlines :-/
472
    $s =~ s/([\\"])/\\$1/gs;
472
    $s =~ s/([\\"])/\\$1/gs;
Lines 475-481 sub quote_po ($) { Link Here
475
    return "\"$s\"";
475
    return "\"$s\"";
476
}
476
}
477
477
478
sub charset_canon ($) {
478
sub charset_canon {
479
    my($charset) = @_;
479
    my($charset) = @_;
480
    $charset = uc($charset);
480
    $charset = uc($charset);
481
    $charset = "$1-$2" if $charset =~ /^(ISO|UTF)(\d.*)/i;
481
    $charset = "$1-$2" if $charset =~ /^(ISO|UTF)(\d.*)/i;
Lines 508-514 use vars qw( @latin1_utf8 ); Link Here
508
    "\303\270", "\303\271", "\303\272", "\303\273", "\303\274", "\303\275",
508
    "\303\270", "\303\271", "\303\272", "\303\273", "\303\274", "\303\275",
509
    "\303\276", "\303\277" );
509
    "\303\276", "\303\277" );
510
510
511
sub charset_convert ($$$) {
511
sub charset_convert {
512
    my($s, $charset_in, $charset_out) = @_;
512
    my($s, $charset_in, $charset_out) = @_;
513
    if ($s !~ /[\200-\377]/s) { # FIXME: don't worry about iso2022 for now
513
    if ($s !~ /[\200-\377]/s) { # FIXME: don't worry about iso2022 for now
514
	;
514
	;
(-)a/misc/translator/VerboseWarnings.pm (-12 / +12 lines)
Lines 40-71 verbose warnings. Link Here
40
use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag $quiet);
40
use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag $quiet);
41
use vars qw( $warned $erred );
41
use vars qw( $warned $erred );
42
42
43
sub set_application_name ($) {
43
sub set_application_name {
44
    my($s) = @_;
44
    my($s) = @_;
45
    $appName = $& if !defined $appName && $s =~ /[^\/]+$/;
45
    $appName = $& if !defined $appName && $s =~ /[^\/]+$/;
46
}
46
}
47
47
48
sub application_name () {
48
sub application_name {
49
    return $appName;
49
    return $appName;
50
}
50
}
51
51
52
sub set_input_file_name ($) {
52
sub set_input_file_name {
53
    my($s) = @_;
53
    my($s) = @_;
54
    $input = $s;
54
    $input = $s;
55
    $input_abbr = $& if defined $s && $s =~ /[^\/]+$/;
55
    $input_abbr = $& if defined $s && $s =~ /[^\/]+$/;
56
}
56
}
57
57
58
sub set_pedantic_mode ($) {
58
sub set_pedantic_mode {
59
    my($p) = @_;
59
    my($p) = @_;
60
    $pedantic_p = $p;
60
    $pedantic_p = $p;
61
    $pedantic_tag = $pedantic_p? '': ' (negligible)';
61
    $pedantic_tag = $pedantic_p? '': ' (negligible)';
62
}
62
}
63
63
64
sub pedantic_p () {
64
sub pedantic_p {
65
    return $pedantic_p;
65
    return $pedantic_p;
66
}
66
}
67
67
68
sub construct_warn_prefix ($$) {
68
sub construct_warn_prefix {
69
    my($prefix, $lc) = @_;
69
    my($prefix, $lc) = @_;
70
    die "construct_warn_prefix called before set_application_name"
70
    die "construct_warn_prefix called before set_application_name"
71
	    unless defined $appName;
71
	    unless defined $appName;
Lines 80-99 sub construct_warn_prefix ($$) { Link Here
80
    return "$appName: $prefix: " . (defined $lc? "$input_abbr: line $lc: ": defined $input_abbr? "$input_abbr: ": '');
80
    return "$appName: $prefix: " . (defined $lc? "$input_abbr: line $lc: ": defined $input_abbr? "$input_abbr: ": '');
81
}
81
}
82
82
83
sub warn_additional ($$) {
83
sub warn_additional {
84
    my($msg, $lc) = @_;
84
    my($msg, $lc) = @_;
85
    my $prefix = construct_warn_prefix('Warning', $lc);
85
    my $prefix = construct_warn_prefix('Warning', $lc);
86
    $msg .= "\n" unless $msg =~ /\n$/s;
86
    $msg .= "\n" unless $msg =~ /\n$/s;
87
    warn "$prefix$msg";
87
    warn "$prefix$msg";
88
}
88
}
89
89
90
sub warn_normal ($$) {
90
sub warn_normal {
91
    my($msg, $lc) = @_;
91
    my($msg, $lc) = @_;
92
    $warned += 1;
92
    $warned += 1;
93
    warn_additional($msg, $lc);
93
    warn_additional($msg, $lc);
94
}
94
}
95
95
96
sub warn_pedantic ($$$) {
96
sub warn_pedantic {
97
    my($msg, $lc, $flag) = @_;
97
    my($msg, $lc, $flag) = @_;
98
    my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
98
    my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
99
    $msg .= "\n" unless $msg =~ /\n$/s;
99
    $msg .= "\n" unless $msg =~ /\n$/s;
Lines 106-125 sub warn_pedantic ($$$) { Link Here
106
    $warned += 1;
106
    $warned += 1;
107
}
107
}
108
108
109
sub error_additional ($$) {
109
sub error_additional {
110
    my($msg, $lc) = @_;
110
    my($msg, $lc) = @_;
111
    my $prefix = construct_warn_prefix('ERROR', $lc);
111
    my $prefix = construct_warn_prefix('ERROR', $lc);
112
    $msg .= "\n" unless $msg =~ /\n$/s;
112
    $msg .= "\n" unless $msg =~ /\n$/s;
113
    warn "$prefix$msg";
113
    warn "$prefix$msg";
114
}
114
}
115
115
116
sub error_normal ($$) {
116
sub error_normal {
117
    my($msg, $lc) = @_;
117
    my($msg, $lc) = @_;
118
    $erred += 1;
118
    $erred += 1;
119
    error_additional($msg, $lc);
119
    error_additional($msg, $lc);
120
}
120
}
121
121
122
sub warned () {
122
sub warned {
123
    return $warned; # number of times warned
123
    return $warned; # number of times warned
124
}
124
}
125
125
(-)a/misc/translator/po2json (-5 / +9 lines)
Lines 37-43 sub usage { Link Here
37
37
38
sub main
38
sub main
39
{
39
{
40
    my ($src_fh, $src);
40
    my $src;
41
41
42
    my $pretty = 0;
42
    my $pretty = 0;
43
    if ($ARGV[0] =~ /^--?p$/) {
43
    if ($ARGV[0] =~ /^--?p$/) {
Lines 124-130 sub main Link Here
124
        # on a normal msgid
124
        # on a normal msgid
125
        } else {
125
        } else {
126
            my $qmsgctxt = $po->msgctxt;
126
            my $qmsgctxt = $po->msgctxt;
127
            my $msgctxt = $po->dequote($qmsgctxt) if $qmsgctxt;
127
            my $msgctxt;
128
            $msgctxt = $po->dequote($qmsgctxt) if $qmsgctxt;
128
129
129
            # build the new msgid key
130
            # build the new msgid key
130
            my $msg_ctxt_id = defined($msgctxt) ? join($gettext_context_glue, ($msgctxt, $msgid1)) : $msgid1;
131
            my $msg_ctxt_id = defined($msgctxt) ? join($gettext_context_glue, ($msgctxt, $msgid1)) : $msgid1;
Lines 134-140 sub main Link Here
134
135
135
            # msgid plural side
136
            # msgid plural side
136
            my $qmsgid_plural = $po->msgid_plural;
137
            my $qmsgid_plural = $po->msgid_plural;
137
            my $msgid2 = $po->dequote( $qmsgid_plural ) if $qmsgid_plural;
138
            my $msgid2;
139
            $msgid2 = $po->dequote( $qmsgid_plural ) if $qmsgid_plural;
138
            push(@trans, $msgid2);
140
            push(@trans, $msgid2);
139
141
140
            # translated string
142
            # translated string
Lines 145-158 sub main Link Here
145
                for (my $i=0; $i<$plural_form_count; $i++)
147
                for (my $i=0; $i<$plural_form_count; $i++)
146
                {
148
                {
147
                    my $qstr = ref($plurals) ? $$plurals{$i} : undef;
149
                    my $qstr = ref($plurals) ? $$plurals{$i} : undef;
148
                    my $str  = $po->dequote( $qstr ) if $qstr;
150
                    my $str;
151
                    $str  = $po->dequote( $qstr ) if $qstr;
149
                    push(@trans, $str);
152
                    push(@trans, $str);
150
                }
153
                }
151
154
152
            # singular
155
            # singular
153
            } else {
156
            } else {
154
                my $qmsgstr = $po->msgstr;
157
                my $qmsgstr = $po->msgstr;
155
                my $msgstr = $po->dequote( $qmsgstr ) if $qmsgstr;
158
                my $msgstr;
159
                $msgstr = $po->dequote( $qmsgstr ) if $qmsgstr;
156
                push(@trans, $msgstr);
160
                push(@trans, $msgstr);
157
            }
161
            }
158
162
(-)a/misc/translator/tmpl_process3.pl (-41 / +40 lines)
Lines 35-41 use vars qw( $charset_in $charset_out ); Link Here
35
35
36
###############################################################################
36
###############################################################################
37
37
38
sub find_translation ($) {
38
sub find_translation {
39
    my($s) = @_;
39
    my($s) = @_;
40
    my $key = $s;
40
    my $key = $s;
41
    if ($s =~ /\S/s) {
41
    if ($s =~ /\S/s) {
Lines 56-68 sub find_translation ($) { Link Here
56
    }
56
    }
57
}
57
}
58
58
59
sub text_replace_tag ($$) {
59
sub text_replace_tag {
60
    my($t, $attr) = @_;
60
    my($t, $attr) = @_;
61
    my $it;
61
    my $it;
62
    my @ttvar;
62
    my @ttvar;
63
63
64
    # value [tag=input], meta
64
    # value [tag=input], meta
65
    my $tag = lc($1) if $t =~ /^<(\S+)/s;
65
    my $tag = ($t =~ /^<(\S+)/s) ? lc($1) : undef;
66
    my $translated_p = 0;
66
    my $translated_p = 0;
67
    for my $a ('alt', 'content', 'title', 'value', 'label', 'placeholder') {
67
    for my $a ('alt', 'content', 'title', 'value', 'label', 'placeholder') {
68
    if ($attr->{$a}) {
68
    if ($attr->{$a}) {
Lines 117-126 sub text_replace_tag ($$) { Link Here
117
    return $it;
117
    return $it;
118
}
118
}
119
119
120
sub text_replace (**) {
120
sub text_replace {
121
    my($h, $output) = @_;
121
    my($h, $output) = @_;
122
    for (;;) {
122
    for (;;) {
123
    my $s = TmplTokenizer::next_token $h;
123
    my $s = TmplTokenizer::next_token($h);
124
    last unless defined $s;
124
    last unless defined $s;
125
    my($kind, $t, $attr) = ($s->type, $s->string, $s->attributes);
125
    my($kind, $t, $attr) = ($s->type, $s->string, $s->attributes);
126
    if ($kind eq C4::TmplTokenType::TEXT) {
126
    if ($kind eq C4::TmplTokenType::TEXT) {
Lines 138-144 sub text_replace (**) { Link Here
138
        for my $t (@{$s->js_data}) {
138
        for my $t (@{$s->js_data}) {
139
        # FIXME for this whole block
139
        # FIXME for this whole block
140
        if ($t->[0]) {
140
        if ($t->[0]) {
141
            printf $output "%s%s%s", $t->[2], find_translation $t->[3],
141
            printf $output "%s%s%s", $t->[2], find_translation($t->[3]),
142
                $t->[2];
142
                $t->[2];
143
        } else {
143
        } else {
144
            print $output $t->[1];
144
            print $output $t->[1];
Lines 178-191 sub listfiles { Link Here
178
            }
178
            }
179
        }
179
        }
180
    } else {
180
    } else {
181
        warn_normal "$dir: $!", undef;
181
        warn_normal("$dir: $!", undef);
182
    }
182
    }
183
    return @it;
183
    return @it;
184
}
184
}
185
185
186
###############################################################################
186
###############################################################################
187
187
188
sub mkdir_recursive ($) {
188
sub mkdir_recursive {
189
    my($dir) = @_;
189
    my($dir) = @_;
190
    local($`, $&, $', $1);
190
    local($`, $&, $', $1);
191
    $dir = $` if $dir ne /^\/+$/ && $dir =~ /\/+$/;
191
    $dir = $` if $dir ne /^\/+$/ && $dir =~ /\/+$/;
Lines 194-206 sub mkdir_recursive ($) { Link Here
194
    if (!-d $dir) {
194
    if (!-d $dir) {
195
    print STDERR "Making directory $dir...\n" unless $quiet;
195
    print STDERR "Making directory $dir...\n" unless $quiet;
196
    # creates with rwxrwxr-x permissions
196
    # creates with rwxrwxr-x permissions
197
    mkdir($dir, 0775) || warn_normal "$dir: $!", undef;
197
    mkdir($dir, 0775) || warn_normal("$dir: $!", undef);
198
    }
198
    }
199
}
199
}
200
200
201
###############################################################################
201
###############################################################################
202
202
203
sub usage ($) {
203
sub usage {
204
    my($exitcode) = @_;
204
    my($exitcode) = @_;
205
    my $h = $exitcode? *STDERR: *STDOUT;
205
    my $h = $exitcode? *STDERR: *STDOUT;
206
    print $h <<EOF;
206
    print $h <<EOF;
Lines 238-244 EOF Link Here
238
238
239
###############################################################################
239
###############################################################################
240
240
241
sub usage_error (;$) {
241
sub usage_error {
242
    for my $msg (split(/\n/, $_[0])) {
242
    for my $msg (split(/\n/, $_[0])) {
243
    print STDERR "$msg\n";
243
    print STDERR "$msg\n";
244
    }
244
    }
Lines 260-269 GetOptions( Link Here
260
    'quiet|q'               => \$quiet,
260
    'quiet|q'               => \$quiet,
261
    'pedantic-warnings|pedantic'    => sub { $pedantic_p = 1 },
261
    'pedantic-warnings|pedantic'    => sub { $pedantic_p = 1 },
262
    'help'              => \&usage,
262
    'help'              => \&usage,
263
) || usage_error;
263
) || usage_error();
264
264
265
VerboseWarnings::set_application_name $0;
265
VerboseWarnings::set_application_name($0);
266
VerboseWarnings::set_pedantic_mode $pedantic_p;
266
VerboseWarnings::set_pedantic_mode($pedantic_p);
267
267
268
# keep the buggy Locale::PO quiet if it says stupid things
268
# keep the buggy Locale::PO quiet if it says stupid things
269
$SIG{__WARN__} = sub {
269
$SIG{__WARN__} = sub {
Lines 307-313 $href = Locale::PO->load_file_ashash($str_file); Link Here
307
# guess the charsets. HTML::Templates defaults to iso-8859-1
307
# guess the charsets. HTML::Templates defaults to iso-8859-1
308
if (defined $href) {
308
if (defined $href) {
309
    die "$str_file: PO file is corrupted, or not a PO file\n" unless defined $href->{'""'};
309
    die "$str_file: PO file is corrupted, or not a PO file\n" unless defined $href->{'""'};
310
    $charset_out = TmplTokenizer::charset_canon $2 if $href->{'""'}->msgstr =~ /\bcharset=(["']?)([^;\s"'\\]+)\1/;
310
    $charset_out = TmplTokenizer::charset_canon($2) if $href->{'""'}->msgstr =~ /\bcharset=(["']?)([^;\s"'\\]+)\1/;
311
    $charset_in = $charset_out;
311
    $charset_in = $charset_out;
312
#     for my $msgid (keys %$href) {
312
#     for my $msgid (keys %$href) {
313
#   if ($msgid =~ /\bcharset=(["']?)([^;\s"'\\]+)\1/) {
313
#   if ($msgid =~ /\bcharset=(["']?)([^;\s"'\\]+)\1/) {
Lines 326-347 if (defined $href) { Link Here
326
        next if $id_count == $str_count ||
326
        next if $id_count == $str_count ||
327
                $msg->{msgstr} eq '""' ||
327
                $msg->{msgstr} eq '""' ||
328
                grep { /fuzzy/ } @{$msg->{_flags}};
328
                grep { /fuzzy/ } @{$msg->{_flags}};
329
        warn_normal
329
        warn_normal(
330
            "unconsistent %s count: ($id_count/$str_count):\n" .
330
            "unconsistent %s count: ($id_count/$str_count):\n" .
331
            "  line:   " . $msg->{loaded_line_number} . "\n" .
331
            "  line:   " . $msg->{loaded_line_number} . "\n" .
332
            "  msgid:  " . $msg->{msgid} . "\n" .
332
            "  msgid:  " . $msg->{msgid} . "\n" .
333
            "  msgstr: " . $msg->{msgstr} . "\n", undef;
333
            "  msgstr: " . $msg->{msgstr} . "\n", undef);
334
    }
334
    }
335
}
335
}
336
336
337
# set our charset in to UTF-8
337
# set our charset in to UTF-8
338
if (!defined $charset_in) {
338
if (!defined $charset_in) {
339
    $charset_in = TmplTokenizer::charset_canon 'UTF-8';
339
    $charset_in = TmplTokenizer::charset_canon('UTF-8');
340
    warn "Warning: Can't determine original templates' charset, defaulting to $charset_in\n" unless ( $quiet );
340
    warn "Warning: Can't determine original templates' charset, defaulting to $charset_in\n" unless ( $quiet );
341
}
341
}
342
# set our charset out to UTF-8
342
# set our charset out to UTF-8
343
if (!defined $charset_out) {
343
if (!defined $charset_out) {
344
    $charset_out = TmplTokenizer::charset_canon 'UTF-8';
344
    $charset_out = TmplTokenizer::charset_canon('UTF-8');
345
    warn "Warning: Charset Out defaulting to $charset_out\n" unless ( $quiet );
345
    warn "Warning: Charset Out defaulting to $charset_out\n" unless ( $quiet );
346
}
346
}
347
my $xgettext = './xgettext.pl'; # actual text extractor script
347
my $xgettext = './xgettext.pl'; # actual text extractor script
Lines 376-398 if ($action eq 'create') { Link Here
376
    # FIXME: msgmerge(1) is a Unix dependency
376
    # FIXME: msgmerge(1) is a Unix dependency
377
    # FIXME: need to check the return value
377
    # FIXME: need to check the return value
378
    unless (-f $str_file) {
378
    unless (-f $str_file) {
379
        local(*INPUT, *OUTPUT);
379
        open(my $infh, '<', $tmpfile2);
380
        open(INPUT, "<$tmpfile2");
380
        open(my $outfh, '>', $str_file);
381
        open(OUTPUT, ">$str_file");
381
        while (<$infh>) {
382
        while (<INPUT>) {
382
        print $outfh;
383
        print OUTPUT;
384
        last if /^\n/s;
383
        last if /^\n/s;
385
        }
384
        }
386
        close INPUT;
385
        close $infh;
387
        close OUTPUT;
386
        close $outfh;
388
    }
387
    }
389
    $st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile2 -o - | msgattrib --no-obsolete -o $str_file");
388
    $st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile2 -o - | msgattrib --no-obsolete -o $str_file");
390
    } else {
389
    } else {
391
    error_normal "Text extraction failed: $xgettext: $!\n", undef;
390
    error_normal("Text extraction failed: $xgettext: $!\n", undef);
392
    error_additional "Will not run msgmerge\n", undef;
391
    error_additional("Will not run msgmerge\n", undef);
393
    }
392
    }
394
    unlink $tmpfile1 || warn_normal "$tmpfile1: unlink failed: $!\n", undef;
393
    unlink $tmpfile1 || warn_normal("$tmpfile1: unlink failed: $!\n", undef);
395
    unlink $tmpfile2 || warn_normal "$tmpfile2: unlink failed: $!\n", undef;
394
    unlink $tmpfile2 || warn_normal("$tmpfile2: unlink failed: $!\n", undef);
396
395
397
} elsif ($action eq 'update') {
396
} elsif ($action eq 'update') {
398
    my($tmph1, $tmpfile1) = tmpnam();
397
    my($tmph1, $tmpfile1) = tmpnam();
Lines 421-431 if ($action eq 'create') { Link Here
421
            $st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile2 -o - | msgattrib --no-obsolete -o $str_file");
420
            $st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile2 -o - | msgattrib --no-obsolete -o $str_file");
422
        }
421
        }
423
    } else {
422
    } else {
424
        error_normal "Text extraction failed: $xgettext: $!\n", undef;
423
        error_normal("Text extraction failed: $xgettext: $!\n", undef);
425
        error_additional "Will not run msgmerge\n", undef;
424
        error_additional("Will not run msgmerge\n", undef);
426
    }
425
    }
427
    unlink $tmpfile1 || warn_normal "$tmpfile1: unlink failed: $!\n", undef;
426
    unlink $tmpfile1 || warn_normal("$tmpfile1: unlink failed: $!\n", undef);
428
    unlink $tmpfile2 || warn_normal "$tmpfile2: unlink failed: $!\n", undef;
427
    unlink $tmpfile2 || warn_normal("$tmpfile2: unlink failed: $!\n", undef);
429
428
430
} elsif ($action eq 'install') {
429
} elsif ($action eq 'install') {
431
    if(!defined($out_dir)) {
430
    if(!defined($out_dir)) {
Lines 448-455 if ($action eq 'create') { Link Here
448
    -d $out_dir || die "$out_dir: The directory does not exist\n";
447
    -d $out_dir || die "$out_dir: The directory does not exist\n";
449
448
450
    # Try to open the file, because Locale::PO doesn't check :-/
449
    # Try to open the file, because Locale::PO doesn't check :-/
451
    open(INPUT, "<$str_file") || die "$str_file: $!\n";
450
    open(my $fh, '<', $str_file) || die "$str_file: $!\n";
452
    close INPUT;
451
    close $fh;
453
452
454
    # creates the new tmpl file using the new translation
453
    # creates the new tmpl file using the new translation
455
    for my $input (@in_files) {
454
    for my $input (@in_files) {
Lines 457-473 if ($action eq 'create') { Link Here
457
            unless substr($input, 0, length($in_dir) + 1) eq "$in_dir/";
456
            unless substr($input, 0, length($in_dir) + 1) eq "$in_dir/";
458
457
459
        my $target = $out_dir . substr($input, length($in_dir));
458
        my $target = $out_dir . substr($input, length($in_dir));
460
        my $targetdir = $` if $target =~ /[^\/]+$/s;
459
        my $targetdir = ($target =~ /[^\/]+$/s) ? $` : undef;
461
460
462
        if (!defined $type || $input =~ /\.(?:$type)$/) {
461
        if (!defined $type || $input =~ /\.(?:$type)$/) {
463
            my $h = TmplTokenizer->new( $input );
462
            my $h = TmplTokenizer->new( $input );
464
            $h->set_allow_cformat( 1 );
463
            $h->set_allow_cformat( 1 );
465
            VerboseWarnings::set_input_file_name $input;
464
            VerboseWarnings::set_input_file_name($input);
466
            mkdir_recursive($targetdir) unless -d $targetdir;
465
            mkdir_recursive($targetdir) unless -d $targetdir;
467
            print STDERR "Creating $target...\n" unless $quiet;
466
            print STDERR "Creating $target...\n" unless $quiet;
468
            open( OUTPUT, ">$target" ) || die "$target: $!\n";
467
            open( my $fh, '>', $target ) || die "$target: $!\n";
469
            text_replace( $h, *OUTPUT );
468
            text_replace( $h, $fh );
470
            close OUTPUT;
469
            close $fh;
471
        } else {
470
        } else {
472
        # just copying the file
471
        # just copying the file
473
            mkdir_recursive($targetdir) unless -d $targetdir;
472
            mkdir_recursive($targetdir) unless -d $targetdir;
(-)a/misc/translator/xgettext.pl (-13 / +15 lines)
Lines 101-107 sub string_list { Link Here
101
sub text_extract {
101
sub text_extract {
102
    my($h) = @_;
102
    my($h) = @_;
103
    for (;;) {
103
    for (;;) {
104
        my $s = TmplTokenizer::next_token $h;
104
        my $s = TmplTokenizer::next_token($h);
105
        last unless defined $s;
105
        last unless defined $s;
106
        my($kind, $t, $attr) = ($s->type, $s->string, $s->attributes);
106
        my($kind, $t, $attr) = ($s->type, $s->string, $s->attributes);
107
        if ($kind eq C4::TmplTokenType::TEXT) {
107
        if ($kind eq C4::TmplTokenType::TEXT) {
Lines 123-129 sub text_extract { Link Here
123
                    next if $a eq 'value' && ($tag ne 'input'
123
                    next if $a eq 'value' && ($tag ne 'input'
124
                        || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|checkbox)$/)); # FIXME
124
                        || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|checkbox)$/)); # FIXME
125
                    my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
125
                    my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
126
                    $val = TmplTokenizer::trim $val;
126
                    $val = TmplTokenizer::trim($val);
127
                    # for selected attributes replace '[%..%]' with '%s' globally
127
                    # for selected attributes replace '[%..%]' with '%s' globally
128
                    if ( $a =~ /title|value|alt|content|placeholder/ ) {
128
                    if ( $a =~ /title|value|alt|content|placeholder/ ) {
129
                        $val =~ s/\[\%.*?\%\]/\%s/g;
129
                        $val =~ s/\[\%.*?\%\]/\%s/g;
Lines 154-160 sub generate_strings_list { Link Here
154
sub generate_po_file {
154
sub generate_po_file {
155
    # We don't emit the Plural-Forms header; it's meaningless for us
155
    # We don't emit the Plural-Forms header; it's meaningless for us
156
    my $pot_charset = (defined $charset_out? $charset_out: 'CHARSET');
156
    my $pot_charset = (defined $charset_out? $charset_out: 'CHARSET');
157
    $pot_charset = TmplTokenizer::charset_canon $pot_charset;
157
    $pot_charset = TmplTokenizer::charset_canon($pot_charset);
158
    # Time stamps aren't exactly right semantically. I don't know how to fix it.
158
    # Time stamps aren't exactly right semantically. I don't know how to fix it.
159
    my $time = POSIX::strftime('%Y-%m-%d %H:%M%z', localtime(time));
159
    my $time = POSIX::strftime('%Y-%m-%d %H:%M%z', localtime(time));
160
    my $time_pot = $time;
160
    my $time_pot = $time;
Lines 243-251 EOF Link Here
243
	    $cformat_p = 1 if $token->type == C4::TmplTokenType::TEXT_PARAMETRIZED;
243
	    $cformat_p = 1 if $token->type == C4::TmplTokenType::TEXT_PARAMETRIZED;
244
	}
244
	}
245
        printf $OUTPUT "#, c-format\n" if $cformat_p;
245
        printf $OUTPUT "#, c-format\n" if $cformat_p;
246
        printf $OUTPUT "msgid %s\n", TmplTokenizer::quote_po
246
        printf $OUTPUT "msgid %s\n", TmplTokenizer::quote_po(
247
		TmplTokenizer::string_canon
247
            TmplTokenizer::string_canon(
248
		TmplTokenizer::charset_convert $t, $charset_in, $charset_out;
248
                TmplTokenizer::charset_convert($t, $charset_in, $charset_out)
249
            )
250
        );
249
        printf $OUTPUT "msgstr %s\n\n", (defined $translation{$t}?
251
        printf $OUTPUT "msgstr %s\n\n", (defined $translation{$t}?
250
		TmplTokenizer::quote_po( $translation{$t} ): "\"\"");
252
		TmplTokenizer::quote_po( $translation{$t} ): "\"\"");
251
    }
253
    }
Lines 255-261 EOF Link Here
255
257
256
sub convert_translation_file {
258
sub convert_translation_file {
257
    open(my $INPUT, '<', $convert_from) || die "$convert_from: $!\n";
259
    open(my $INPUT, '<', $convert_from) || die "$convert_from: $!\n";
258
    VerboseWarnings::set_input_file_name $convert_from;
260
    VerboseWarnings::set_input_file_name($convert_from);
259
    while (<$INPUT>) {
261
    while (<$INPUT>) {
260
	chomp;
262
	chomp;
261
	my($msgid, $msgstr) = split(/\t/);
263
	my($msgid, $msgstr) = split(/\t/);
Lines 272-284 sub convert_translation_file { Link Here
272
	$translation{$msgid} = $msgstr unless $msgstr eq '*****';
274
	$translation{$msgid} = $msgstr unless $msgstr eq '*****';
273
275
274
	if ($msgid  =~ /\bcharset=(["']?)([^;\s"']+)\1/s) {
276
	if ($msgid  =~ /\bcharset=(["']?)([^;\s"']+)\1/s) {
275
	    my $candidate = TmplTokenizer::charset_canon $2;
277
	    my $candidate = TmplTokenizer::charset_canon($2);
276
	    die "Conflicting charsets in msgid: $candidate vs $charset_in\n"
278
	    die "Conflicting charsets in msgid: $candidate vs $charset_in\n"
277
		    if defined $charset_in && $charset_in ne $candidate;
279
		    if defined $charset_in && $charset_in ne $candidate;
278
	    $charset_in = $candidate;
280
	    $charset_in = $candidate;
279
	}
281
	}
280
	if ($msgstr =~ /\bcharset=(["']?)([^;\s"']+)\1/s) {
282
	if ($msgstr =~ /\bcharset=(["']?)([^;\s"']+)\1/s) {
281
	    my $candidate = TmplTokenizer::charset_canon $2;
283
	    my $candidate = TmplTokenizer::charset_canon($2);
282
	    die "Conflicting charsets in msgid: $candidate vs $charset_out\n"
284
	    die "Conflicting charsets in msgid: $candidate vs $charset_out\n"
283
		    if defined $charset_out && $charset_out ne $candidate;
285
		    if defined $charset_out && $charset_out ne $candidate;
284
	    $charset_out = $candidate;
286
	    $charset_out = $candidate;
Lines 286-292 sub convert_translation_file { Link Here
286
    }
288
    }
287
    # The following assumption is correct; that's what HTML::Template assumes
289
    # The following assumption is correct; that's what HTML::Template assumes
288
    if (!defined $charset_in) {
290
    if (!defined $charset_in) {
289
	$charset_in = $charset_out = TmplTokenizer::charset_canon 'utf-8';
291
	$charset_in = $charset_out = TmplTokenizer::charset_canon('utf-8');
290
	warn "Warning: Can't determine original templates' charset, defaulting to $charset_in\n";
292
	warn "Warning: Can't determine original templates' charset, defaulting to $charset_in\n";
291
    }
293
    }
292
}
294
}
Lines 354-361 GetOptions( Link Here
354
    'help'				=> sub { usage(0) },
356
    'help'				=> sub { usage(0) },
355
) || usage_error;
357
) || usage_error;
356
358
357
VerboseWarnings::set_application_name $0;
359
VerboseWarnings::set_application_name($0);
358
VerboseWarnings::set_pedantic_mode $pedantic_p;
360
VerboseWarnings::set_pedantic_mode($pedantic_p);
359
361
360
usage_error('Missing mandatory option -f')
362
usage_error('Missing mandatory option -f')
361
	unless defined $files_from || defined $convert_from;
363
	unless defined $files_from || defined $convert_from;
Lines 380-386 if (defined $files_from) { Link Here
380
	my $input = /^\//? $_: "$directory/$_";
382
	my $input = /^\//? $_: "$directory/$_";
381
	my $h = TmplTokenizer->new( $input );
383
	my $h = TmplTokenizer->new( $input );
382
	$h->set_allow_cformat( 1 );
384
	$h->set_allow_cformat( 1 );
383
	VerboseWarnings::set_input_file_name $input;
385
	VerboseWarnings::set_input_file_name($input);
384
	print STDERR "$0: Processing file \"$input\"\n" if $verbose_p;
386
	print STDERR "$0: Processing file \"$input\"\n" if $verbose_p;
385
	text_extract( $h );
387
	text_extract( $h );
386
    }
388
    }
(-)a/opac/opac-MARCdetail.pl (-1 lines)
Lines 155-161 if (C4::Context->preference("RequestOnOpac")) { Link Here
155
155
156
# fill arrays
156
# fill arrays
157
my @loop_data = ();
157
my @loop_data = ();
158
my $tag;
159
158
160
# loop through each tab 0 through 9
159
# loop through each tab 0 through 9
161
for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) {
160
for ( my $tabloop = 0 ; $tabloop <= 9 ; $tabloop++ ) {
(-)a/opac/opac-alert-subscribe.pl (-1 lines)
Lines 32-38 my $query = new CGI; Link Here
32
my $op    = $query->param('op') || '';
32
my $op    = $query->param('op') || '';
33
my $dbh   = C4::Context->dbh;
33
my $dbh   = C4::Context->dbh;
34
34
35
my $sth;
36
my ( $template, $loggedinuser, $cookie );
35
my ( $template, $loggedinuser, $cookie );
37
my $subscriptionid = $query->param('subscriptionid');
36
my $subscriptionid = $query->param('subscriptionid');
38
my $referer      = $query->param('referer') || 'detail';
37
my $referer      = $query->param('referer') || 'detail';
(-)a/opac/opac-authorities-home.pl (-1 lines)
Lines 56-62 if ( $op eq "do_search" ) { Link Here
56
    my @value = $query->multi_param('value');
56
    my @value = $query->multi_param('value');
57
    $value[0] ||= q||;
57
    $value[0] ||= q||;
58
58
59
    my @tags;
60
    my $builder = Koha::SearchEngine::QueryBuilder->new(
59
    my $builder = Koha::SearchEngine::QueryBuilder->new(
61
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
60
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
62
    my $searcher = Koha::SearchEngine::Search->new(
61
    my $searcher = Koha::SearchEngine::Search->new(
(-)a/opac/opac-authoritiesdetail.pl (-1 lines)
Lines 114-120 if ($show_marc) { Link Here
114
114
115
# fill arrays
115
# fill arrays
116
    my @loop_data = ();
116
    my @loop_data = ();
117
    my $tag;
118
117
119
# loop through each tag
118
# loop through each tag
120
    my @fields    = $record->fields();
119
    my @fields    = $record->fields();
(-)a/opac/opac-basket.pl (-1 lines)
Lines 119-125 foreach my $biblionumber ( @bibs ) { Link Here
119
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
119
      { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) };
120
120
121
	# COinS format FIXME: for books Only
121
	# COinS format FIXME: for books Only
122
        my $coins_format;
123
        my $fmt = substr $record->leader(), 6,2;
122
        my $fmt = substr $record->leader(), 6,2;
124
        my $fmts;
123
        my $fmts;
125
        $fmts->{'am'} = 'book';
124
        $fmts->{'am'} = 'book';
(-)a/opac/opac-search.pl (-5 lines)
Lines 534-541 my $hits; Link Here
534
# Define some global variables
534
# Define some global variables
535
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
535
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
536
536
537
my @results;
538
539
my $suppress = 0;
537
my $suppress = 0;
540
if (C4::Context->preference('OpacSuppression')) {
538
if (C4::Context->preference('OpacSuppression')) {
541
    # OPAC suppression by IP address
539
    # OPAC suppression by IP address
Lines 604-612 $template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSid Link Here
604
## II. DO THE SEARCH AND GET THE RESULTS
602
## II. DO THE SEARCH AND GET THE RESULTS
605
my $total = 0; # the total results for the whole set
603
my $total = 0; # the total results for the whole set
606
my $facets; # this object stores the faceted results that display on the left-hand of the results page
604
my $facets; # this object stores the faceted results that display on the left-hand of the results page
607
my @results_array;
608
my $results_hashref;
605
my $results_hashref;
609
my @coins;
610
606
611
if ($tag) {
607
if ($tag) {
612
    $query_cgi = "tag=" .  uri_escape_utf8( $tag ) . "&" . $query_cgi;
608
    $query_cgi = "tag=" .  uri_escape_utf8( $tag ) . "&" . $query_cgi;
Lines 967-973 for (my $i=0;$i<@servers;$i++) { Link Here
967
    # FIXME: can add support for other targets as needed here
963
    # FIXME: can add support for other targets as needed here
968
    $template->param(           outer_sup_results_loop => \@sup_results_array);
964
    $template->param(           outer_sup_results_loop => \@sup_results_array);
969
} #/end of the for loop
965
} #/end of the for loop
970
#$template->param(FEDERATED_RESULTS => \@results_array);
971
966
972
for my $facet ( @$facets ) {
967
for my $facet ( @$facets ) {
973
    for my $entry ( @{ $facet->{facets} } ) {
968
    for my $entry ( @{ $facet->{facets} } ) {
(-)a/opac/opac-serial-issues.pl (-2 lines)
Lines 34-41 my $dbh = C4::Context->dbh; Link Here
34
my $selectview = $query->param('selectview');
34
my $selectview = $query->param('selectview');
35
$selectview = C4::Context->preference("SubscriptionHistory") unless $selectview;
35
$selectview = C4::Context->preference("SubscriptionHistory") unless $selectview;
36
36
37
my $sth;
38
39
# my $id;
37
# my $id;
40
my ( $template, $loggedinuser, $cookie );
38
my ( $template, $loggedinuser, $cookie );
41
my $biblionumber = $query->param('biblionumber');
39
my $biblionumber = $query->param('biblionumber');
(-)a/opac/opac-showreviews.pl (-1 lines)
Lines 85-91 my $reviews = Koha::Reviews->search( Link Here
85
my $marcflavour      = C4::Context->preference("marcflavour");
85
my $marcflavour      = C4::Context->preference("marcflavour");
86
my $hits = Koha::Reviews->search({ approved => 1 })->count;
86
my $hits = Koha::Reviews->search({ approved => 1 })->count;
87
my $i = 0;
87
my $i = 0;
88
my $latest_comment_date;
89
for my $result (@$reviews){
88
for my $result (@$reviews){
90
    my $biblionumber = $result->{biblionumber};
89
    my $biblionumber = $result->{biblionumber};
91
    my $biblio = Koha::Biblios->find( $biblionumber );
90
    my $biblio = Koha::Biblios->find( $biblionumber );
(-)a/patroncards/create-pdf.pl (-5 / +5 lines)
Lines 44-56 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
44
                                                                     flagsrequired   => { tools => 'label_creator' },
44
                                                                     flagsrequired   => { tools => 'label_creator' },
45
                                                                     debug           => 1,
45
                                                                     debug           => 1,
46
                                                                     });
46
                                                                     });
47
my $batch_id    = $cgi->param('batch_id') if $cgi->param('batch_id');
47
my $batch_id    = $cgi->param('batch_id') || undef;
48
my $template_id = $cgi->param('template_id') || undef;
48
my $template_id = $cgi->param('template_id') || undef;
49
my $layout_id   = $cgi->param('layout_id') || undef;
49
my $layout_id   = $cgi->param('layout_id') || undef;
50
my $layout_back_id   = $cgi->param('layout_back_id') || undef;
50
my $layout_back_id   = $cgi->param('layout_back_id') || undef;
51
my $start_card = $cgi->param('start_card') || 1;
51
my $start_card = $cgi->param('start_card') || 1;
52
my @label_ids   = $cgi->multi_param('label_id') if $cgi->param('label_id');
52
my @label_ids   = $cgi->multi_param('label_id');
53
my @borrower_numbers  = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number');
53
my @borrower_numbers  = $cgi->multi_param('borrower_number');
54
my $patronlist_id = $cgi->param('patronlist_id');
54
my $patronlist_id = $cgi->param('patronlist_id');
55
55
56
my $items = undef; # items = cards
56
my $items = undef; # items = cards
Lines 70-76 $pdf = C4::Creators::PDF->new(InitVars => 0); Link Here
70
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
70
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
71
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
71
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1);
72
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
72
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id);
73
my $layout_back = C4::Patroncards::Layout->retrieve(layout_id => $layout_back_id) if ( $layout_back_id );
73
my $layout_back = $layout_back_id ? C4::Patroncards::Layout->retrieve(layout_id => $layout_back_id) : undef;
74
74
75
$| = 1;
75
$| = 1;
76
76
Lines 111-117 else { Link Here
111
}
111
}
112
112
113
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);
113
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);
114
my $layout_back_xml = XMLin($layout_back->get_attr('layout_xml'), ForceArray => 1) if ( defined $layout_back );
114
my $layout_back_xml = defined $layout_back ? XMLin($layout_back->get_attr('layout_xml'), ForceArray => 1) : undef;
115
115
116
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page to swap columns
116
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page to swap columns
117
    my $even = 1;
117
    my $even = 1;
(-)a/patroncards/image-manage.pl (-1 / +1 lines)
Lines 28-34 my $file_name = $cgi->param('uploadfile') || ''; Link Here
28
my $image_name = $cgi->param('image_name') || $file_name;
28
my $image_name = $cgi->param('image_name') || $file_name;
29
my $upload_file = $cgi->upload('uploadfile') || '';
29
my $upload_file = $cgi->upload('uploadfile') || '';
30
my $op = $cgi->param('op') || 'none';
30
my $op = $cgi->param('op') || 'none';
31
my @image_ids = $cgi->multi_param('image_id') if $cgi->param('image_id');
31
my @image_ids = $cgi->multi_param('image_id');
32
32
33
my $source_file = "$file_name"; # otherwise we end up with what amounts to a pointer to a filehandle rather than a user-friendly filename
33
my $source_file = "$file_name"; # otherwise we end up with what amounts to a pointer to a filehandle rather than a user-friendly filename
34
34
(-)a/patroncards/print.pl (-6 / +6 lines)
Lines 40-53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
40
);
40
);
41
41
42
my $op = $cgi->param('op') || 'none';
42
my $op = $cgi->param('op') || 'none';
43
my @label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id');   # this will handle individual card printing; we use label_id to maintain consistency with the column names in the creator_batches table
43
my @label_ids = $cgi->multi_param('label_id');   # this will handle individual card printing; we use label_id to maintain consistency with the column names in the creator_batches table
44
my @batch_ids = $cgi->multi_param('batch_id') if $cgi->param('batch_id');
44
my @batch_ids = $cgi->multi_param('batch_id');
45
my $patronlist_id = $cgi->param('patronlist_id') || undef;
45
my $patronlist_id = $cgi->param('patronlist_id') || undef;
46
my $layout_id = $cgi->param('layout_id') || undef;
46
my $layout_id = $cgi->param('layout_id') || undef;
47
my $layout_back_id = $cgi->param('layout_back_id') || undef;
47
my $layout_back_id = $cgi->param('layout_back_id') || undef;
48
my $template_id = $cgi->param('template_id') || undef;
48
my $template_id = $cgi->param('template_id') || undef;
49
my $start_card = $cgi->param('start_card') || 1;
49
my $start_card = $cgi->param('start_card') || 1;
50
my @borrower_numbers = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number');
50
my @borrower_numbers = $cgi->multi_param('borrower_number');
51
my $output_format = $cgi->param('output_format') || 'pdf';
51
my $output_format = $cgi->param('output_format') || 'pdf';
52
my $referer = $cgi->param('referer') || undef;
52
my $referer = $cgi->param('referer') || undef;
53
53
Lines 123-131 elsif ($op eq 'none') { Link Here
123
    # setup select menus for selecting layout and template for this run...
123
    # setup select menus for selecting layout and template for this run...
124
    $referer = $ENV{'HTTP_REFERER'};
124
    $referer = $ENV{'HTTP_REFERER'};
125
    $referer =~ s/^.*?:\/\/.*?(\/.*)$/$1/m;
125
    $referer =~ s/^.*?:\/\/.*?(\/.*)$/$1/m;
126
    @batch_ids = grep{$_ = {batch_id => $_}} @batch_ids;
126
    @batch_ids = map { {batch_id => $_} } @batch_ids;
127
    @label_ids = grep{$_ = {label_id => $_}} @label_ids;
127
    @label_ids = map { {label_id => $_} } @label_ids;
128
    @borrower_numbers = grep{$_ = {borrower_number => $_}} @borrower_numbers;
128
    @borrower_numbers = map { {borrower_number => $_} } @borrower_numbers;
129
    $templates = get_all_templates( { fields => [qw( template_id template_code ) ], filters => { creator => "Patroncards" } });
129
    $templates = get_all_templates( { fields => [qw( template_id template_code ) ], filters => { creator => "Patroncards" } });
130
    $layouts = get_all_layouts({ fields => [ qw( layout_id layout_name ) ], filters => { creator => "Patroncards" } });
130
    $layouts = get_all_layouts({ fields => [ qw( layout_id layout_name ) ], filters => { creator => "Patroncards" } });
131
    $output_formats = get_output_formats();
131
    $output_formats = get_output_formats();
(-)a/plugins/plugins-upload.pl (-1 / +1 lines)
Lines 50-56 my $uploadfile = $input->upload('uploadfile'); Link Here
50
my $uploadlocation = $input->param('uploadlocation');
50
my $uploadlocation = $input->param('uploadlocation');
51
my $op             = $input->param('op') || q{};
51
my $op             = $input->param('op') || q{};
52
52
53
my ( $total, $handled, @counts, $tempfile, $tfh );
53
my ( $tempfile, $tfh );
54
54
55
my %errors;
55
my %errors;
56
56
(-)a/reports/acquisitions_stats.pl (-1 lines)
Lines 426-432 sub calculate { Link Here
426
    }
426
    }
427
427
428
    my $i = 0;
428
    my $i = 0;
429
    my @totalcol;
430
    my $hilighted = -1;
429
    my $hilighted = -1;
431
430
432
    #Initialization of cell values.....
431
    #Initialization of cell values.....
(-)a/reports/bor_issues_top.pl (-14 / +12 lines)
Lines 41-47 plugin that shows a stats on borrowers Link Here
41
41
42
=cut
42
=cut
43
43
44
$debug and open DEBUG, ">/tmp/bor_issues_top.debug.log";
44
$debug and open my $debugfh, '>', '/tmp/bor_issues_top.debug.log';
45
45
46
my $input = new CGI;
46
my $input = new CGI;
47
my $fullreportname = "reports/bor_issues_top.tt";
47
my $fullreportname = "reports/bor_issues_top.tt";
Lines 104-110 if ($do_it) { Link Here
104
}
104
}
105
105
106
my $dbh = C4::Context->dbh;
106
my $dbh = C4::Context->dbh;
107
my @values;
108
107
109
# here each element returned by map is a hashref, get it?
108
# here each element returned by map is a hashref, get it?
110
my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
109
my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
Lines 125-131 sub calculate { Link Here
125
    my ($limit, $column, $filters) = @_;
124
    my ($limit, $column, $filters) = @_;
126
125
127
    my @loopcol;
126
    my @loopcol;
128
    my @loopline;
129
    my @looprow;
127
    my @looprow;
130
    my %globalline;
128
    my %globalline;
131
	my %columns;
129
	my %columns;
Lines 226-250 sub calculate { Link Here
226
        $strsth2 .=" GROUP BY $colfield";
224
        $strsth2 .=" GROUP BY $colfield";
227
        $strsth2 .=" ORDER BY $colorder";
225
        $strsth2 .=" ORDER BY $colorder";
228
226
229
        $debug and print DEBUG "bor_issues_top (old_issues) SQL: $strsth2\n";
227
        $debug and print $debugfh "bor_issues_top (old_issues) SQL: $strsth2\n";
230
        my $sth2 = $dbh->prepare($strsth2);
228
        my $sth2 = $dbh->prepare($strsth2);
231
        $sth2->execute;
229
        $sth2->execute;
232
        print DEBUG "rows: ", $sth2->rows, "\n";
230
        print $debugfh "rows: ", $sth2->rows, "\n";
233
        while (my @row = $sth2->fetchrow) {
231
        while (my @row = $sth2->fetchrow) {
234
			$columns{($row[0] ||'NULL')}++;
232
			$columns{($row[0] ||'NULL')}++;
235
            push @loopcol, { coltitle => $row[0] || 'NULL' };
233
            push @loopcol, { coltitle => $row[0] || 'NULL' };
236
        }
234
        }
237
235
238
		$strsth2 =~ s/old_issues/issues/g;
236
		$strsth2 =~ s/old_issues/issues/g;
239
        $debug and print DEBUG "bor_issues_top (issues) SQL: $strsth2\n";
237
        $debug and print $debugfh "bor_issues_top (issues) SQL: $strsth2\n";
240
		$sth2 = $dbh->prepare($strsth2);
238
		$sth2 = $dbh->prepare($strsth2);
241
        $sth2->execute;
239
        $sth2->execute;
242
        $debug and print DEBUG "rows: ", $sth2->rows, "\n";
240
        $debug and print $debugfh "rows: ", $sth2->rows, "\n";
243
        while (my @row = $sth2->fetchrow) {
241
        while (my @row = $sth2->fetchrow) {
244
			$columns{($row[0] ||'NULL')}++;
242
			$columns{($row[0] ||'NULL')}++;
245
            push @loopcol, { coltitle => $row[0] || 'NULL' };
243
            push @loopcol, { coltitle => $row[0] || 'NULL' };
246
        }
244
        }
247
		$debug and print DEBUG "full array: ", Dumper(\%columns), "\n";
245
		$debug and print $debugfh "full array: ", Dumper(\%columns), "\n";
248
    }else{
246
    }else{
249
        $columns{''} = 1;
247
        $columns{''} = 1;
250
    }
248
    }
Lines 281-290 sub calculate { Link Here
281
    $strcalc .= ",$colfield " if ($colfield);
279
    $strcalc .= ",$colfield " if ($colfield);
282
    $strcalc .= " LIMIT $limit" if ($limit);
280
    $strcalc .= " LIMIT $limit" if ($limit);
283
281
284
    $debug and print DEBUG "(old_issues) SQL : $strcalc\n";
282
    $debug and print $debugfh "(old_issues) SQL : $strcalc\n";
285
    my $dbcalc = $dbh->prepare($strcalc);
283
    my $dbcalc = $dbh->prepare($strcalc);
286
    $dbcalc->execute;
284
    $dbcalc->execute;
287
    $debug and print DEBUG "rows: ", $dbcalc->rows, "\n";
285
    $debug and print $debugfh "rows: ", $dbcalc->rows, "\n";
288
	my %patrons = ();
286
	my %patrons = ();
289
	# DATA STRUCTURE is going to look like this:
287
	# DATA STRUCTURE is going to look like this:
290
	# 	(2253=> {name=>"John Doe",
288
	# 	(2253=> {name=>"John Doe",
Lines 303-312 sub calculate { Link Here
303
	use Data::Dumper;
301
	use Data::Dumper;
304
302
305
	$strcalc =~ s/old_issues/issues/g;
303
	$strcalc =~ s/old_issues/issues/g;
306
    $debug and print DEBUG "(issues) SQL : $strcalc\n";
304
    $debug and print $debugfh "(issues) SQL : $strcalc\n";
307
    $dbcalc = $dbh->prepare($strcalc);
305
    $dbcalc = $dbh->prepare($strcalc);
308
    $dbcalc->execute;
306
    $dbcalc->execute;
309
    $debug and print DEBUG "rows: ", $dbcalc->rows, "\n";
307
    $debug and print $debugfh "rows: ", $dbcalc->rows, "\n";
310
    while (my @data = $dbcalc->fetchrow) {
308
    while (my @data = $dbcalc->fetchrow) {
311
        my ($row, $rank, $id, $col) = @data;
309
        my ($row, $rank, $id, $col) = @data;
312
        $col = "zzEMPTY" if (!defined($col));
310
        $col = "zzEMPTY" if (!defined($col));
Lines 325-331 sub calculate { Link Here
325
			$patrons{$id}->{total} += $count;
323
			$patrons{$id}->{total} += $count;
326
		}
324
		}
327
	}
325
	}
328
    $debug and print DEBUG "\n\npatrons: ", Dumper(\%patrons);
326
    $debug and print $debugfh "\n\npatrons: ", Dumper(\%patrons);
329
    
327
    
330
	my $i = 1;
328
	my $i = 1;
331
	my @cols_in_order = sort keys %columns;		# if you want to order the columns, do something here
329
	my @cols_in_order = sort keys %columns;		# if you want to order the columns, do something here
Lines 371-376 sub calculate { Link Here
371
    return [\%globalline];	# reference to a 1 element array: that element is a hashref
369
    return [\%globalline];	# reference to a 1 element array: that element is a hashref
372
}
370
}
373
371
374
$debug and close DEBUG;
372
$debug and close $debugfh;
375
1;
373
1;
376
__END__
374
__END__
(-)a/reports/borrowers_out.pl (-6 / +1 lines)
Lines 110-120 if ($do_it) { Link Here
110
# Displaying choices
110
# Displaying choices
111
} else {
111
} else {
112
    my $dbh = C4::Context->dbh;
112
    my $dbh = C4::Context->dbh;
113
    my @values;
113
114
    my %labels;
115
    my %select;
116
    my $req;
117
    
118
    my $CGIextChoice = ( 'CSV' ); # FIXME translation
114
    my $CGIextChoice = ( 'CSV' ); # FIXME translation
119
	my $CGIsepChoice = GetDelimiterChoices;
115
	my $CGIsepChoice = GetDelimiterChoices;
120
116
Lines 133-139 sub calculate { Link Here
133
    my @mainloop;
129
    my @mainloop;
134
    my @loopfooter;
130
    my @loopfooter;
135
    my @loopcol;
131
    my @loopcol;
136
    my @loopline;
137
    my @looprow;
132
    my @looprow;
138
    my %globalline;
133
    my %globalline;
139
    my $grantotal =0;
134
    my $grantotal =0;
(-)a/reports/catalogue_out.pl (-2 lines)
Lines 66-73 output_html_with_http_headers $input, $cookie, $template->output; Link Here
66
66
67
sub calculate {
67
sub calculate {
68
    my ( $limit, $column, $filters ) = @_;
68
    my ( $limit, $column, $filters ) = @_;
69
    my @loopline;
70
    my @looprow;
71
    my %globalline;
69
    my %globalline;
72
    my %columns = ();
70
    my %columns = ();
73
    my $dbh     = C4::Context->dbh;
71
    my $dbh     = C4::Context->dbh;
(-)a/reports/catalogue_stats.pl (-5 lines)
Lines 114-124 if ($do_it) { Link Here
114
    }
114
    }
115
} else {
115
} else {
116
	my $dbh = C4::Context->dbh;
116
	my $dbh = C4::Context->dbh;
117
	my @values;
118
	my %labels;
119
	my $count=0;
117
	my $count=0;
120
	my $req;
121
	my @select;
122
118
123
    my $itemtypes = Koha::ItemTypes->search_with_localization;
119
    my $itemtypes = Koha::ItemTypes->search_with_localization;
124
120
Lines 397-403 sub calculate { Link Here
397
    }
393
    }
398
394
399
    my $i = 0;
395
    my $i = 0;
400
    my @totalcol;
401
    my $hilighted = -1;
396
    my $hilighted = -1;
402
397
403
    #Initialization of cell values.....
398
    #Initialization of cell values.....
(-)a/reports/issues_avg_stats.pl (-5 lines)
Lines 389-395 sub calculate { Link Here
389
#	warn "fin des titres colonnes";
389
#	warn "fin des titres colonnes";
390
390
391
    my $i=0;
391
    my $i=0;
392
    my @totalcol;
393
    my $hilighted=-1;
392
    my $hilighted=-1;
394
    
393
    
395
    #Initialization of cell values.....
394
    #Initialization of cell values.....
Lines 442-453 sub calculate { Link Here
442
    $dbcalc->execute;
441
    $dbcalc->execute;
443
# 	warn "filling table";
442
# 	warn "filling table";
444
    my $issues_count=0;
443
    my $issues_count=0;
445
    my $previous_row; 
446
    my $previous_col;
447
    my $loanlength; 
444
    my $loanlength; 
448
    my $err;
449
    my $emptycol;
445
    my $emptycol;
450
    my $weightrow;
451
446
452
    while (my  @data = $dbcalc->fetchrow) {
447
    while (my  @data = $dbcalc->fetchrow) {
453
        my ($row, $col, $issuedate, $returndate, $weight)=@data;
448
        my ($row, $col, $issuedate, $returndate, $weight)=@data;
(-)a/reports/issues_stats.pl (-4 / +1 lines)
Lines 148-156 if ($do_it) { Link Here
148
148
149
149
150
my $dbh = C4::Context->dbh;
150
my $dbh = C4::Context->dbh;
151
my @values;
152
my %labels;
153
my %select;
154
151
155
    # location list
152
    # location list
156
my @locations;
153
my @locations;
Lines 525-531 sub calculate { Link Here
525
        or ( $colsource eq 'items' ) || @$filters[5] || @$filters[6] || @$filters[7] || @$filters[8] || @$filters[9] || @$filters[10] || @$filters[11] || @$filters[12] || @$filters[13] );
522
        or ( $colsource eq 'items' ) || @$filters[5] || @$filters[6] || @$filters[7] || @$filters[8] || @$filters[9] || @$filters[10] || @$filters[11] || @$filters[12] || @$filters[13] );
526
523
527
    $strcalc .= "WHERE 1=1 ";
524
    $strcalc .= "WHERE 1=1 ";
528
    @$filters = map { defined($_) and s/\*/%/g; $_ } @$filters;
525
    @$filters = map { my $f = $_; defined($f) and $f =~ s/\*/%/g; $f } @$filters;
529
    $strcalc .= " AND statistics.datetime >= '" . @$filters[0] . "'"       if ( @$filters[0] );
526
    $strcalc .= " AND statistics.datetime >= '" . @$filters[0] . "'"       if ( @$filters[0] );
530
    $strcalc .= " AND statistics.datetime <= '" . @$filters[1] . " 23:59:59'"       if ( @$filters[1] );
527
    $strcalc .= " AND statistics.datetime <= '" . @$filters[1] . " 23:59:59'"       if ( @$filters[1] );
531
    $strcalc .= " AND borrowers.categorycode LIKE '" . @$filters[2] . "'" if ( @$filters[2] );
528
    $strcalc .= " AND borrowers.categorycode LIKE '" . @$filters[2] . "'" if ( @$filters[2] );
(-)a/reports/reserves_stats.pl (-4 lines)
Lines 126-134 if ($do_it) { Link Here
126
}
126
}
127
127
128
my $dbh = C4::Context->dbh;
128
my $dbh = C4::Context->dbh;
129
my @values;
130
my %labels;
131
my %select;
132
129
133
my $itemtypes = Koha::ItemTypes->search_with_localization;
130
my $itemtypes = Koha::ItemTypes->search_with_localization;
134
131
Lines 260-266 sub calculate { Link Here
260
	push @loopfilter, {crit=>'SQL =', sql=>1, filter=>$strcalc};
257
	push @loopfilter, {crit=>'SQL =', sql=>1, filter=>$strcalc};
261
	@sqlparams=(@sqlparams,@sqlorparams);
258
	@sqlparams=(@sqlparams,@sqlorparams);
262
	$dbcalc->execute(@sqlparams);
259
	$dbcalc->execute(@sqlparams);
263
	my ($emptycol,$emptyrow); 
264
	my $data = $dbcalc->fetchall_hashref([qw(line col)]);
260
	my $data = $dbcalc->fetchall_hashref([qw(line col)]);
265
	my %cols_hash;
261
	my %cols_hash;
266
	foreach my $row (keys %$data){
262
	foreach my $row (keys %$data){
(-)a/rewrite-config.PL (-10 / +12 lines)
Lines 19-24 Link Here
19
# 
19
# 
20
# 2007/11/12	Added DB_PORT and changed other keywords to reflect multi-dbms support.	-fbcit
20
# 2007/11/12	Added DB_PORT and changed other keywords to reflect multi-dbms support.	-fbcit
21
21
22
use Modern::Perl;
22
use Sys::Hostname;
23
use Sys::Hostname;
23
use Socket;
24
use Socket;
24
25
Lines 158-164 $prefix = $ENV{'INSTALL_BASE'} || "/usr"; Link Here
158
);
159
);
159
160
160
# Override configuration from the environment
161
# Override configuration from the environment
161
foreach $key (keys %configuration) {
162
foreach my $key (keys %configuration) {
162
  if (defined($ENV{$key})) {
163
  if (defined($ENV{$key})) {
163
    $configuration{$key} = $ENV{$key};
164
    $configuration{$key} = $ENV{$key};
164
  }
165
  }
Lines 180-200 $file =~ s/__.*?__/exists $configuration{$&} ? $configuration{$&} : $&/seg; Link Here
180
# to make it writable.  Note that stat and chmod
181
# to make it writable.  Note that stat and chmod
181
# (the Perl functions) should work on Win32
182
# (the Perl functions) should work on Win32
182
my $old_perm;
183
my $old_perm;
183
$old_perm = (stat $fname)[2] & 07777;
184
$old_perm = (stat $fname)[2] & oct(7777);
184
my $new_perm = $old_perm | 0200;
185
my $new_perm = $old_perm | oct(200);
185
chmod $new_perm, $fname;
186
chmod $new_perm, $fname;
186
187
187
open(OUTPUT,">$fname") || die "Can't open $fname for write: $!";
188
open(my $output, ">", $fname) || die "Can't open $fname for write: $!";
188
print OUTPUT $file;
189
print $output $file;
189
close(OUTPUT);
190
close($output);
190
191
191
chmod $old_perm, $fname;
192
chmod $old_perm, $fname;
192
193
193
# Idea taken from perlfaq5
194
# Idea taken from perlfaq5
194
sub read_file($) {
195
sub read_file {
195
  local(*INPUT,$/);
196
  local $/;
196
  open(INPUT,$_[0]) || die "Can't open $_[0] for read";
197
  open(my $fh , '<', $_[0]) || die "Can't open $_[0] for read";
197
  my $file = <INPUT>;
198
  my $file = <$fh>;
199
  close $fh;
198
  return $file;
200
  return $file;
199
}
201
}
200
202
(-)a/svc/holds (-1 lines)
Lines 66-72 my $holds_rs = Koha::Holds->search( Link Here
66
    }
66
    }
67
);
67
);
68
68
69
my $borrower;
70
my @holds;
69
my @holds;
71
while ( my $h = $holds_rs->next() ) {
70
while ( my $h = $holds_rs->next() ) {
72
    my $item = $h->item();
71
    my $item = $h->item();
(-)a/t/00-testcritic.t (-30 / +2 lines)
Lines 1-39 Link Here
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
2
3
# This script can be used to run perlcritic on perl files in koha
3
# This script can be used to run perlcritic on perl files in koha
4
# It calls its own custom perlcriticrc
5
# The script is purely optional requiring Test::Perl::Critic to be installed 
4
# The script is purely optional requiring Test::Perl::Critic to be installed 
6
# and the environment variable TEST_QA to be set
5
# and the environment variable TEST_QA to be set
7
# At present only the directories in @dirs will pass the tests in 'Gentle' mode
8
6
9
use Modern::Perl;
7
use Modern::Perl;
10
use File::Spec;
11
use Test::More;
8
use Test::More;
12
use English qw(-no_match_vars);
9
use English qw(-no_match_vars);
13
10
14
my @dirs = qw(
15
    acqui
16
    admin
17
    authorities
18
    basket
19
    catalogue
20
    cataloguing
21
    circ
22
    debian
23
    errors
24
    labels
25
    members
26
    offline_circ
27
    reserve
28
    reviews
29
    rotating_collections
30
    serials
31
    sms
32
    virtualshelves
33
    Koha
34
    C4/SIP
35
);
36
37
if ( not $ENV{TEST_QA} ) {
11
if ( not $ENV{TEST_QA} ) {
38
    my $msg = 'Author test. Set $ENV{TEST_QA} to a true value to run';
12
    my $msg = 'Author test. Set $ENV{TEST_QA} to a true value to run';
39
    plan( skip_all => $msg );
13
    plan( skip_all => $msg );
Lines 46-52 if ( $EVAL_ERROR ) { Link Here
46
    plan( skip_all => $msg );
20
    plan( skip_all => $msg );
47
}
21
}
48
22
49
my $rcfile = File::Spec->catfile( 't', 'perlcriticrc' );
23
Test::Perl::Critic->import( -profile => '.perlcriticrc');
50
Test::Perl::Critic->import( -profile => $rcfile);
24
all_critic_ok('.');
51
all_critic_ok(@dirs);
52
(-)a/t/Languages.t (-1 / +1 lines)
Lines 37-43 $module_context->mock( Link Here
37
    preference => sub {
37
    preference => sub {
38
        my ($self, $pref) = @_;
38
        my ($self, $pref) = @_;
39
        if ($return_undef) {
39
        if ($return_undef) {
40
            return undef;
40
            return;
41
        } elsif ($pref =~ /language/) {
41
        } elsif ($pref =~ /language/) {
42
            return join ',', @languages;
42
            return join ',', @languages;
43
        } else {
43
        } else {
(-)a/t/Prices.t (-2 / +2 lines)
Lines 42-49 fixtures_ok [ Link Here
42
42
43
my $bookseller_module = Test::MockModule->new('Koha::Acquisition::Bookseller');
43
my $bookseller_module = Test::MockModule->new('Koha::Acquisition::Bookseller');
44
44
45
my ( $basketno_0_0,  $basketno_1_1,  $basketno_1_0,  $basketno_0_1 );
45
my ( $basketno_0_0,  $basketno_1_1 );
46
my ( $invoiceid_0_0, $invoiceid_1_1, $invoiceid_1_0, $invoiceid_0_1 );
46
my ( $invoiceid_0_0, $invoiceid_1_1 );
47
my $today;
47
my $today;
48
48
49
for my $currency_format ( qw( US FR ) ) {
49
for my $currency_format ( qw( US FR ) ) {
(-)a/t/SuggestionEngine.t (-1 / +1 lines)
Lines 13-19 BEGIN { Link Here
13
my $plugindir = File::Spec->rel2abs('Koha/SuggestionEngine/Plugin');
13
my $plugindir = File::Spec->rel2abs('Koha/SuggestionEngine/Plugin');
14
14
15
opendir(my $dh, $plugindir);
15
opendir(my $dh, $plugindir);
16
my @installed_plugins = map { ( /\.pm$/ && -f "$plugindir/$_" && s/\.pm$// ) ? "Koha::SuggestionEngine::Plugin::$_" : () } readdir($dh);
16
my @installed_plugins = map { my $p = $_; ( $p =~ /\.pm$/ && -f "$plugindir/$p" && $p =~ s/\.pm$// ) ? "Koha::SuggestionEngine::Plugin::$p" : () } readdir($dh);
17
my @available_plugins = Koha::SuggestionEngine::AvailablePlugins();
17
my @available_plugins = Koha::SuggestionEngine::AvailablePlugins();
18
18
19
foreach my $plugin (@installed_plugins) {
19
foreach my $plugin (@installed_plugins) {
(-)a/t/db_dependent/Accounts.t (-1 lines)
Lines 61-67 $dbh->do(q|DELETE FROM issues|); Link Here
61
$dbh->do(q|DELETE FROM borrowers|);
61
$dbh->do(q|DELETE FROM borrowers|);
62
62
63
my $branchcode = $library->{branchcode};
63
my $branchcode = $library->{branchcode};
64
my $borrower_number;
65
64
66
my $context = new Test::MockModule('C4::Context');
65
my $context = new Test::MockModule('C4::Context');
67
$context->mock( 'userenv', sub {
66
$context->mock( 'userenv', sub {
(-)a/t/db_dependent/Acquisition/OrderFromSubscription.t (-2 / +1 lines)
Lines 30-36 my $bookseller = Koha::Acquisition::Bookseller->new( Link Here
30
)->store;
30
)->store;
31
31
32
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
32
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
33
my $budgetid;
34
my $bpid = AddBudgetPeriod({
33
my $bpid = AddBudgetPeriod({
35
    budget_period_startdate   => '2015-01-01',
34
    budget_period_startdate   => '2015-01-01',
36
    budget_period_enddate     => '2015-12-31',
35
    budget_period_enddate     => '2015-12-31',
Lines 55-61 my $subscriptionid = NewSubscription( Link Here
55
);
54
);
56
die unless $subscriptionid;
55
die unless $subscriptionid;
57
56
58
my ($basket, $basketno);
57
my $basketno;
59
ok($basketno = NewBasket($bookseller->id, 1), "NewBasket(  " . $bookseller->id . ", 1  ) returns $basketno");
58
ok($basketno = NewBasket($bookseller->id, 1), "NewBasket(  " . $bookseller->id . ", 1  ) returns $basketno");
60
59
61
my $cost = 42.00;
60
my $cost = 42.00;
(-)a/t/db_dependent/Acquisition/OrderUsers.t (-1 lines)
Lines 41-47 my $budgetid = C4::Budgets::AddBudget( Link Here
41
);
41
);
42
my $budget = C4::Budgets::GetBudget($budgetid);
42
my $budget = C4::Budgets::GetBudget($budgetid);
43
43
44
my @ordernumbers;
45
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
44
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( MARC::Record->new, '' );
46
45
47
my $order = Koha::Acquisition::Order->new(
46
my $order = Koha::Acquisition::Order->new(
(-)a/t/db_dependent/Barcodes.t (-2 / +2 lines)
Lines 149-155 my %thash = ( Link Here
149
    EAN13 => ['0000000695152','892685001928'],
149
    EAN13 => ['0000000695152','892685001928'],
150
);
150
);
151
151
152
my ($obj1,$obj2,$format,$value,$initial,$serial,$re,$next,$previous,$temp);
152
my ($obj1,$obj2,$format,$value,$initial,$serial,$next,$previous,$temp);
153
my @formats = sort keys %thash;
153
my @formats = sort keys %thash;
154
foreach (@formats) {
154
foreach (@formats) {
155
    my $pre = sprintf '(%-12s)', $_;
155
    my $pre = sprintf '(%-12s)', $_;
Lines 214-220 foreach (@formats) { Link Here
214
    }
214
    }
215
}
215
}
216
216
217
foreach $format (@formats) {
217
foreach my $format (@formats) {
218
    my $pre = sprintf '(%-12s)', $format;
218
    my $pre = sprintf '(%-12s)', $format;
219
    foreach my $testval (@{$thash{ $format }}) {
219
    foreach my $testval (@{$thash{ $format }}) {
220
        if ($format eq 'hbyymmincr') {
220
        if ($format eq 'hbyymmincr') {
(-)a/t/db_dependent/Context.t (-2 lines)
Lines 68-75 ok($config = $koha->{config}, 'Getting $koha->{config} '); Link Here
68
# Testing syspref caching
68
# Testing syspref caching
69
use Test::DBIx::Class;
69
use Test::DBIx::Class;
70
70
71
my $history;
72
73
my $schema = Koha::Database->new()->schema();
71
my $schema = Koha::Database->new()->schema();
74
$schema->storage->debug(1);
72
$schema->storage->debug(1);
75
my $trace_read;
73
my $trace_read;
(-)a/t/db_dependent/Hold.t (-1 / +1 lines)
Lines 78-84 my $hold = Koha::Hold->new( Link Here
78
$hold->store();
78
$hold->store();
79
79
80
my $b1_cal = C4::Calendar->new( branchcode => $branches[1]->{branchcode} );
80
my $b1_cal = C4::Calendar->new( branchcode => $branches[1]->{branchcode} );
81
$b1_cal->insert_single_holiday( day => 02, month => 01, year => 2017, title => "Morty Day", description => "Rick" ); #Add a holiday
81
$b1_cal->insert_single_holiday( day => 2, month => 1, year => 2017, title => "Morty Day", description => "Rick" ); #Add a holiday
82
my $today = dt_from_string;
82
my $today = dt_from_string;
83
is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days')  , "Age of hold is days from reservedate to now if calendar ignored");
83
is( $hold->age(), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days')  , "Age of hold is days from reservedate to now if calendar ignored");
84
is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used");
84
is( $hold->age(1), $today->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days' ) - 1 , "Age of hold is days from reservedate to now minus 1 if calendar used");
(-)a/t/db_dependent/LDAP/test_ldap_add.pl (-1 / +1 lines)
Lines 46-52 sub hashup { Link Here
46
}
46
}
47
47
48
sub recursive_breakdown {
48
sub recursive_breakdown {
49
	my $dse = shift or return undef;
49
	my $dse = shift or return;
50
	if (ref($dse) =~ /HASH/) {
50
	if (ref($dse) =~ /HASH/) {
51
		return join "\n", map {"$_\t=> " . recursive_breakdown($dse->{$_})} keys %$dse;
51
		return join "\n", map {"$_\t=> " . recursive_breakdown($dse->{$_})} keys %$dse;
52
	} elsif (ref($dse) =~ /ARRAY/) {
52
	} elsif (ref($dse) =~ /ARRAY/) {
(-)a/t/db_dependent/Record/Record.t (-16 / +16 lines)
Lines 45-92 $ ./Record_test.pl Link Here
45
ok (1, 'module compiled');
45
ok (1, 'module compiled');
46
46
47
# open some files for testing
47
# open some files for testing
48
open MARC21MARC8,WHEREAMI."/marc21_marc8.dat" or die $!;
48
open my $MARC21MARC8, '<', WHEREAMI."/marc21_marc8.dat" or die $!;
49
my $marc21_marc8; # = scalar (MARC21MARC8);
49
my $marc21_marc8; # = scalar (MARC21MARC8);
50
foreach my $line (<MARC21MARC8>) {
50
foreach my $line (<$MARC21MARC8>) {
51
    $marc21_marc8 .= $line;
51
    $marc21_marc8 .= $line;
52
}
52
}
53
$marc21_marc8 =~ s/\n$//;
53
$marc21_marc8 =~ s/\n$//;
54
close MARC21MARC8;
54
close $MARC21MARC8;
55
55
56
open (MARC21UTF8,"<:utf8",WHEREAMI."/marc21_utf8.dat") or die $!;
56
open (my $MARC21UTF8, '<:encoding(UTF-8)', WHEREAMI."/marc21_utf8.dat") or die $!;
57
my $marc21_utf8;
57
my $marc21_utf8;
58
foreach my $line (<MARC21UTF8>) {
58
foreach my $line (<$MARC21UTF8>) {
59
	$marc21_utf8 .= $line;
59
	$marc21_utf8 .= $line;
60
}
60
}
61
$marc21_utf8 =~ s/\n$//;
61
$marc21_utf8 =~ s/\n$//;
62
close MARC21UTF8;
62
close $MARC21UTF8;
63
63
64
open MARC21MARC8COMBCHARS,WHEREAMI."/marc21_marc8_combining_chars.dat" or die $!;
64
open(my $MARC21MARC8COMBCHARS, '<', WHEREAMI."/marc21_marc8_combining_chars.dat" or die $!;
65
my $marc21_marc8_combining_chars;
65
my $marc21_marc8_combining_chars;
66
foreach my $line(<MARC21MARC8COMBCHARS>) {
66
foreach my $line(<$MARC21MARC8COMBCHARS>) {
67
	$marc21_marc8_combining_chars.=$line;
67
	$marc21_marc8_combining_chars.=$line;
68
}
68
}
69
$marc21_marc8_combining_chars =~ s/\n$//; #FIXME: why is a newline ending up here?
69
$marc21_marc8_combining_chars =~ s/\n$//; #FIXME: why is a newline ending up here?
70
close MARC21MARC8COMBCHARS;
70
close $MARC21MARC8COMBCHARS;
71
71
72
open (MARC21UTF8COMBCHARS,"<:utf8",WHEREAMI."/marc21_utf8_combining_chars.dat") or die $!;
72
open (my $MARC21UTF8COMBCHARS, '<:encoding(UTF-8)', WHEREAMI."/marc21_utf8_combining_chars.dat") or die $!;
73
my $marc21_utf8_combining_chars;
73
my $marc21_utf8_combining_chars;
74
foreach my $line(<MARC21UTF8COMBCHARS>) {
74
foreach my $line(<$MARC21UTF8COMBCHARS>) {
75
	$marc21_utf8_combining_chars.=$line;
75
	$marc21_utf8_combining_chars.=$line;
76
}
76
}
77
close MARC21UTF8COMBCHARS;
77
close $MARC21UTF8COMBCHARS;
78
78
79
open (MARCXMLUTF8,"<:utf8",WHEREAMI."/marcxml_utf8.xml") or die $!;
79
open (my $MARCXMLUTF8, '<:encoding(UTF-8)', WHEREAMI."/marcxml_utf8.xml") or die $!;
80
my $marcxml_utf8;
80
my $marcxml_utf8;
81
foreach my $line (<MARCXMLUTF8>) {
81
foreach my $line (<$MARCXMLUTF8>) {
82
	$marcxml_utf8 .= $line;
82
	$marcxml_utf8 .= $line;
83
}
83
}
84
close MARCXMLUTF8;
84
close $MARCXMLUTF8;
85
85
86
$marcxml_utf8 =~ s/\n//g;
86
$marcxml_utf8 =~ s/\n//g;
87
87
88
## The Tests:
88
## The Tests:
89
my $error; my $marc; my $marcxml; my $dcxml; # some scalars to store values
89
my $error; my $marc; my $marcxml; # some scalars to store values
90
## MARC to MARCXML
90
## MARC to MARCXML
91
print "\n1. Checking conversion of simple ISO-2709 (MARC21) records to MARCXML\n";
91
print "\n1. Checking conversion of simple ISO-2709 (MARC21) records to MARCXML\n";
92
ok (($error,$marcxml) = marc2marcxml($marc21_marc8,'UTF-8','MARC21'), 'marc2marcxml - from MARC-8 to UTF-8 (MARC21)');
92
ok (($error,$marcxml) = marc2marcxml($marc21_marc8,'UTF-8','MARC21'), 'marc2marcxml - from MARC-8 to UTF-8 (MARC21)');
(-)a/t/db_dependent/Search.t (+6 lines)
Lines 94-99 END { Link Here
94
    cleanup();
94
    cleanup();
95
}
95
}
96
96
97
sub matchesExplodedTerms {
98
    my ($message, $query, @terms) = @_;
99
    my $match = '(' . join ('|', map { " \@attr 1=Subject \@attr 4=1 \"$_\"" } @terms) . "){" . scalar(@terms) . "}";
100
    like($query, qr/$match/, $message);
101
}
102
97
our $QueryStemming = 0;
103
our $QueryStemming = 0;
98
our $QueryAutoTruncate = 0;
104
our $QueryAutoTruncate = 0;
99
our $QueryWeightFields = 0;
105
our $QueryWeightFields = 0;
(-)a/t/db_dependent/Serials.t (-1 lines)
Lines 47-53 my $bookseller = Koha::Acquisition::Bookseller->new( Link Here
47
47
48
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
48
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
49
49
50
my $budgetid;
51
my $bpid = AddBudgetPeriod({
50
my $bpid = AddBudgetPeriod({
52
    budget_period_startdate   => '2015-01-01',
51
    budget_period_startdate   => '2015-01-01',
53
    budget_period_enddate     => '2015-12-31',
52
    budget_period_enddate     => '2015-12-31',
(-)a/t/db_dependent/Serials_2.t (-1 lines)
Lines 38-44 my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); Link Here
38
38
39
my $my_branch = $library1->{branchcode};
39
my $my_branch = $library1->{branchcode};
40
my $another_branch = $library2->{branchcode};
40
my $another_branch = $library2->{branchcode};
41
my $budgetid;
42
my $bpid = AddBudgetPeriod({
41
my $bpid = AddBudgetPeriod({
43
    budget_period_startdate   => '2015-01-01',
42
    budget_period_startdate   => '2015-01-01',
44
    budget_period_enddate     => '2015-12-31',
43
    budget_period_enddate     => '2015-12-31',
(-)a/t/db_dependent/XISBN.t (-1 lines)
Lines 27-33 my $search_module = new Test::MockModule("Koha::SearchEngine::${engine}::Search" Link Here
27
27
28
$search_module->mock('simple_search_compat', \&Mock_simple_search_compat );
28
$search_module->mock('simple_search_compat', \&Mock_simple_search_compat );
29
29
30
my $errors;
31
my $context = C4::Context->new;
30
my $context = C4::Context->new;
32
31
33
my ( $biblionumber_tag, $biblionumber_subfield ) =
32
my ( $biblionumber_tag, $biblionumber_subfield ) =
(-)a/t/db_dependent/cronjobs/advance_notices_digest.t (-5 / +1 lines)
Lines 177-190 sub run_script { Link Here
177
    my $script = shift;
177
    my $script = shift;
178
    local @ARGV = @_;
178
    local @ARGV = @_;
179
179
180
    ## no critic
181
182
    # We simulate script execution by evaluating the script code in the context
180
    # We simulate script execution by evaluating the script code in the context
183
    # of this unit test.
181
    # of this unit test.
184
182
185
    eval $script; #Violates 'ProhibitStringyEval'
183
    eval $script; ## no critic (StringyEval)
186
187
    ## use critic
188
184
189
    die $@ if $@;
185
    die $@ if $@;
190
}
186
}
(-)a/t/db_dependent/www/auth_values_input_www.t (-1 lines)
Lines 57-63 my $dbh = C4::Context->dbh; Link Here
57
$intranet =~ s#/$##;
57
$intranet =~ s#/$##;
58
58
59
my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
59
my $agent = Test::WWW::Mechanize->new( autocheck => 1 );
60
my $jsonresponse;
61
my ($category, $expected_base, $add_form_link_exists, $delete_form_link_exists);
60
my ($category, $expected_base, $add_form_link_exists, $delete_form_link_exists);
62
61
63
# -------------------------------------------------- LOGIN
62
# -------------------------------------------------- LOGIN
(-)a/t/dummy.t (+1 lines)
Lines 1-3 Link Here
1
# Dummy test until Test::Harness or similar
1
# Dummy test until Test::Harness or similar
2
# is used by the other tests to check deps.
2
# is used by the other tests to check deps.
3
use Modern::Perl;
3
print "1..1\nok 1\n";
4
print "1..1\nok 1\n";
(-)a/tags/review.pl (-3 / +3 lines)
Lines 36-42 use C4::Tags qw(get_tags get_approval_rows approval_counts whitelist blacklist i Link Here
36
my $script_name = "/cgi-bin/koha/tags/review.pl";
36
my $script_name = "/cgi-bin/koha/tags/review.pl";
37
my $needed_flags = { tools => 'moderate_tags' };    # FIXME: replace when more specific permission is created.
37
my $needed_flags = { tools => 'moderate_tags' };    # FIXME: replace when more specific permission is created.
38
38
39
sub ajax_auth_cgi ($) { # returns CGI object
39
sub ajax_auth_cgi { # returns CGI object
40
    my $needed_flags = shift;
40
    my $needed_flags = shift;
41
    my %cookies = CGI::Cookie->fetch;
41
    my %cookies = CGI::Cookie->fetch;
42
    my $input = CGI->new;
42
    my $input = CGI->new;
Lines 122-129 foreach (keys %$counts) { Link Here
122
    $template->param($_ => $counts->{$_});
122
    $template->param($_ => $counts->{$_});
123
}
123
}
124
124
125
sub pagination_calc ($;$) {
125
sub pagination_calc {
126
    my $query = shift or return undef;
126
    my $query = shift or return;
127
    my $hardlimit = (@_) ? shift : 100;     # hardcoded, could be another syspref
127
    my $hardlimit = (@_) ? shift : 100;     # hardcoded, could be another syspref
128
    my $pagesize = $query->param('limit' ) || $hardlimit;
128
    my $pagesize = $query->param('limit' ) || $hardlimit;
129
    my $page     = $query->param('page'  ) || 1;
129
    my $page     = $query->param('page'  ) || 1;
(-)a/tools/batchMod.pl (-2 / +1 lines)
Lines 82-88 $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrar Link Here
82
82
83
$template->param(del       => $del);
83
$template->param(del       => $del);
84
84
85
my $itemrecord;
86
my $nextop="";
85
my $nextop="";
87
my @errors; # store errors found while checking data BEFORE saving item.
86
my @errors; # store errors found while checking data BEFORE saving item.
88
my $items_display_hashref;
87
my $items_display_hashref;
Lines 391-397 foreach my $tag (sort keys %{$tagslib}) { Link Here
391
	$subfield_data{marc_lib}   ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
390
	$subfield_data{marc_lib}   ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
392
	$subfield_data{mandatory}  = $tagslib->{$tag}->{$subfield}->{mandatory};
391
	$subfield_data{mandatory}  = $tagslib->{$tag}->{$subfield}->{mandatory};
393
	$subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable};
392
	$subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable};
394
	my ($x,$value);
393
	my $value;
395
   if ( $use_default_values) {
394
   if ( $use_default_values) {
396
	    $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
395
	    $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
397
	    # get today date & replace YYYY, MM, DD if provided in the default value
396
	    # get today date & replace YYYY, MM, DD if provided in the default value
(-)a/tools/export.pl (-2 lines)
Lines 93-100 if ( $op eq "export" ) { Link Here
93
    my @biblionumbers      = $query->multi_param("biblionumbers");
93
    my @biblionumbers      = $query->multi_param("biblionumbers");
94
    my @itemnumbers        = $query->multi_param("itemnumbers");
94
    my @itemnumbers        = $query->multi_param("itemnumbers");
95
    my $strip_items_not_from_libraries =  $query->param('strip_items_not_from_libraries');
95
    my $strip_items_not_from_libraries =  $query->param('strip_items_not_from_libraries');
96
    my @sql_params;
97
    my $sql_query;
98
96
99
    my $libraries = Koha::Libraries->search_filtered->unblessed;
97
    my $libraries = Koha::Libraries->search_filtered->unblessed;
100
    my $only_export_items_for_branches = $strip_items_not_from_libraries ? \@branch : undef;
98
    my $only_export_items_for_branches = $strip_items_not_from_libraries ? \@branch : undef;
(-)a/tools/import_borrowers.pl (-3 lines)
Lines 58-64 use Text::CSV; Link Here
58
58
59
use CGI qw ( -utf8 );
59
use CGI qw ( -utf8 );
60
60
61
my ( @errors, @feedback );
62
my $extended = C4::Context->preference('ExtendedPatronAttributes');
61
my $extended = C4::Context->preference('ExtendedPatronAttributes');
63
62
64
my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns();
63
my @columnkeys = map { $_ ne 'borrowernumber' ? $_ : () } Koha::Patrons->columns();
Lines 67-74 push( @columnkeys, qw( relationship guarantor_id guarantor_firstname guarantor_ Link Here
67
66
68
my $input = CGI->new();
67
my $input = CGI->new();
69
68
70
#push @feedback, {feedback=>1, name=>'backend', value=>$csv->backend, backend=>$csv->backend}; #XXX
71
72
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
73
    {
70
    {
74
        template_name   => "tools/import_borrowers.tt",
71
        template_name   => "tools/import_borrowers.tt",
(-)a/tools/letter.pl (-1 / +1 lines)
Lines 191-197 sub add_form { Link Here
191
            code       => $code,
191
            code       => $code,
192
        );
192
        );
193
        my $first_flag_name = 1;
193
        my $first_flag_name = 1;
194
        my ( $lang, @templates );
194
        my $lang;
195
        # The letter name is contained into each mtt row.
195
        # The letter name is contained into each mtt row.
196
        # So we can only sent the first one to the template.
196
        # So we can only sent the first one to the template.
197
        for my $letter ( @$letters ) {
197
        for my $letter ( @$letters ) {
(-)a/tools/modborrowers.pl (-2 / +1 lines)
Lines 63-72 if ( $op eq 'show' ) { Link Here
63
    my $patron_list_id = $input->param('patron_list_id');
63
    my $patron_list_id = $input->param('patron_list_id');
64
    my @borrowers;
64
    my @borrowers;
65
    my @cardnumbers;
65
    my @cardnumbers;
66
    my ( @notfoundcardnumbers, @from_another_group_of_libraries );
66
    my @notfoundcardnumbers;
67
67
68
    # Get cardnumbers from a file or the input area
68
    # Get cardnumbers from a file or the input area
69
    my @contentlist;
70
    if ($filefh) {
69
    if ($filefh) {
71
        while ( my $content = <$filefh> ) {
70
        while ( my $content = <$filefh> ) {
72
            $content =~ s/[\r\n]*$//g;
71
            $content =~ s/[\r\n]*$//g;
(-)a/tools/overduerules.pl (-2 lines)
Lines 215-222 my $letters = C4::Letters::GetLettersAvailableForALibrary( Link Here
215
    }
215
    }
216
);
216
);
217
217
218
my @line_loop;
219
220
my $message_transport_types = C4::Letters::GetMessageTransportTypes();
218
my $message_transport_types = C4::Letters::GetMessageTransportTypes();
221
my ( @first, @second, @third );
219
my ( @first, @second, @third );
222
for my $patron_category (@patron_categories) {
220
for my $patron_category (@patron_categories) {
(-)a/tools/picture-upload.pl (-7 / +7 lines)
Lines 219-225 sub handle_dir { Link Here
219
              if ( $filename =~ m/datalink\.txt/i
219
              if ( $filename =~ m/datalink\.txt/i
220
                || $filename =~ m/idlink\.txt/i );
220
                || $filename =~ m/idlink\.txt/i );
221
        }
221
        }
222
        unless ( open( FILE, $file ) ) {
222
        my $fh;
223
        unless ( open( $fh, '<', $file ) ) {
223
            warn "Opening $dir/$file failed!";
224
            warn "Opening $dir/$file failed!";
224
            $direrrors{'OPNLINK'} = $file;
225
            $direrrors{'OPNLINK'} = $file;
225
            # This error is fatal to the import of this directory contents
226
            # This error is fatal to the import of this directory contents
Lines 227-233 sub handle_dir { Link Here
227
            return \%direrrors;
228
            return \%direrrors;
228
        }
229
        }
229
230
230
        while ( my $line = <FILE> ) {
231
        while ( my $line = <$fh> ) {
231
            $debug and warn "Reading contents of $file";
232
            $debug and warn "Reading contents of $file";
232
            chomp $line;
233
            chomp $line;
233
            $debug and warn "Examining line: $line";
234
            $debug and warn "Examining line: $line";
Lines 247-253 sub handle_dir { Link Here
247
            $source = "$dir/$filename";
248
            $source = "$dir/$filename";
248
            %counts = handle_file( $cardnumber, $source, $template, %counts );
249
            %counts = handle_file( $cardnumber, $source, $template, %counts );
249
        }
250
        }
250
        close FILE;
251
        close $fh;
251
        closedir DIR;
252
        closedir DIR;
252
    }
253
    }
253
    else {
254
    else {
Lines 290-298 sub handle_file { Link Here
290
            return %count;
291
            return %count;
291
        }
292
        }
292
        my ( $srcimage, $image );
293
        my ( $srcimage, $image );
293
        if ( open( IMG, "$source" ) ) {
294
        if ( open( my $fh, '<', $source ) ) {
294
            $srcimage = GD::Image->new(*IMG);
295
            $srcimage = GD::Image->new($fh);
295
            close(IMG);
296
            close($fh);
296
            if ( defined $srcimage ) {
297
            if ( defined $srcimage ) {
297
                my $imgfile;
298
                my $imgfile;
298
                my $mimetype = 'image/png';
299
                my $mimetype = 'image/png';
Lines 343-349 sub handle_file { Link Here
343
                    undef $srcimage; # This object can get big...
344
                    undef $srcimage; # This object can get big...
344
                }
345
                }
345
                $debug and warn "Image is of mimetype $mimetype";
346
                $debug and warn "Image is of mimetype $mimetype";
346
                my $dberror;
347
                if ($mimetype) {
347
                if ($mimetype) {
348
                    my $patron = Koha::Patrons->find({ cardnumber => $cardnumber });
348
                    my $patron = Koha::Patrons->find({ cardnumber => $cardnumber });
349
                    if ( $patron ) {
349
                    if ( $patron ) {
(-)a/tools/upload-cover-image.pl (-3 / +3 lines)
Lines 132-139 if ($fileID) { Link Here
132
                else {
132
                else {
133
                    next;
133
                    next;
134
                }
134
                }
135
                if ( open( FILE, $file ) ) {
135
                if ( open( my $fh, '<', $file ) ) {
136
                    while ( my $line = <FILE> ) {
136
                    while ( my $line = <$fh> ) {
137
                        my $delim =
137
                        my $delim =
138
                            ( $line =~ /\t/ ) ? "\t"
138
                            ( $line =~ /\t/ ) ? "\t"
139
                          : ( $line =~ /,/ )  ? ","
139
                          : ( $line =~ /,/ )  ? ","
Lines 171-177 if ($fileID) { Link Here
171
                            undef $srcimage;
171
                            undef $srcimage;
172
                        }
172
                        }
173
                    }
173
                    }
174
                    close(FILE);
174
                    close($fh);
175
                }
175
                }
176
                else {
176
                else {
177
                    $error = 'OPNLINK';
177
                    $error = 'OPNLINK';
(-)a/xt/author/show-template-structure.pl (-3 / +3 lines)
Lines 56-62 Output is sent to STDOUT. Link Here
56
56
57
scalar(@ARGV) == 1 or die "Usage: $0 template-file\n";
57
scalar(@ARGV) == 1 or die "Usage: $0 template-file\n";
58
my $file = $ARGV[0];
58
my $file = $ARGV[0];
59
open IN, $file or die "Failed to open template file $file: $!\n";
59
open my $fh, '<', $file or die "Failed to open template file $file: $!\n";
60
60
61
my %valid_tmpl_tags = (
61
my %valid_tmpl_tags = (
62
    tmpl_var     => 1,
62
    tmpl_var     => 1,
Lines 87-93 sub emit { Link Here
87
    print "  " x ( $level - 1 ), shift;
87
    print "  " x ( $level - 1 ), shift;
88
}
88
}
89
89
90
while (<IN>) {
90
while (<$fh>) {
91
    $lineno++;
91
    $lineno++;
92
92
93
    # look for TMPL_IF, TMPL_ELSE, TMPL_UNLESS, and TMPL_LOOPs in HTML comments
93
    # look for TMPL_IF, TMPL_ELSE, TMPL_UNLESS, and TMPL_LOOPs in HTML comments
Lines 147-153 while (<IN>) { Link Here
147
    }
147
    }
148
}
148
}
149
149
150
close IN;
150
close $fh;
151
151
152
# anything left in the stack?
152
# anything left in the stack?
153
if (scalar @tag_stack > 0) {
153
if (scalar @tag_stack > 0) {
(-)a/xt/author/translatable-templates.t (-1 / +1 lines)
Lines 69-75 sub test_string_extraction { Link Here
69
69
70
    my $command = "PERL5LIB=\$PERL5LIB:$misc_translator_dir ./tmpl_process3.pl create -i $template_dir -s $po_dir/$module.po -r --pedantic-warnings";
70
    my $command = "PERL5LIB=\$PERL5LIB:$misc_translator_dir ./tmpl_process3.pl create -i $template_dir -s $po_dir/$module.po -r --pedantic-warnings";
71
   
71
   
72
    open (NULL, ">", File::Spec->devnull);
72
    open (NULL, ">", File::Spec->devnull); ## no critic (BarewordFileHandles)
73
    print NULL "foo"; # avoid warning;
73
    print NULL "foo"; # avoid warning;
74
    my $pid = open3(gensym, ">&NULL", \*PH, $command); 
74
    my $pid = open3(gensym, ">&NULL", \*PH, $command); 
75
    my @warnings;
75
    my @warnings;
(-)a/xt/find-license-problems.t (-2 / +3 lines)
Lines 42-51 sub wanted { Link Here
42
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir());
42
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir());
43
43
44
foreach my $name (@files) {
44
foreach my $name (@files) {
45
    open( FILE, $name ) || die "cannot open file $name $!";
45
    open( my $fh, '<', $name ) || die "cannot open file $name $!";
46
    my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense,
46
    my ( $hascopyright, $hasgpl, $hasv3, $hasorlater, $haslinktolicense,
47
        $hasfranklinst, $is_not_us ) = (0)x7;
47
        $hasfranklinst, $is_not_us ) = (0)x7;
48
    while ( my $line = <FILE> ) {
48
    while ( my $line = <$fh> ) {
49
        $hascopyright = 1 if ( $line =~ /^(#|--)?\s*Copyright.*\d\d/ );
49
        $hascopyright = 1 if ( $line =~ /^(#|--)?\s*Copyright.*\d\d/ );
50
        $hasgpl       = 1 if ( $line =~ /GNU General Public License/ );
50
        $hasgpl       = 1 if ( $line =~ /GNU General Public License/ );
51
        $hasv3        = 1 if ( $line =~ /either version 3/ );
51
        $hasv3        = 1 if ( $line =~ /either version 3/ );
Lines 56-61 foreach my $name (@files) { Link Here
56
        $hasfranklinst    = 1 if ( $line =~ /51 Franklin Street/ );
56
        $hasfranklinst    = 1 if ( $line =~ /51 Franklin Street/ );
57
        $is_not_us        = 1 if $line =~ m|This file is part of the Zebra server|;
57
        $is_not_us        = 1 if $line =~ m|This file is part of the Zebra server|;
58
    }
58
    }
59
    close $fh;
59
    next unless $hascopyright;
60
    next unless $hascopyright;
60
    next if $is_not_us;
61
    next if $is_not_us;
61
    is(    $hasgpl
62
    is(    $hasgpl
(-)a/xt/fix-old-fsf-address (-4 / +4 lines)
Lines 112-130 sub dashcomment { Link Here
112
112
113
sub readfile {
113
sub readfile {
114
    my ($filename) = @_;
114
    my ($filename) = @_;
115
    open(FILE, $filename) || die("Can't open $filename for reading");
115
    open(my $fh, '<', $filename) || die("Can't open $filename for reading");
116
    my @lines;
116
    my @lines;
117
    while (my $line = <FILE>) {
117
    while (my $line = <$fh>) {
118
        push @lines, $line;
118
        push @lines, $line;
119
    }
119
    }
120
    close(FILE);
120
    close($fh);
121
    return join '', @lines;
121
    return join '', @lines;
122
}
122
}
123
123
124
124
125
sub try_to_fix {
125
sub try_to_fix {
126
    my ($data, @patterns) = @_;
126
    my ($data, @patterns) = @_;
127
    return undef;
127
    return;
128
}
128
}
129
129
130
130
(-)a/xt/single_quotes.t (-2 / +1 lines)
Lines 42-48 close $dh; Link Here
42
my @files;
42
my @files;
43
find(
43
find(
44
    sub {
44
    sub {
45
        open my $fh, $_ or die "Could not open $_: $!";
45
        open my $fh, '<', $_ or die "Could not open $_: $!";
46
        my @lines = sort grep /\_\(\'/, <$fh>;
46
        my @lines = sort grep /\_\(\'/, <$fh>;
47
        push @files, { name => "$_", lines => \@lines } if @lines;
47
        push @files, { name => "$_", lines => \@lines } if @lines;
48
    },
48
    },
49
- 

Return to bug 21395