Bug 21797: Update two-column templates with Bootstrap grid: Acquisitions part 5
[koha.git] / tags / list.pl
blob862327862f5d751f45ce870e035bd85a490d9f3b
1 #!/usr/bin/perl
3 # Copyright 2011 Athens County Public Libraries
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
21 use CGI qw ( -utf8 );
23 use C4::Auth qw(:DEFAULT check_cookie_auth);
24 use C4::Biblio;
25 use C4::Context;
26 use C4::Items;
27 use C4::Koha;
28 use C4::Tags qw(get_tags remove_tag get_tag_rows);
29 use C4::Output;
31 my $needed_flags = { tools => 'moderate_tags'
32 }; # FIXME: replace when more specific permission is created.
34 my $query = CGI->new;
35 my $op = $query->param('op') || '';
36 my $biblionumber = $query->param('biblionumber');
37 my $tag = $query->param('tag');
38 my $tag_id = $query->param('tag_id');
40 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
42 template_name => "tags/list.tt",
43 query => $query,
44 type => "intranet",
45 debug => 1,
46 authnotrequired => 0,
47 flagsrequired => $needed_flags,
51 if ( $op eq "del" ) {
52 remove_tag($tag_id);
53 print $query->redirect("/cgi-bin/koha/tags/list.pl?tag=$tag");
55 else {
57 my $marcflavour = C4::Context->preference('marcflavour');
58 my @results;
60 if ($tag) {
61 my $taglist = get_tag_rows( { term => $tag } );
62 for ( @{$taglist} ) {
63 my $dat = &GetBiblioData( $_->{biblionumber} );
64 my $record = &GetMarcBiblio({ biblionumber => $_->{biblionumber} });
65 $dat->{'subtitle'} =
66 GetRecordValue( 'subtitle', $record,
67 GetFrameworkCode( $_->{biblionumber} ) );
68 my @items = GetItemsInfo( $_->{biblionumber} );
69 $dat->{biblionumber} = $_->{biblionumber};
70 $dat->{tag_id} = $_->{tag_id};
71 $dat->{items} = \@items;
72 $dat->{TagLoop} = get_tags(
74 biblionumber => $_->{biblionumber},
75 'sort' => '-weight',
76 limit => 10
79 push( @results, $dat );
82 my $resultsarray = \@results;
84 $template->param(
85 tag => $tag,
86 titles => $resultsarray,
91 output_html_with_http_headers $query, $cookie, $template->output;