Lines 1-4
Link Here
|
1 |
package Koha::Cron; |
1 |
package Koha::Script; |
2 |
|
2 |
|
3 |
# Copyright PTFS Europe 2019 |
3 |
# Copyright PTFS Europe 2019 |
4 |
# Copyright 2019 Koha Development Team |
4 |
# Copyright 2019 Koha Development Team |
Lines 22-50
use Modern::Perl;
Link Here
|
22 |
|
22 |
|
23 |
=head1 NAME |
23 |
=head1 NAME |
24 |
|
24 |
|
25 |
Koha::Cron - Koha Cron scripts base class |
25 |
Koha::Script - Koha scripts base class |
26 |
|
26 |
|
27 |
=head1 SYNOPSIS |
27 |
=head1 SYNOPSIS |
28 |
|
28 |
|
29 |
use Koha::Cron; |
29 |
use Koha::Script |
|
|
30 |
use Koha::Script -cron; |
30 |
|
31 |
|
31 |
=head1 DESCRIPTION |
32 |
=head1 DESCRIPTION |
32 |
|
33 |
|
33 |
This class should be used in all cronscripts. It sets the interface and userenv appropriately. |
34 |
This class should be used in all scripts. It sets the interface and userenv appropriately. |
34 |
|
35 |
|
35 |
=cut |
36 |
=cut |
36 |
|
37 |
|
37 |
use C4::Context; |
38 |
use C4::Context; |
38 |
|
39 |
|
39 |
# Set userenv |
40 |
sub import { |
40 |
C4::Context->_new_userenv(1); |
41 |
my $class = shift; |
41 |
C4::Context->set_userenv( |
42 |
my @flags = @_; |
42 |
undef, undef, undef, 'CRON', 'CRON', undef, |
43 |
|
43 |
undef, undef, undef, undef, undef |
44 |
C4::Context->_new_userenv(1); |
44 |
); |
45 |
if ( ( $flags[0] || '' ) eq '-cron' ) { |
45 |
|
46 |
|
46 |
# Set interface |
47 |
# Set userenv |
47 |
C4::Context->interface('cron'); |
48 |
C4::Context->_new_userenv(1); |
|
|
49 |
C4::Context->set_userenv( |
50 |
undef, undef, undef, 'CRON', 'CRON', undef, |
51 |
undef, undef, undef, undef, undef |
52 |
); |
53 |
|
54 |
# Set interface |
55 |
C4::Context->interface('cron'); |
56 |
|
57 |
} |
58 |
else { |
59 |
# Set userenv |
60 |
C4::Context->set_userenv( |
61 |
undef, undef, undef, 'CLI', 'CLI', undef, |
62 |
undef, undef, undef, undef, undef |
63 |
); |
64 |
|
65 |
# Set interface |
66 |
C4::Context->interface('commandline'); |
67 |
} |
68 |
} |
48 |
|
69 |
|
49 |
=head1 AUTHOR |
70 |
=head1 AUTHOR |
50 |
|
71 |
|