/);
sub fetch_course_materials {
- my ($self, $conn, $copy_id) = @_;
+ my ($self, $conn, $args) = @_;
my $e = new_editor();
- return $e->search_asset_course_module_course_materials({item => $copy_id});
+ return $e->search_asset_course_module_course_materials($args);
}
sub fetch_courses {
my ($self, $conn, @course_ids) = @_;
my $e = new_editor();
- return unless @course_ids;
+ return unless @course_ids;
my $targets = ();
foreach my $course_id (@course_ids) {
my $target = $e->retrieve_asset_course_module_course($course_id);
$copy->{course_materials} = $U->simplereq(
'open-ils.circ',
'open-ils.circ.course_materials.retrieve',
- $copy->{id}
+ {item => $copy->{id}}
);
my %course_ids;
for my $material (@{$copy->{course_materials}}) {
}
}
+ my $course_module_opt_in = 0;
+ if ($ctx->{get_org_setting}->($self->_get_search_lib, "circ.course_materials_opt_in")) {
+ $course_module_opt_in = 1;
+ }
+
for my $rec (@{$ctx->{records}}) {
my ($res_rec) = grep { $_->[0] == $rec->{$id_key} } @{$results->{ids}};
$rec->{badges} = [split(',', $res_rec->[1])] if $res_rec->[1];
$rec->{popularity} = $res_rec->[2];
+ if ($course_module_opt_in) {
+ $rec->{course_materials} = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.course_materials.retrieve',
+ {record => $rec->{id}}
+ );
+ my %course_ids;
+ for my $material (@{$rec->{course_materials}}) {
+ $course_ids{$material->course} = 1;
+ }
+
+ $rec->{courses} = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.courses.retrieve',
+ keys %course_ids
+ );
+ }
if ($tag_circs) {
# index 3 (5 for MR) in the per-record result array is a boolean which
# indicates whether the record in question is in the users
$rec->{user_circulated} = 1 if $res_rec->[$index];
}
}
+
$ctx->{search_facets} = $facets;
return ($cache_key, $list);
}
-1;
+1;
\ No newline at end of file
[% UNLESS rec.mmr_id;
PROCESS "opac/parts/result/copy_counts.tt2";
END; %]
+ [%- IF ctx.get_org_setting(ctx.search_ou, 'circ.course_materials_opt_in') == 1 %]
+ [%- courseStrings = [] %]
+ [% FOREACH course IN rec.courses %]
+ [% courseString = course.name _ ' (' _ course.course_number _ ')' %]
+ [% courseStrings.push(courseString); %]
+ [% END %]
+ [% IF courseStrings.size > 0 %]
+ <span><strong>[% l('Associated Courses: ') %]</strong></span>
+ <span>[% courseStrings.join(', ') %]</span>
+ [% END %]
+ [% END %]
[% IF rec.user_circulated %]
<div class="result_item_circulated">
<img src="[% ctx.media_prefix %]/images/green_check.png[% ctx.cache_key %]" alt="[% l('Checked Out Before') %]"/>