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

(-)a/C4/Breeding.pm (-14 / +43 lines)
Lines 254-312 sub Z3950Search { Link Here
254
    my @oResult;
254
    my @oResult;
255
    my @errconn;
255
    my @errconn;
256
    my $s = 0;
256
    my $s = 0;
257
    my $query;
257
    my @query = '';
258
    my $nterms=0;
258
    my $nterms=0;
259
    my $imported=0;
259
    my $imported=0;
260
    my @serverinfo; #replaces former serverhost, servername, encoding
260
    my @serverinfo; #replaces former serverhost, servername, encoding
261
261
262
    if ($isbn) {
262
    if ($isbn) {
263
        $term=$isbn;
263
        $term=$isbn;
264
        $query .= " \@attr 1=7 \@attr 5=1 \"$term\" ";
264
        push @query, "\@attr 1=7 \@attr 5=1 \"$term\"";
265
        $nterms++;
265
        $nterms++;
266
    }
266
    }
267
    if ($issn) {
267
    if ($issn) {
268
        $term=$issn;
268
        $term=$issn;
269
        $query .= " \@attr 1=8 \@attr 5=1 \"$term\" ";
269
        push @query, "\@attr 1=8 \@attr 5=1 \"$term\"";
270
        $nterms++;
270
        $nterms++;
271
    }
271
    }
272
    if ($title) {
272
    if ($title) {
273
        $query .= " \@attr 1=4 \"$title\" ";
273
        push @query, "\@attr 1=4 \"$title\"";
274
        $nterms++;
274
        $nterms++;
275
    }
275
    }
276
    if ($author) {
276
    if ($author) {
277
        $query .= " \@attr 1=1003 \"$author\" ";
277
        push @query, "\@attr 1=1003 \"$author\"";
278
        $nterms++;
278
        $nterms++;
279
    }
279
    }
280
    if ($dewey) {
280
    if ($dewey) {
281
        $query .= " \@attr 1=16 \"$dewey\" ";
281
        push @query, "\@attr 1=16 \"$dewey\"";
282
        $nterms++;
282
        $nterms++;
283
    }
283
    }
284
    if ($subject) {
284
    if ($subject) {
285
        $query .= " \@attr 1=21 \"$subject\" ";
285
        push @query, "\@attr 1=21 \"$subject\"";
286
        $nterms++;
286
        $nterms++;
287
    }
287
    }
288
    if ($lccn) {
288
    if ($lccn) {
289
        $query .= " \@attr 1=9 $lccn ";
289
        push @query, "\@attr 1=9 $lccn";
290
        $nterms++;
290
        $nterms++;
291
    }
291
    }
292
    if ($lccall) {
292
    if ($lccall) {
293
        $query .= " \@attr 1=16 \@attr 2=3 \@attr 3=1 \@attr 4=1 \@attr 5=1 \@attr 6=1 \"$lccall\" ";
293
        push @query, "\@attr 1=16 \@attr 2=3 \@attr 3=1 \@attr 4=1 \@attr 5=1 \@attr 6=1 \"$lccall\"";
294
        $nterms++;
294
        $nterms++;
295
    }
295
    }
296
    if ($controlnumber) {
296
    if ($controlnumber) {
297
        $query .= " \@attr 1=12 \"$controlnumber\" ";
297
        push @query, "\@attr 1=12 \"$controlnumber\"";
298
        $nterms++;
298
        $nterms++;
299
    }
299
    }
300
    if($srchany) {
300
    if($srchany) {
301
        $query .= " \@attr 1=1016 \"$srchany\" ";
301
        push @query, "\@attr 1=1016 \"$srchany\"";
302
        $nterms++;
302
        $nterms++;
303
    }
303
    }
304
    if($stdid) {
304
    if($stdid) {
305
        $query .= " \@attr 1=1007 \"$stdid\" ";
305
        push @query, "\@attr 1=1007 \"$stdid\"";
306
        $nterms++;
306
        $nterms++;
307
    }
307
    }
308
    for my $i (1..$nterms-1) {
308
    for my $i (1..$nterms-1) {
309
        $query = "\@and " . $query;
309
        $query[0] = "\@and " . $query[0];
310
    }
310
    }
311
311
312
    my $dbh   = C4::Context->dbh;
312
    my $dbh   = C4::Context->dbh;
Lines 326-331 sub Z3950Search { Link Here
326
            $oConnection[$s]->connect( $server->{host}, $server->{port} );
326
            $oConnection[$s]->connect( $server->{host}, $server->{port} );
327
            $serverinfo[$s]->{host}= $server->{host};
327
            $serverinfo[$s]->{host}= $server->{host};
328
            $serverinfo[$s]->{name}= $server->{name};
328
            $serverinfo[$s]->{name}= $server->{name};
329
            # Add additional attributes if some specified
330
            if($server->{attributes}) {
331
                # Extract all additional server attributes
332
                my %additional_attributes;
333
                my @split_attributes = split(/\s+/, $server->{attributes});
334
                for(my $i=0; $i<=$#split_attributes; $i++) {
335
                    if($split_attributes[$i] eq "\@attr" and $split_attributes[$i+1] =~ /^(\d+)=\d+$/) {
336
                        $additional_attributes{$1} = $split_attributes[$i] . ' ' . $split_attributes[$i+1];
337
                        $i++;
338
                    }
339
                }
340
341
                # Clone the query and modify it
342
                $serverinfo[$s]->{query} = [@query];
343
                foreach my $querypart (@{$serverinfo[$s]->{query}}) {
344
                    # Ignore parts without attributes
345
                    next if $querypart !~ /\@attr/;
346
                    # Only add additional attributes if they don't already exist in the query part
347
                    foreach my $attr_type (keys %additional_attributes) {
348
                        if($querypart !~ /\@attr $attr_type=/) {
349
                            $querypart = $additional_attributes{$attr_type} . ' ' . $querypart;
350
                        }
351
                    }
352
                }
353
            }
354
            else {
355
                # Use a reference to the original query
356
                $serverinfo[$s]->{query} = \@query;
357
            }
329
            $serverinfo[$s]->{encd}= $server->{encoding} // "iso-5426";
358
            $serverinfo[$s]->{encd}= $server->{encoding} // "iso-5426";
330
            $s++;
359
            $s++;
331
        }    ## while fetch
360
        }    ## while fetch
Lines 333-339 sub Z3950Search { Link Here
333
    my $nremaining  = $s;
362
    my $nremaining  = $s;
334
363
335
    for ( my $z = 0 ; $z < $s ; $z++ ) {
364
    for ( my $z = 0 ; $z < $s ; $z++ ) {
336
        $oResult[$z] = $oConnection[$z]->search_pqf($query);
365
        $oResult[$z] = $oConnection[$z]->search_pqf( join(' ', @{$serverinfo[$z]->{query}}) )
337
    }
366
    }
338
367
339
    while ( $nremaining-- ) {
368
    while ( $nremaining-- ) {
(-)a/admin/z3950servers.pl (-7 / +10 lines)
Lines 93-106 if ( $op eq 'add_form' ) { Link Here
93
    if ($searchfield) {
93
    if ($searchfield) {
94
        my $dbh = C4::Context->dbh;
94
        my $dbh = C4::Context->dbh;
95
        my $sth = $dbh->prepare(
95
        my $sth = $dbh->prepare(
96
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name"
96
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype,attributes from z3950servers where (name = ?) order by rank,name"
97
        );
97
        );
98
        $sth->execute($searchfield);
98
        $sth->execute($searchfield);
99
        $data = $sth->fetchrow_hashref;
99
        $data = $sth->fetchrow_hashref;
100
        $sth->finish;
100
        $sth->finish;
101
    }
101
    }
102
    $template->param( $_ => $data->{$_} )
102
    $template->param( $_ => $data->{$_} )
103
      for (qw( host port db userid password checked rank timeout encoding ));
103
      for (qw( host port db userid password checked rank timeout encoding attributes ));
104
    $template->param( $_ . $data->{$_} => 1 ) for (qw( syntax recordtype ));
104
    $template->param( $_ . $data->{$_} => 1 ) for (qw( syntax recordtype ));
105
105
106
    # END $OP eq ADD_FORM
106
    # END $OP eq ADD_FORM
Lines 113-119 if ( $op eq 'add_form' ) { Link Here
113
	my $checked = $input->param('checked') ? 1 : 0;
113
	my $checked = $input->param('checked') ? 1 : 0;
114
	if ($sth->rows) {
114
	if ($sth->rows) {
115
        $template->param(confirm_update => 1);
115
        $template->param(confirm_update => 1);
116
             $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=? where name=?");
116
             $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=?,recordtype=?,attributes=? where name=?");
117
		$sth->execute($input->param('host'),
117
		$sth->execute($input->param('host'),
118
		      $input->param('port'),
118
		      $input->param('port'),
119
		      $input->param('db'),
119
		      $input->param('db'),
Lines 126-131 if ( $op eq 'add_form' ) { Link Here
126
              $input->param('encoding'),
126
              $input->param('encoding'),
127
              $input->param('timeout'),
127
              $input->param('timeout'),
128
              $input->param('recordtype'),
128
              $input->param('recordtype'),
129
              $input->param('attributes'),
129
		      $input->param('searchfield'),
130
		      $input->param('searchfield'),
130
		      );
131
		      );
131
	} 
132
	} 
Lines 133-147 if ( $op eq 'add_form' ) { Link Here
133
        $template->param(confirm_add => 1);
134
        $template->param(confirm_add => 1);
134
		$sth=$dbh->prepare(
135
		$sth=$dbh->prepare(
135
		  "INSERT INTO z3950servers " .
136
		  "INSERT INTO z3950servers " .
136
              "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype) " .
137
              "(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout,recordtype,attributes) " .
137
               "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" );
138
               "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" );
138
        $sth->execute(
139
        $sth->execute(
139
            $input->param('host'),     $input->param('port'),
140
            $input->param('host'),     $input->param('port'),
140
            $input->param('db'),       $input->param('userid'),
141
            $input->param('db'),       $input->param('userid'),
141
            $input->param('password'), $input->param('searchfield'),
142
            $input->param('password'), $input->param('searchfield'),
142
            $checked,                  $input->param('rank'),
143
            $checked,                  $input->param('rank'),
143
            $input->param('syntax'),   $input->param('encoding'),
144
            $input->param('syntax'),   $input->param('encoding'),
144
            $input->param('timeout'),  $input->param('recordtype')
145
            $input->param('timeout'),  $input->param('recordtype'),
146
            $input->param('attributes')
145
        );
147
        );
146
    }
148
    }
147
    $sth->finish;
149
    $sth->finish;
Lines 154-160 if ( $op eq 'add_form' ) { Link Here
154
    my $dbh = C4::Context->dbh;
156
    my $dbh = C4::Context->dbh;
155
157
156
    my $sth2 = $dbh->prepare(
158
    my $sth2 = $dbh->prepare(
157
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype from z3950servers where (name = ?) order by rank,name"
159
"select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout,recordtype,attributes from z3950servers where (name = ?) order by rank,name"
158
    );
160
    );
159
    $sth2->execute($searchfield);
161
    $sth2->execute($searchfield);
160
    my $data = $sth2->fetchrow_hashref;
162
    my $data = $sth2->fetchrow_hashref;
Lines 171-176 if ( $op eq 'add_form' ) { Link Here
171
        syntax     => $data->{'syntax'},
173
        syntax     => $data->{'syntax'},
172
        timeout    => $data->{'timeout'},
174
        timeout    => $data->{'timeout'},
173
        recordtype => $data->{'recordtype'},
175
        recordtype => $data->{'recordtype'},
176
        attributes => $data->{'attributes'},
174
        encoding   => $data->{'encoding'}
177
        encoding   => $data->{'encoding'}
175
    );
178
    );
176
179
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 7330-7335 if ( CheckVersion($DBversion) ) { Link Here
7330
    SetVersion($DBversion);
7330
    SetVersion($DBversion);
7331
}
7331
}
7332
7332
7333
$DBversion = "3.13.00.XXX";
7334
if ( CheckVersion($DBversion) ) {
7335
    $dbh->do("ALTER TABLE z3950servers ADD COLUMN attributes VARCHAR(255);");
7336
    print "Upgrade to $DBversion done (Add new column z3950servers.attributes)\n";
7337
    SetVersion($DBversion);
7338
}
7339
7333
=head1 FUNCTIONS
7340
=head1 FUNCTIONS
7334
7341
7335
=head2 TableExists($table)
7342
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt (-1 / +3 lines)
Lines 139-144 Link Here
139
                </li>
139
                </li>
140
		<li><label for="rank">Rank (display order): </label>	<input type="text" name="rank" id="rank" size="4" value="[% rank %]" onblur="isNum(this)" />
140
		<li><label for="rank">Rank (display order): </label>	<input type="text" name="rank" id="rank" size="4" value="[% rank %]" onblur="isNum(this)" />
141
		</li>	
141
		</li>	
142
		<li><label for="attributes">Attributes (additional PQF attributes added to each query): </label>	<input type="text" name="attributes" id="attributes" size="30" value="[% attributes %]" />
143
		</li>	
142
		<li><label for="syntax">Syntax (z3950 can send<br /> records in various format. Choose one): </label>	
144
		<li><label for="syntax">Syntax (z3950 can send<br /> records in various format. Choose one): </label>	
143
<select name="syntax">
145
<select name="syntax">
144
[% IF ( syntaxUNIMARC ) %]
146
[% IF ( syntaxUNIMARC ) %]
Lines 289-294 Link Here
289
                <li><strong>Encoding: </strong>[% encoding %]</li>
291
                <li><strong>Encoding: </strong>[% encoding %]</li>
290
                <li><strong>Timeout: </strong>[% timeout %]</li>
292
                <li><strong>Timeout: </strong>[% timeout %]</li>
291
                <li><strong>Record type: </strong>[% recordtype %]</li>
293
                <li><strong>Record type: </strong>[% recordtype %]</li>
294
                <li><strong>Attributes: </strong>[% attributes %]</li>
292
	</ul>                <form action="[% script_name %]" method="post"><input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="searchfield" value="[% searchfield %]" /><input type="submit" value="Delete this server" /></form>  <form action="[% script_name %]" method="post"><input type="submit" value="Do not delete" /></form>
295
	</ul>                <form action="[% script_name %]" method="post"><input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="searchfield" value="[% searchfield %]" /><input type="submit" value="Delete this server" /></form>  <form action="[% script_name %]" method="post"><input type="submit" value="Do not delete" /></form>
293
296
294
297
295
- 

Return to bug 11297