X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FBackgroundJob.pm;h=3ab5125228e87d93a00981023660e01f7e70d0fa;hb=9da4c80b0149a88c14316099515ede2ebdaf7646;hp=45e404eadcae58cb697b40c05ca7bc154fc8e91b;hpb=8480f56370e2e52995c3de2923985abcd9aad931;p=koha_fer diff --git a/C4/BackgroundJob.pm b/C4/BackgroundJob.pm index 45e404eadc..3ab5125228 100644 --- a/C4/BackgroundJob.pm +++ b/C4/BackgroundJob.pm @@ -28,7 +28,7 @@ use vars qw($VERSION); BEGIN { # set the version for version checking - $VERSION = 3.00; + $VERSION = 3.07.00.049; } =head1 NAME @@ -83,6 +83,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(); @@ -231,7 +232,7 @@ if the job status is not 'completed'. sub results { my $self = shift; - return undef unless $self->{'status'} eq 'completed'; + return unless $self->{'status'} eq 'completed'; return $self->{'results'}; } @@ -253,19 +254,58 @@ sub fetch { my $session = get_session($sessionID); my $prefix = "job_$jobID"; unless (defined $session->param($prefix)) { - return undef; + return; } my $self = $session->param($prefix); bless $self, $class; 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}; +} + 1; __END__ =head1 AUTHOR -Koha Development Team +Koha Development Team Galen Charlton