X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FBackgroundJob.pm;h=f607340f12cf410b983ab6c54dca8aca227c1dc1;hb=39d2885d1330afe825e1881f5fc8033d459f6006;hp=6830565ce4114fa7dacfef218f8c589599877318;hpb=ea1aa7a0d906d583375618e37be60e9f0d62d939;p=koha.git diff --git a/C4/BackgroundJob.pm b/C4/BackgroundJob.pm index 6830565ce4..f607340f12 100644 --- a/C4/BackgroundJob.pm +++ b/C4/BackgroundJob.pm @@ -5,18 +5,18 @@ package C4::BackgroundJob; # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use strict; #use warnings; FIXME - Bug 2505 @@ -24,12 +24,7 @@ use C4::Context; use C4::Auth qw/get_session/; use Digest::MD5; -use vars qw($VERSION); -BEGIN { - # set the version for version checking - $VERSION = 3.07.00.049; -} =head1 NAME @@ -83,6 +78,7 @@ sub new { $self->{'progress'} = 0; $self->{'status'} = "running"; $self->{'jobID'} = Digest::MD5::md5_hex(Digest::MD5::md5_hex(time().{}.rand().{}.$$)); + $self->{'extra_values'} = {}; bless $self, $class; $self->_serialize(); @@ -260,6 +256,64 @@ sub fetch { return $self; } +=head2 set + +=over 4 + +=item $job->set($hashref); + +=back + +Set some variables into the hashref. +These variables can be retrieved using the get method. + +=cut + +sub set { + my ($self, $hashref) = @_; + while ( my ($k, $v) = each %$hashref ) { + $self->{extra_values}->{$k} = $v; + } + $self->_serialize(); + return; +} + +=head2 get + +=over 4 + +=item $value = $job->get($key); + +=back + +Get a variable which has been previously stored with the set method. + +=cut + +sub get { + my ($self, $key) = @_; + return $self->{extra_values}->{$key}; +} + + +=head2 clear + +=over 4 + +=item $job->clear(); + +=back + +Clear the job from the current session. + +=cut + +sub clear { + my $self = shift; + get_session($self->{sessionID})->clear('job_' . $self->{jobID}); +} + + 1; __END__