+++ /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;
--- /dev/null
+package Koha::Script;
+
+# 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::Script - Koha scripts base class
+
+=head1 SYNOPSIS
+
+ use Koha::Script
+ use Koha::Script -cron;
+
+=head1 DESCRIPTION
+
+This class should be used in all scripts. It sets the interface and userenv appropriately.
+
+=cut
+
+use C4::Context;
+
+sub import {
+ my $class = shift;
+ my @flags = @_;
+
+ C4::Context->_new_userenv(1);
+ if ( ( $flags[0] || '' ) eq '-cron' ) {
+
+ # 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');
+
+ }
+ else {
+ # Set userenv
+ C4::Context->set_userenv(
+ undef, undef, undef, 'CLI', 'CLI', undef,
+ undef, undef, undef, undef, undef
+ );
+
+ # Set interface
+ C4::Context->interface('commandline');
+ }
+}
+
+=head1 AUTHOR
+
+Martin Renvoize <martin.renvoize@ptfs-europe.com>
+
+=cut
+
+1;
# along with Koha; if not, see <http://www.gnu.org/licenses>.
#
+use Koha::Script;
use C4::Boolean;
use C4::Context;
use C4::Debug;
}
# Koha modules used
+use Koha::Script;
use C4::Context;
use MARC::File::USMARC;
use MARC::Record;
}
# Koha modules used
+use Koha::Script;
use MARC::Record;
use C4::Context;
use C4::Biblio;
# Koha modules used
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use MARC::Record;
}
# Koha modules used
+use Koha::Script;
use MARC::Record;
use C4::Context;
use C4::Biblio;
use Pod::Usage;
use Time::HiRes qw(gettimeofday);
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::Items;
}
# Koha modules used
-
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use Pod::Usage;
use IO::File;
+use Koha::Script;
use C4::Biblio;
my ($help, $files);
use File::Find;
+use Koha::Script;
use C4::Context;
@ARGV = qw(.) unless @ARGV;
eval { require "$FindBin::Bin/kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::ImportBatch;
use Getopt::Long;
use FindBin;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Biblio;
use C4::Context;
use C4::Letters;
use Pod::Usage;
use JSON;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Items;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Circulation;
use C4::Context;
use C4::Log;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use Koha::Patrons;
use Date::Calc qw(
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Koha;
use C4::Context;
use C4::Biblio;
use strict;
use warnings;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Items qw/ CartToShelf /;
use C4::Log;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Biblio;
use AnyEvent;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Biblio;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Search;
use C4::Search::History;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Log;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use English qw(-no_match_vars);
eval { my $lib = "$FindBin::Bin/../kohalib.pl"; require $lib };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
my $help;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Items;
use C4::Circulation;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Members;
use Koha::DateUtils;
use Koha::Patrons;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -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 Koha::Script -cron;
use C4::Context;
use Log::Log4perl qw(:easy);
use Koha::Database;
use warnings;
use 5.010;
-use Koha::Cron;
+use Koha::Script -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 Koha::Script -cron;
use C4::Context;
use C4::Debug;
use C4::Letters;
# cancel all expired hold requests
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Reserves;
use C4::Log;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::HoldsQueue qw(CreateQueue);
use C4::Log;
# cancel all expired hold requests
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Reserves;
use C4::Log;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Reserves;
use C4::Log;
use Koha::Holds;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::ImportBatch;
my ($help, $framework);
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Members;
use Getopt::Long;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Items;
use C4::Circulation qw/LostItem MarkIssueReturned/;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Letters;
use C4::Log;
use Pod::Usage;
use Time::HiRes qw(gettimeofday);
-use Koha::Cron;
+use Koha::Script -cron;
use C4::AuthoritiesMarc;
use Koha::Authority::MergeRequests;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Budgets qw( GetBudget );
use C4::Suggestions qw( GetUnprocessedSuggestions );
use Koha::Libraries;
use DateTime;
use DateTime::Duration;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Letters;
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Letters;
use C4::Log;
use Getopt::Long;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Suggestions;
use C4::Log;
use C4::Context;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Log;
use Koha::Account::Lines;
use strict;
use warnings;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
# this script will remove those older than 5 days
use Template;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use Time::Local;
use POSIX;
use Modern::Perl;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Reports::Guided; # 0.12
use Koha::Reports;
use C4::Context;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Debug;
use C4::Serials;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::UsageStats;
use C4::Log;
use Pod::Usage;
use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Biblio;
use Koha::Sitemapper;
use Modern::Perl;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::SocialData;
my $results = C4::SocialData::get_report;
use Modern::Perl;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::SocialData;
use Date::Calc qw/Date_to_Days/;
-use Koha::Cron;
+use Koha::Script -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 Koha::Script -cron;
use C4::Context;
use C4::Letters;
use Koha::StockRotationRotas;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
sub usage {
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Items;
use C4::Letters;
use Getopt::Long;
use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
use C4::Context;
use C4::Biblio;
use C4::Log;
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use Koha::Patrons;
my ( $help, $surname, $userid, $password, $branchcode, $categorycode, $cardnumber );
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use C4::Installer;
use C4::Context;
use Text::CSV;
use Getopt::Long qw(:config no_ignore_case);
+use Koha::Script;
use C4::Context;
use Koha::Patrons;
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use C4::Auth;
use C4::Context;
use C4::Record;
eval { require "$FindBin::Bin/kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::Auth;
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use Koha::Patrons::Import;
my $Import = Koha::Patrons::Import->new();
eval { require "$FindBin::Bin/kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use Getopt::Long;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Biblio;
sub process {
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Biblio;
use Getopt::Long;
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use Koha::Authorities;
use Koha::Authority::Subfields;
use Koha::MetadataRecord::Authority;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::Members::Messaging;
use Getopt::Long;
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use C4::Context;
my $dbh = C4::Context->dbh;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use Getopt::Long;
use Pod::Usage;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::Installer;
use Pod::Usage;
use YAML;
use Try::Tiny;
+use Koha::Script;
use C4::Context;
use C4::Context;
use C4::Tags;
+use Koha::Script;
use Koha::Database;
use Koha::Tags;
use Koha::Tags::Approvals;
use warnings;
use 5.010;
+use Koha::Script;
use Koha::Indexer::Utils;
use Getopt::Long;
use strict;
use warnings;
+
+use Koha::Script;
use Koha::RecordProcessor;
use Data::Dumper;
use C4::Biblio;
use warnings;
$|=1;
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use Getopt::Long;
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
+
+use Koha::Script;
use C4::Charset qw( SanitizeRecord );
use C4::Context;
use DBI;
use Modern::Perl;
+use Koha::Script;
use Koha::Items;
use Koha::Biblioitems;
use Koha::ItemTypes;
# possible modules to use
use Getopt::Long;
+
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use Pod::Usage;
# possible modules to use
use Getopt::Long;
+
+use Koha::Script;
use C4::Context;
use C4::Items;
use Pod::Usage;
use List::MoreUtils qw/uniq/;
use Pod::Usage;
+use Koha::Script;
use C4::AuthoritiesMarc qw/AddAuthority DelAuthority GetAuthority merge/;
my ( @authid, $confirm, $delete, $help, $merge, $reference, $renumber, $verbose );
#use warnings; FIXME - Bug 2505
# Koha modules used
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::AuthoritiesMarc;
use MARC::File::USMARC;
use MARC::Record;
use MARC::Batch;
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::AuthoritiesMarc;
#use warnings; FIXME - Bug 2505
# Koha modules used
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::AuthoritiesMarc;
use List::MoreUtils qw/uniq/;
use Getopt::Std;
+use Koha::Script;
use C4::Context;
use C4::Charset qw/StripNonXmlChars/;
use C4::Biblio;
use MARC::Batch;
use MARC::Charset;
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::Koha;
# Koha modules used
use MARC::Record;
+use Koha::Script;
use C4::Context;
use Getopt::Long;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::Items;
use strict;
#use warnings; FIXME - Bug 2505
-use C4::Context;
+
+use Koha::Script;
+use C4::Context;
use C4::Items;
use C4::Biblio;
use Getopt::Long;
use Text::CSV;
+use Koha::Script;
use C4::Context;
use C4::Biblio;
use C4::Koha qw( GetVariationsOfISBN );
use Modern::Perl;
+use Koha::Script;
use C4::Context;
use Getopt::Long;
use Fcntl qw(:flock);
use strict;
use warnings;
+use Koha::Script;
use C4::Context;
use C4::AuthoritiesMarc;
use Getopt::Long;
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
use C4::Biblio;
use C4::Context;
use Getopt::Long;
use strict;
#use warnings; FIXME - Bug 2505
-use C4::Context;
+
+use Koha::Script;
+use C4::Context;
use C4::Items;
use C4::Biblio;
use Getopt::Long;
use Pod::Usage;
+use Koha::Script;
use C4::Biblio;
my @biblios;
use strict;
use warnings;
+
+use Koha::Script;
use C4::Context;
use C4::Items;
use Data::Dumper;
use autodie;
use Getopt::Long;
+use Koha::Script;
use C4::Context;
use Koha::MetadataRecord::Authority;
use Koha::BiblioUtils;
eval { require "$FindBin::Bin/kohalib.pl" };
}
+use Koha::Script;
use C4::Context;
use C4::ImportBatch;
use C4::Matcher;
+++ /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;
--- /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::Script') }
+
+use C4::Context;
+
+my $userenv = C4::Context->userenv;
+is_deeply(
+ $userenv,
+ {
+ 'surname' => 'CLI',
+ 'id' => undef,
+ 'flags' => undef,
+ 'cardnumber' => undef,
+ 'firstname' => 'CLI',
+ 'branchname' => undef,
+ 'branchprinter' => undef,
+ 'emailaddress' => undef,
+ 'number' => undef,
+ 'shibboleth' => undef,
+ 'branch' => undef
+ },
+ "Context userenv set correctly with no flags"
+);
+
+my $interface = C4::Context->interface;
+is( $interface, 'commandline', "Context interface set correctly with no flags" );
+
+1;
--- /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::Script", '-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 with -cron"
+);
+
+my $interface = C4::Context->interface;
+is( $interface, 'cron', "Context interface set correctly with -cron" );
+
+1;