}
);
+ my $stat = $self->check_1hit_redirect($rec_ids);
+ return $stat if $stat;
+
# shove recs into context in search results order
for my $rec_id (@$rec_ids) {
push(
return Apache2::Const::OK;
}
+# If the calling search results in 1 record and the client
+# is configured to do so, redirect the search results to
+# the record details page.
+sub check_1hit_redirect {
+ my ($self, $rec_ids) = @_;
+ my $ctx = $self->ctx;
+
+ return undef unless $rec_ids and @$rec_ids == 1;
+
+ my ($sname, $org);
+
+ if ($ctx->{is_staff}) {
+ $sname = 'opac.staff.jump_to_details_on_single_hit';
+ $org = $ctx->{user}->ws_ou;
+
+ } else {
+ $sname = 'opac.patron.jump_to_details_on_single_hit';
+ $org = ($ctx->{user}) ?
+ $ctx->{user}->home_ou :
+ $ctx->{orig_loc} ||
+ $self->ctx->{aou_tree}->()->id;
+ }
+
+ return undef unless
+ $self->ctx->{get_org_setting}->($org, $sname);
+
+ my $base_url = sprintf(
+ '%s://%s%s/record/%s',
+ $ctx->{proto},
+ $self->apache->hostname,
+ $self->ctx->{opac_root},
+ $$rec_ids[0],
+ );
+
+ # If we get here from the same record detail page to which we
+ # now wish to redirect, do not perform the redirect. This
+ # approach seems to work well, with the rare exception of
+ # performing a new serach directly from the detail page that
+ # happens to result in the same single hit. In this case, the
+ # user will be left on the search results page. This could be
+ # overcome w/ additional CGI, etc., but I'm not sure it's necessary.
+ if (my $referer = $ctx->{referer}) {
+ $referer =~ s/([^?]*).*/$1/g;
+ return undef if $base_url eq $referer;
+ }
+
+ return $self->generic_redirect($base_url . '?' . $self->cgi->query_string);
+}
+
# Searching by barcode is a special search that does /not/ respect any other
# of the usual search parameters, not even the ones for sorting and paging!
sub item_barcode_shortcut {
}
$self->ctx->{ids} = [ grep { $_ } @{$results->{ids}} ];
+ $self->ctx->{hit_count} = $results->{count};
+
+ return Apache2::Const::OK if @{$self->ctx->{ids}} == 0 or $args{internal};
+
+ my $stat = $self->check_1hit_redirect($self->ctx->{ids});
+ return $stat if $stat;
my ($facets, @data) = $self->get_records_and_facets(
$self->ctx->{ids}, undef, {flesh => "{holdings_xml,mra}"}
);
$self->ctx->{records} = [@data];
- $self->ctx->{hit_count} = $results->{count};
return Apache2::Const::OK;
}
'coust', 'description'),
'integer', null)
+,( 'opac.staff.jump_to_details_on_single_hit', 'opac',
+ oils_i18n_gettext('opac.staff.jump_to_details_on_single_hit',
+ 'Jump to details on 1 hit (staff client)',
+ 'coust', 'label'),
+ oils_i18n_gettext('opac.staff.jump_to_details_on_single_hit',
+ 'When a search yields only 1 result, jump directly to the record details page. This setting only affects the OPAC within the staff client',
+ 'coust', 'description'),
+ 'bool', null)
+,( 'opac.patron.jump_to_details_on_single_hit', 'opac',
+ oils_i18n_gettext('opac.patron.jump_to_details_on_single_hit',
+ 'Jump to details on 1 hit (public)',
+ 'coust', 'label'),
+ oils_i18n_gettext('opac.patron.jump_to_details_on_single_hit',
+ 'When a search yields only 1 result, jump directly to the record details page. This setting only affects the public OPAC',
+ 'coust', 'description'),
+ 'bool', null)
+
;
UPDATE config.org_unit_setting_type
--- /dev/null
+-- Evergreen DB patch 0635.data.opac.jump-to-details-setting.sql
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0635', :eg_version);
+
+INSERT INTO config.org_unit_setting_type ( name, grp, label, description, datatype )
+ VALUES (
+ 'opac.staff.jump_to_details_on_single_hit',
+ 'opac',
+ oils_i18n_gettext(
+ 'opac.staff.jump_to_details_on_single_hit',
+ 'Jump to details on 1 hit (staff client)',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'opac.staff.jump_to_details_on_single_hit',
+ 'When a search yields only 1 result, jump directly to the record details page. This setting only affects the OPAC within the staff client',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+ ), (
+ 'opac.patron.jump_to_details_on_single_hit',
+ 'opac',
+ oils_i18n_gettext(
+ 'opac.patron.jump_to_details_on_single_hit',
+ 'Jump to details on 1 hit (public)',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'opac.patron.jump_to_details_on_single_hit',
+ 'When a search yields only 1 result, jump directly to the record details page. This setting only affects the public OPAC',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+ );
+
+COMMIT;