View | Details | Raw Unified | Return to bug 36434
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_36434_-_add_OPACAlwaysSearchKeyword_syspref.pl (+16 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "36434",
5
    description => "Use a keyword that will be secretly included in all OPAC bibliographic and authority searches",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(
11
            q{ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACAlwaysSearchKeyword', '', NULL, 'Force OPAC bibliographic and authority searches to additionally search the provided keyword, to quietly limit search results', 'Free') }
12
        );
13
14
        say $out "Added system preference 'OPACAlwaysSearchKeyword'";
15
    },
16
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+5 lines)
Lines 94-99 Searching: Link Here
94
                  1: Enable
94
                  1: Enable
95
                  0: Disable
95
                  0: Disable
96
            - "the option for staff with permission to create/edit custom saved search filters."
96
            - "the option for staff with permission to create/edit custom saved search filters."
97
        -
98
            - Force OPAC bibliographic and authority searches to additionally search
99
            - pref: OPACAlwaysSearchKeyword
100
            - ", to quietly limit search results. Leave empty to disable this feature."
101
            - "IMPORTANT: If enabled, this may have unexpected results when doing a 'starts with' or 'is exactly' search. It is designed to work with a 'contains' search only."
97
    Search form:
102
    Search form:
98
        -
103
        -
99
            - pref: LoadSearchHistoryToTheFirstLoggedUser
104
            - pref: LoadSearchHistoryToTheFirstLoggedUser
(-)a/opac/opac-authorities-home.pl (-3 / +10 lines)
Lines 56-61 if ( $op eq "cud-do_search" ) { Link Here
56
    my $orderby = $query->param('orderby');
56
    my $orderby = $query->param('orderby');
57
    my @value = $query->multi_param('value');
57
    my @value = $query->multi_param('value');
58
    $value[0] ||= q||;
58
    $value[0] ||= q||;
59
    my $value_history = $value[0];
60
61
    if ( C4::Context->preference('OPACAlwaysSearchKeyword') ) {
62
        my $always_search_kw = C4::Context->preference('OPACAlwaysSearchKeyword');
63
        $always_search_kw =~ s/^\s+|\s+$//g;
64
        $value[0] = $value[0] . " " . $always_search_kw;
65
    }
59
66
60
    # validation of "Where"
67
    # validation of "Where"
61
    my @valid_marc_list = qw( all match mainentry );
68
    my @valid_marc_list = qw( all match mainentry );
Lines 82-88 if ( $op eq "cud-do_search" ) { Link Here
82
    $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate');
89
    $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate');
83
90
84
    # multi page display gestion
91
    # multi page display gestion
85
    my $value_url = uri_escape_utf8($value[0]);
92
    my $value_url = uri_escape_utf8($value_history);
86
    my $base_url = "opac-authorities-home.pl?"
93
    my $base_url = "opac-authorities-home.pl?"
87
      ."marclist=$marclist[0]"
94
      ."marclist=$marclist[0]"
88
      ."&and_or=$and_or[0]"
95
      ."&and_or=$and_or[0]"
Lines 158-164 if ( $op eq "cud-do_search" ) { Link Here
158
            unless ( $loggedinuser ) {
165
            unless ( $loggedinuser ) {
159
                my $new_search = C4::Search::History::add_to_session({
166
                my $new_search = C4::Search::History::add_to_session({
160
                        cgi => $query,
167
                        cgi => $query,
161
                        query_desc => $value[0],
168
                        query_desc => $value_history,
162
                        query_cgi => $query_cgi_history,
169
                        query_cgi => $query_cgi_history,
163
                        total => $total,
170
                        total => $total,
164
                        type => "authority",
171
                        type => "authority",
Lines 168-174 if ( $op eq "cud-do_search" ) { Link Here
168
                C4::Search::History::add({
175
                C4::Search::History::add({
169
                    userid => $loggedinuser,
176
                    userid => $loggedinuser,
170
                    sessionid => $query->cookie("CGISESSID"),
177
                    sessionid => $query->cookie("CGISESSID"),
171
                    query_desc => $value[0],
178
                    query_desc => $value_history,
172
                    query_cgi => $query_cgi_history,
179
                    query_cgi => $query_cgi_history,
173
                    total => $total,
180
                    total => $total,
174
                    type => "authority",
181
                    type => "authority",
(-)a/opac/opac-search.pl (-1 / +7 lines)
Lines 414-419 if ($indexes[0] && !$indexes[1]) { Link Here
414
# an operand can be a single term, a phrase, or a complete ccl query
414
# an operand can be a single term, a phrase, or a complete ccl query
415
my @operands = $cgi->multi_param('q');
415
my @operands = $cgi->multi_param('q');
416
@operands = map { uri_unescape($_) } @operands;
416
@operands = map { uri_unescape($_) } @operands;
417
if ( C4::Context->preference('OPACAlwaysSearchKeyword') ) {
418
    my $always_search_kw = C4::Context->preference('OPACAlwaysSearchKeyword');
419
    $always_search_kw =~ s/^\s+|\s+$//g;
420
    push @operands, $always_search_kw;
421
}
417
422
418
$template->{VARS}->{querystring} = join(' ', @operands);
423
$template->{VARS}->{querystring} = join(' ', @operands);
419
424
Lines 715-720 for (my $i=0;$i<@servers;$i++) { Link Here
715
                my $query_cgi_history = $cgi->url(-query=>1);
720
                my $query_cgi_history = $cgi->url(-query=>1);
716
                $query_cgi_history =~ s/^$path_info\?//;
721
                $query_cgi_history =~ s/^$path_info\?//;
717
                $query_cgi_history =~ s/;/&/g;
722
                $query_cgi_history =~ s/;/&/g;
723
                my $always_search_kw = C4::Context->preference('OPACAlwaysSearchKeyword');
724
                $query_desc =~ s/ AND kw,wrdl: $always_search_kw//;
718
                my $query_desc_history = join ", ", grep { defined $_ } $query_desc, $limit_desc;
725
                my $query_desc_history = join ", ", grep { defined $_ } $query_desc, $limit_desc;
719
726
720
                if ( $borrowernumber and $cgi->cookie("CGISESSID") ) {
727
                if ( $borrowernumber and $cgi->cookie("CGISESSID") ) {
721
- 

Return to bug 36434