diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index aa4b33dd68..ff58ac6b4c 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -471,14 +471,17 @@ sub plugin_types_to_classes { my $namespace = $metadata->{namespace}; foreach my $type ( keys %{$tasks} ) { - my $class = $tasks->{$type}; + my $class = + ( ref $tasks->{$type} eq 'HASH' ) + ? $tasks->{$type}{class} + : $tasks->{$type}; # skip if conditions not met next unless $type and $class; my $key = "plugin_$namespace" . "_$type"; - $self->{_plugin_mapping}->{$key} = $tasks->{$type}; + $self->{_plugin_mapping}->{$key} = $class; } } } diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index b193fdbf2a..80f93bc5ab 100755 --- a/admin/background_jobs.pl +++ b/admin/background_jobs.pl @@ -91,9 +91,12 @@ my @plugin_job_types; for my $plugin (@plugins) { my $tasks = $plugin->background_tasks; for my $id ( keys %$tasks ) { + + # fallback to package name if no human-readable name is available + my $name = ( ref $tasks->{$id} eq 'HASH' ) ? $tasks->{$id}{name} : $tasks->{$id}; push @plugin_job_types, { id => 'plugin_' . $plugin->get_metadata->{namespace} . "_$id", - str => $tasks->{$id}, + str => $name, }; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt index e811b1139f..8ac60f6428 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt @@ -181,72 +181,72 @@ const job_types = [ { '_id': 'batch_biblio_record_modification', - '_str': _("Batch bibliographic record modification") + '_str': _("Batch bibliographic record modification").escapeHtml() }, { '_id': 'batch_biblio_record_deletion', - '_str': _("Batch bibliographic record deletion") + '_str': _("Batch bibliographic record deletion").escapeHtml() }, { '_id': 'batch_authority_record_modification', - '_str': _("Batch authority record modification") + '_str': _("Batch authority record modification").escapeHtml() }, { '_id': 'batch_authority_record_deletion', - '_str': _("Batch authority record deletion") + '_str': _("Batch authority record deletion").escapeHtml() }, { '_id': 'batch_item_record_modification', - '_str': _("Batch item record modification") + '_str': _("Batch item record modification").escapeHtml() }, { '_id': 'batch_item_record_deletion', - '_str': _("Batch item record deletion") + '_str': _("Batch item record deletion").escapeHtml() }, { '_id': 'erm_sushi_harvester', - '_str': _("ERM Usage Statistics SUSHI Harvester") + '_str': _("ERM Usage Statistics SUSHI Harvester").escapeHtml() }, { '_id': 'batch_hold_cancel', - '_str': _("Batch hold cancellation") + '_str': _("Batch hold cancellation").escapeHtml() }, { '_id': 'pseudonymize_statistic', - '_str': _("Pseudonymize statistic") + '_str': _("Pseudonymize statistic").escapeHtml() }, { '_id': 'create_eholdings_from_biblios', - '_str': _("Create eHolding titles") + '_str': _("Create eHolding titles").escapeHtml() }, { '_id': 'update_elastic_index', - '_str': _("Update Elasticsearch index") + '_str': _("Update Elasticsearch index").escapeHtml() }, { '_id': 'update_holds_queue_for_biblios', - '_str': _("Holds queue update") + '_str': _("Holds queue update").escapeHtml() }, { '_id': 'stage_marc_for_import', - '_str': _("Staged MARC records for import") + '_str': _("Staged MARC records for import").escapeHtml() }, { '_id': 'marc_import_commit_batch', - '_str': _("Import MARC records") + '_str': _("Import MARC records").escapeHtml() }, { '_id': 'marc_import_revert_batch', - '_str': _("Revert import MARC records") + '_str': _("Revert import MARC records").escapeHtml() }, { '_id': 'import_from_kbart_file', - '_str': _("Import titles from a KBART file") + '_str': _("Import titles from a KBART file").escapeHtml() }, [% FOR job_type IN plugin_job_types %] { - '_id': '[% job_type.id %]', - '_str': '[% job_type.str %]' + '_id': '[% job_type.id | html %]', + '_str': '[% job_type.str | html_entity %]' }, [% END %] ]; @@ -316,7 +316,7 @@ "searchable": true, "orderable": true, "render": function(data, type, row, meta) { - return get_job_type(row.type).escapeHtml(); + return get_job_type(row.type); } }, { diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm index 255fc90a12..aa4bba3953 100644 --- a/t/lib/plugins/Koha/Plugin/Test.pm +++ b/t/lib/plugins/Koha/Plugin/Test.pm @@ -365,7 +365,10 @@ sub intranet_catalog_biblio_tab { sub background_tasks { return { foo => 'MyPlugin::Class::Foo', - bar => 'MyPlugin::Class::Bar', + bar => { + class => 'MyPlugin::Class::Bar', + name => "Bar task", + }, }; }