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

(-)a/C4/AuthoritiesMarc.pm (-40 / +1 lines)
Lines 51-58 BEGIN { Link Here
51
    	&GetAuthority
51
    	&GetAuthority
52
    	&GetAuthorityXML
52
    	&GetAuthorityXML
53
53
54
    	&CountUsage
55
    	&CountUsageChildren
56
    	&SearchAuthorities
54
    	&SearchAuthorities
57
    
55
    
58
        &BuildSummary
56
        &BuildSummary
Lines 327-333 sub SearchAuthorities { Link Here
327
        ###
325
        ###
328
        if (! $skipmetadata) {
326
        if (! $skipmetadata) {
329
            for (my $z=0; $z<@finalresult; $z++){
327
            for (my $z=0; $z<@finalresult; $z++){
330
                my  $count=CountUsage($finalresult[$z]{authid});
328
                my $count = Koha::Authorities->get_usage_count({ authid => $finalresult[$z]{authid} });
331
                $finalresult[$z]{used}=$count;
329
                $finalresult[$z]{used}=$count;
332
            }# all $z's
330
            }# all $z's
333
        }
331
        }
Lines 340-382 sub SearchAuthorities { Link Here
340
    return (\@finalresult, $nbresults);
338
    return (\@finalresult, $nbresults);
341
}
339
}
342
340
343
=head2 CountUsage 
344
345
  $count= &CountUsage($authid)
346
347
counts Usage of Authid in bibliorecords. 
348
349
=cut
350
351
sub CountUsage {
352
    my ($authid) = @_;
353
        ### ZOOM search here
354
        my $query;
355
        $query= "an:".$authid;
356
        # Should really be replaced with a real count call, this is a
357
        # bad way.
358
        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
359
        my ($err,$res,$result) = $searcher->simple_search_compat($query,0,1);
360
        if ($err) {
361
            warn "Error: $err from search $query";
362
            $result = 0;
363
        }
364
365
        return $result;
366
}
367
368
=head2 CountUsageChildren 
369
370
  $count= &CountUsageChildren($authid)
371
372
counts Usage of narrower terms of Authid in bibliorecords.
373
374
=cut
375
376
sub CountUsageChildren {
377
  my ($authid) = @_;
378
}
379
380
=head2 GuessAuthTypeCode
341
=head2 GuessAuthTypeCode
381
342
382
  my $authtypecode = GuessAuthTypeCode($record);
343
  my $authtypecode = GuessAuthTypeCode($record);
(-)a/authorities/detail.pl (-2 / +3 lines)
Lines 178-184 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
178
178
179
my $authid = $query->param('authid');
179
my $authid = $query->param('authid');
180
180
181
my $authtypecode = Koha::Authorities->find($authid)->authtypecode;
181
my $authobj = Koha::Authorities->find($authid);
182
my $authtypecode = $authobj ? $authobj->authtypecode: q{};
182
$tagslib = &GetTagsLabels(1,$authtypecode);
183
$tagslib = &GetTagsLabels(1,$authtypecode);
183
184
184
# Build list of authtypes for showing them
185
# Build list of authtypes for showing them
Lines 200-206 if (C4::Context->preference("AuthDisplayHierarchy")){ Link Here
200
    $template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
201
    $template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
201
}
202
}
202
203
203
my $count = CountUsage($authid);
204
my $count = $authobj ? $authobj->get_usage_count : 0;
204
205
205
# find the marc field/subfield used in biblio by this authority
206
# find the marc field/subfield used in biblio by this authority
206
my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
207
my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
(-)a/opac/opac-authoritiesdetail.pl (-2 / +2 lines)
Lines 77-90 if ( ! $record ) { Link Here
77
}
77
}
78
78
79
my $authority = Koha::Authorities->find( $authid );
79
my $authority = Koha::Authorities->find( $authid );
80
my $authtypecode = $authority->authtypecode;
80
my $authtypecode = $authority ? $authority->authtypecode : q{};
81
81
82
if ($display_hierarchy){
82
if ($display_hierarchy){
83
    $template->{VARS}->{'displayhierarchy'} = $display_hierarchy;
83
    $template->{VARS}->{'displayhierarchy'} = $display_hierarchy;
84
    $template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
84
    $template->{VARS}->{'loophierarchies'} = GenerateHierarchy($authid);
85
}
85
}
86
86
87
my $count = CountUsage($authid);
87
my $count = $authority ? $authority->get_usage_count : 0;
88
88
89
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
89
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
90
$template->param(
90
$template->param(
(-)a/t/db_dependent/Koha/Authorities.t (-1 / +1 lines)
Lines 127-133 subtest 'Testing reporting_tag_xml in MergeRequest' => sub { Link Here
127
    );
127
    );
128
};
128
};
129
129
130
subtest 'Trivial tests for get_count_usage and linked_biblionumbers' => sub {
130
subtest 'Trivial tests for get_usage_count and linked_biblionumbers' => sub {
131
    plan tests => 5;
131
    plan tests => 5;
132
132
133
    # NOTE: We are not testing $searcher->simple_search_compat here. Suppose
133
    # NOTE: We are not testing $searcher->simple_search_compat here. Suppose
(-)a/tools/batch_delete_records.pl (-2 / +2 lines)
Lines 28-33 use C4::Output; Link Here
28
use C4::AuthoritiesMarc;
28
use C4::AuthoritiesMarc;
29
use C4::Biblio;
29
use C4::Biblio;
30
30
31
use Koha::Authorities;
31
use Koha::Biblios;
32
use Koha::Biblios;
32
33
33
my $input = new CGI;
34
my $input = new CGI;
Lines 101-107 if ( $op eq 'form' ) { Link Here
101
            $authority = {
102
            $authority = {
102
                authid => $record_id,
103
                authid => $record_id,
103
                summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ),
104
                summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ),
104
                count_usage => C4::AuthoritiesMarc::CountUsage( $record_id ),
105
                count_usage => Koha::Authorities->get_usage_count({ authid => $record_id }),
105
            };
106
            };
106
            push @records, $authority;
107
            push @records, $authority;
107
        }
108
        }
108
- 

Return to bug 18149