|| $interface eq 'opac'
|| $interface eq 'intranet'
|| $interface eq 'sip'
+ || $interface eq 'cron'
|| $interface eq 'commandline' )
{
$context->{interface} = $interface;
--- /dev/null
+package Koha::Cron;
+
+# Copyright PTFS Europe 2019
+# Copyright 2019 Koha Development Team
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+=head1 NAME
+
+Koha::Cron - Koha Cron scripts base class
+
+=head1 SYNOPSIS
+
+ use Koha::Cron;
+
+=head1 DESCRIPTION
+
+This class should be used in all cronscripts. It sets the interface and userenv appropriately.
+
+=cut
+
+use C4::Context;
+
+# Set userenv
+C4::Context->_new_userenv(1);
+C4::Context->set_userenv(
+ undef, undef, undef, 'CRON', 'CRON', undef,
+ undef, undef, undef, undef, undef
+);
+
+# Set interface
+C4::Context->interface('cron');
+
+=head1 AUTHOR
+
+Martin Renvoize <martin.renvoize@ptfs-europe.com>
+
+=cut
+
+1;
use FindBin;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Biblio;
use C4::Context;
use C4::Letters;
unless ($confirm) {
pod2usage(1);
}
-
cronlogaction();
# The fields that will be substituted into <<items.content>>
use Pod::Usage;
use JSON;
+use Koha::Cron;
use C4::Context;
use C4::Items;
use Pod::Usage;
use Getopt::Long;
+use Koha::Cron;
use C4::Circulation;
use C4::Context;
use C4::Log;
) || pod2usage(1);
pod2usage(0) if $help;
-
cronlogaction();
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Context;
use Koha::Patrons;
use Date::Calc qw(
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Koha;
use C4::Context;
use C4::Biblio;
use strict;
use warnings;
+use Koha::Cron;
use C4::Items qw/ CartToShelf /;
use C4::Log;
use Modern::Perl;
use Pod::Usage;
use Getopt::Long;
+
+use Koha::Cron;
use C4::Context;
use C4::Biblio;
use AnyEvent;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
+use Koha::Cron;
use C4::Biblio;
use Pod::Usage;
use Getopt::Long;
+use Koha::Cron;
use C4::Context;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Context;
use C4::Search;
use C4::Search::History;
use YAML::Syck;
use Pod::Usage;
use Getopt::Long;
+
+use Koha::Cron;
use C4::Context;
use C4::Log;
exit;
}
-usage() if $help || !$conf;
+usage() if $help || !$conf;
cronlogaction();
use DBI;
use Getopt::Long;
use Pod::Usage;
+
+use Koha::Cron;
use C4::Context;
use English qw(-no_match_vars);
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
-
my %wanted_borrowers_columns = map { $_ => 1 } qw/borrowernumber cardnumber surname firstname address city phone dateofbirth/;
my %wanted_issues_columns = map { $_ => 1 } qw/borrowernumber date_due itemcallnumber title itemtype/;
eval { my $lib = "$FindBin::Bin/../kohalib.pl"; require $lib };
}
+use Koha::Cron;
use C4::Context;
my $help;
#! /usr/bin/perl
use Getopt::Long;
+
+use Koha::Cron;
use C4::Context;
use C4::Items;
use C4::Circulation;
use Pod::Usage;
use Getopt::Long;
+use Koha::Cron;
use C4::Members;
use Koha::DateUtils;
use Koha::Patrons;
use Getopt::Long;
use Pod::Usage;
+use Koha::Cron;
use C4::Biblio;
use C4::Items;
use Koha::Database;
# can be run as frequently as required
# log messages are appended to logdir/editrace.log
+use Koha::Cron;
use C4::Context;
use Log::Log4perl qw(:easy);
use Koha::Database;
use warnings;
use 5.010;
+use Koha::Cron;
use C4::Context;
use C4::Overdues;
use Getopt::Long;
}
use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
+use Koha::Cron;
use C4::Context;
use C4::Debug;
use C4::Letters;
# cancel all expired hold requests
+use Koha::Cron;
use C4::Reserves;
use C4::Log;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::HoldsQueue qw(CreateQueue);
use C4::Log;
# cancel all expired hold requests
+use Koha::Cron;
use C4::Reserves;
use C4::Log;
use Getopt::Long;
use Pod::Usage;
+use Koha::Cron;
use C4::Reserves;
use C4::Log;
use Koha::Holds;
use Getopt::Long;
use Pod::Usage;
+use Koha::Cron;
use C4::ImportBatch;
my ($help, $framework);
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Context;
use C4::Members;
use Getopt::Long;
use FindBin;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+
+use Koha::Cron;
use C4::Context;
use C4::Items;
use C4::Circulation qw/LostItem MarkIssueReturned/;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Context;
use C4::Letters;
use C4::Log;
use Pod::Usage;
use Time::HiRes qw(gettimeofday);
+use Koha::Cron;
use C4::AuthoritiesMarc;
use Koha::Authority::MergeRequests;
);
$|=1; # flushes output
-if( $params->{batch} ) {
- handle_batch( $params );
+if ( $params->{batch} ) {
+ handle_batch($params);
} else {
pod2usage(1);
}
use Pod::Usage;
use Getopt::Long;
+use Koha::Cron;
use C4::Budgets qw( GetBudget );
use C4::Suggestions qw( GetUnprocessedSuggestions );
use Koha::Libraries;
use DateTime;
use DateTime::Duration;
+use Koha::Cron;
use C4::Context;
use C4::Letters;
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
-
cronlogaction() unless $test_mode;
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
use FindBin;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+
+use Koha::Cron;
use C4::Letters;
use C4::Log;
use Getopt::Long;
use Getopt::Long;
use Pod::Usage;
+
+use Koha::Cron;
use C4::Suggestions;
use C4::Log;
use C4::Context;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Log;
use Koha::Account::Lines;
) or pod2usage(2);
pod2usage(1) if $help;
-
cronlogaction();
my @patron_ids = map { $_->borrowernumber } Koha::Account::Lines->search(
use strict;
use warnings;
+use Koha::Cron;
use C4::Context;
# this script will remove those older than 5 days
use Modern::Perl;
use Template;
+
+use Koha::Cron;
use C4::Context;
use Time::Local;
use POSIX;
use Modern::Perl;
+use Koha::Cron;
use C4::Reports::Guided; # 0.12
use Koha::Reports;
use C4::Context;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Cron;
use C4::Context;
use C4::Debug;
use C4::Serials;
use Pod::Usage;
use Getopt::Long;
+use Koha::Cron;
use C4::Context;
use C4::UsageStats;
use C4::Log;
use utf8;
use Pod::Usage;
use Getopt::Long;
+
+use Koha::Cron;
use C4::Biblio;
use Koha::Sitemapper;
#!/usr/bin/perl
use Modern::Perl;
+
+use Koha::Cron;
use C4::SocialData;
my $results = C4::SocialData::get_report;
#!/usr/bin/perl
use Modern::Perl;
+
+use Koha::Cron;
use C4::Context;
use C4::SocialData;
use Date::Calc qw/Date_to_Days/;
+use Koha::Cron;
use C4::Context;
use C4::Circulation;
use C4::Overdues;
use Modern::Perl;
use Getopt::Long qw/HelpMessage :config gnu_getopt/;
+
+use Koha::Cron;
use C4::Context;
use C4::Letters;
use Koha::StockRotationRotas;
use Getopt::Long;
use Pod::Usage;
+use Koha::Cron;
use C4::Context;
sub usage {
use Getopt::Long;
use Pod::Usage;
+use Koha::Cron;
use C4::Context;
use C4::Items;
use C4::Letters;
use Getopt::Long;
use Pod::Usage;
+
+use Koha::Cron;
use C4::Context;
use C4::Biblio;
use C4::Log;
use Modern::Perl;
use DBI;
-use Test::More tests => 26;
+use Test::More tests => 27;
use Test::MockModule;
BEGIN {
#Bug 14751
is( C4::Context->interface( 'SiP' ), 'sip', 'interface SiP' );
is( C4::Context->interface( 'COMMANDLINE' ), 'commandline', 'interface commandline uc' );
+is( C4::Context->interface( 'CRON' ), 'cron', 'interface cron uc' );
--- /dev/null
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use Test::More tests => 3;
+
+BEGIN { use_ok('Koha::Cron') }
+
+use C4::Context;
+
+my $userenv = C4::Context->userenv;
+is_deeply(
+ $userenv,
+ {
+ 'surname' => 'CRON',
+ 'id' => undef,
+ 'flags' => undef,
+ 'cardnumber' => undef,
+ 'firstname' => 'CRON',
+ 'branchname' => undef,
+ 'branchprinter' => undef,
+ 'emailaddress' => undef,
+ 'number' => undef,
+ 'shibboleth' => undef,
+ 'branch' => undef
+ },
+ "Context userenv set correctly"
+);
+
+my $interface = C4::Context->interface;
+is($interface, 'cron', "Context interface set correctly");
+
+1;