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

(-)a/C4/Breeding.pm (+41 lines)
Lines 25-30 use C4::Biblio; Link Here
25
use C4::Koha;
25
use C4::Koha;
26
use C4::Charset;
26
use C4::Charset;
27
use MARC::File::USMARC;
27
use MARC::File::USMARC;
28
use MARC::Field;
28
use C4::ImportBatch;
29
use C4::ImportBatch;
29
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
30
use C4::Languages;
31
use C4::Languages;
Lines 338-343 sub _add_rowdata { Link Here
338
    }
339
    }
339
    $row->{date}//= $row->{date2};
340
    $row->{date}//= $row->{date2};
340
    $row->{isbn}=_isbn_replace($row->{isbn});
341
    $row->{isbn}=_isbn_replace($row->{isbn});
342
343
    $row = _add_custom_field_rowdata($row, $record);
344
345
    return $row;
346
}
347
348
sub _add_custom_field_rowdata
349
{
350
    my ( $row, $record ) = @_;
351
    my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
352
353
    $pref_newtags =~ s/^\s+|\s+$//g;
354
    $pref_newtags =~ s/\h+/ /g;
355
356
    my @addnumberfields;
357
358
    foreach my $field (split / /, $pref_newtags) {
359
        my ($tag, $subtags) = split(/\$/, $field);
360
361
        if ( $record->field($tag) ) {
362
            my $marcfield   = $record->field($tag);
363
364
            if ( $subtags ) {
365
                my $content = '';
366
                for my $code (split //, $subtags) {
367
                    $content .= $marcfield->subfield($code) . ' ';
368
                }
369
370
                $row->{$field} = $content;
371
            } elsif ( $tag <= 10 ) {
372
                $row->{$field} = $marcfield->data();
373
            } else {
374
                $row->{$field} = $marcfield->as_string();
375
            }
376
            push( @addnumberfields, $field );
377
        }
378
    }
379
380
    $row->{'addnumberfields'} = \@addnumberfields;
381
341
    return $row;
382
    return $row;
342
}
383
}
343
384
(-)a/installer/data/mysql/atomicupdate/bug_12747-additional_fields_in_Z3950_search_result.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AdditionalFieldsInZ3950ResultSearch', '', 'NULL', 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 6-11 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
9
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
10
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
12
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt (+15 lines)
Lines 1-8 Link Here
1
[% USE Koha %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
3
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( opsearch ) %]Order from external source[% ELSE %]Order from external source &rsaquo; Search results[% END %]</title>
3
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
4
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'datatables.inc' %]
6
[% INCLUDE 'datatables.inc' %]
7
[% USE Koha %]
6
8
7
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
9
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
8
<script type="text/javascript">
10
<script type="text/javascript">
Lines 131-136 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
131
        <th>Author</th>
133
        <th>Author</th>
132
        <th>ISBN</th>
134
        <th>ISBN</th>
133
        <th>LCCN</th>
135
        <th>LCCN</th>
136
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
137
        <th>Additional fields</th>
138
        [% END %]
134
        <th>Preview</th>
139
        <th>Preview</th>
135
		<th>&nbsp;</th>
140
		<th>&nbsp;</th>
136
    </tr></thead>
141
    </tr></thead>
Lines 143-148 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
143
            <td>[% breeding_loo.author %]</td>
148
            <td>[% breeding_loo.author %]</td>
144
            <td>[% breeding_loo.isbn %]</td>
149
            <td>[% breeding_loo.isbn %]</td>
145
            <td>[% breeding_loo.lccn %]</td>
150
            <td>[% breeding_loo.lccn %]</td>
151
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
152
            <td>
153
               <dl>
154
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
155
                  <dt>[% addnumberfield %]:</dt>
156
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
157
                  [% END %]
158
               </dl>
159
            </td>
160
            [% END %]
146
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
161
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" class="previewData">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="Card" class="previewData">Card</a></td>
147
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
162
            <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?frameworkcode=[% frameworkcode | uri %]&amp;breedingid=[% breeding_loo.breedingid %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Order</a></td>
148
163
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+4 lines)
Lines 229-234 Cataloging: Link Here
229
                  no: "don't"
229
                  no: "don't"
230
            - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records.  Note that this preference has no effect if UseQueryParser is on.
230
            - attempt to match aggressively by trying all variations of the ISBNs in the imported record as a phrase in the ISBN fields of already cataloged records.  Note that this preference has no effect if UseQueryParser is on.
231
        -
231
        -
232
            - Determines the MARC field/subfields
233
            - pref: AdditionalFieldsInZ3950ResultSearch
234
            - "are displayed in 'Additional fields' column in the result of a search Z3950 (use whitespace as delimiter ex: <code>082$ab</code> <code>090$ab</code>)"
235
        -
232
            - When matching on ISSN with the record import tool,
236
            - When matching on ISSN with the record import tool,
233
            - pref: AggressiveMatchOnISSN
237
            - pref: AggressiveMatchOnISSN
234
              choices:
238
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt (+14 lines)
Lines 1-3 Link Here
1
[% USE Koha %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Z39.50/SRU search results</title>
3
<title>Koha &rsaquo; Z39.50/SRU search results</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 144-149 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
144
        <th>Edition</th>
145
        <th>Edition</th>
145
        <th>ISBN</th>
146
        <th>ISBN</th>
146
        <th>LCCN</th>
147
        <th>LCCN</th>
148
        [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
149
        <th>Additional fields</th>
150
        [% END %]
147
        <th>MARC</th>
151
        <th>MARC</th>
148
        <th>Card</th>
152
        <th>Card</th>
149
		<th>&nbsp;</th>
153
		<th>&nbsp;</th>
Lines 159-164 tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : Link Here
159
            <td>[% breeding_loo.edition %]</td>
163
            <td>[% breeding_loo.edition %]</td>
160
            <td>[% breeding_loo.isbn %]</td>
164
            <td>[% breeding_loo.isbn %]</td>
161
            <td>[% breeding_loo.lccn %]</td>
165
            <td>[% breeding_loo.lccn %]</td>
166
            [% IF Koha.Preference('AdditionalFieldsInZ3950ResultSearch') != '' %]
167
            <td>
168
               <dl>
169
                  [% FOREACH addnumberfield IN breeding_loo.addnumberfields %]
170
                  <dt>[% addnumberfield %]:</dt>
171
                  <dd>[% breeding_loo.$addnumberfield %]</dd>
172
                  [% END %]
173
               </dl>
174
            </td>
175
            [% END %]
162
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" class="previewData">MARC</a></td>
176
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" class="previewData">MARC</a></td>
163
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" class="previewData">Card</a></td>
177
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" class="previewData">Card</a></td>
164
            <td><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid %]" data-biblionumber="[% breeding_loo.biblionumber %]" data-frameworkcode="[% frameworkcode | uri %]">Import</a></td>
178
            <td><a href="#" class="import_record" data-breedingid="[% breeding_loo.breedingid %]" data-biblionumber="[% breeding_loo.biblionumber %]" data-frameworkcode="[% frameworkcode | uri %]">Import</a></td>
(-)a/t/db_dependent/Breeding.t (-2 / +43 lines)
Lines 20-28 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use FindBin;
22
use FindBin;
23
use Test::More tests => 3;
23
use Test::More tests => 4;
24
use Test::Warn;
24
use Test::Warn;
25
25
26
use C4::Context;
26
use C4::Breeding;
27
use C4::Breeding;
27
use Koha::XSLT_Handler;
28
use Koha::XSLT_Handler;
28
29
Lines 49-54 subtest '_do_xslt_proc' => sub { Link Here
49
    plan tests => 7;
50
    plan tests => 7;
50
    test_do_xslt();
51
    test_do_xslt();
51
};
52
};
53
#Group 4: testing _add_rowdata (part of Z3950Search)
54
subtest '_add_rowdata' => sub {
55
    plan tests => 4;
56
    test_add_rowdata();
57
};
52
58
53
#-------------------------------------------------------------------------------
59
#-------------------------------------------------------------------------------
54
60
Lines 186-188 sub test_do_xslt { Link Here
186
    is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
192
    is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
187
        'At least the title is the same :)' );
193
        'At least the title is the same :)' );
188
}
194
}
189
- 
195
196
sub test_add_rowdata {
197
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch','');
198
199
    my $row = {
200
       biblionumber => 0,
201
       server => "testServer",
202
       breedingid => 0,
203
   };
204
205
    my $biblio = MARC::Record->new();
206
    $biblio->append_fields(
207
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
208
    );
209
210
    my $returned_row = C4::Breeding::_add_rowdata($row,$biblio);
211
212
    is($returned_row->{title} ,"Just a title","_add_rowdata returns the title of a biblio");
213
    is($returned_row->{addnumberfields}[0],undef,"_add_rowdata returns undef if it has no additionnal field");
214
215
    t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch',"245\$a");
216
217
    $row = {
218
       biblionumber => 0,
219
       server => "testServer",
220
       breedingid => 0,
221
   };
222
   $biblio = MARC::Record->new();
223
   $biblio->append_fields(
224
       MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title
225
   );
226
   $returned_row = C4::Breeding::_add_rowdata($row,$biblio);
227
228
   is($returned_row->{title} ,"Just a title","_add_rowdata returns the title of a biblio");
229
   is($returned_row->{addnumberfields}[0],"245\$a","_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference");
230
}

Return to bug 12747