1 package Koha::BackgroundJobs;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Koha::BackgroundJob;
22 use base qw(Koha::Objects);
26 Koha::BackgroundJobs - Koha BackgroundJob Object set class
34 my $background_jobs = Koha::BackgroundJobs->search_limited( $params, $attributes );
36 Returns all background jobs the logged in user should be allowed to see
41 my ( $self, $params, $attributes ) = @_;
43 my $can_manage_background_jobs;
45 my $userenv = C4::Context->userenv;
46 if ( $userenv and $userenv->{number} ) {
47 $logged_in_user = Koha::Patrons->find( $userenv->{number} );
48 $can_manage_background_jobs = $logged_in_user->has_permission(
49 { parameters => 'manage_background_jobs' } );
52 return $self->search( $params, $attributes ) if $can_manage_background_jobs;
53 my $id = $logged_in_user ? $logged_in_user->borrowernumber : undef;
54 return $self->search({ borrowernumber => $id })->search( $params, $attributes );
57 =head3 filter_by_current
59 my $current_jobs = $jobs->filter_by_current;
61 Returns a new resultset, filtering out finished jobs.
65 sub filter_by_current {
70 status => { not_in => [ 'cancelled', 'failed', 'finished' ] }
75 =head2 Internal methods
82 return 'BackgroundJob';
90 return 'Koha::BackgroundJob';