Bug 10963: Simplified creation - FA framework
[koha.git] / tags / list.pl
blob2d5c5c88366a149bde06d92f9e8296fb17e7a07c
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 warnings;
21 use strict;
22 use CGI qw ( -utf8 );
24 use C4::Auth qw(:DEFAULT check_cookie_auth);
25 use C4::Biblio;
26 use C4::Context;
27 use C4::Dates qw(format_date);
28 use C4::Items;
29 use C4::Koha;
30 use C4::Tags qw(get_tags remove_tag get_tag_rows);
31 use C4::Output;
33 my $needed_flags = { tools => 'moderate_tags'
34 }; # FIXME: replace when more specific permission is created.
36 my $query = CGI->new;
37 my $op = $query->param('op') || '';
38 my $biblionumber = $query->param('biblionumber');
39 my $tag = $query->param('tag');
40 my $tag_id = $query->param('tag_id');
42 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
44 template_name => "tags/list.tt",
45 query => $query,
46 type => "intranet",
47 debug => 1,
48 authnotrequired => 0,
49 flagsrequired => $needed_flags,
53 if ( $op eq "del" ) {
54 remove_tag($tag_id);
55 print $query->redirect("/cgi-bin/koha/tags/list.pl?tag=$tag");
57 else {
59 my $marcflavour = C4::Context->preference('marcflavour');
60 my @results;
62 if ($tag) {
63 my $taglist = get_tag_rows( { term => $tag } );
64 for ( @{$taglist} ) {
65 my $dat = &GetBiblioData( $_->{biblionumber} );
66 my $record = &GetMarcBiblio( $_->{biblionumber} );
67 $dat->{'subtitle'} =
68 GetRecordValue( 'subtitle', $record,
69 GetFrameworkCode( $_->{biblionumber} ) );
70 my @items = GetItemsInfo( $_->{biblionumber} );
71 $dat->{biblionumber} = $_->{biblionumber};
72 $dat->{tag_id} = $_->{tag_id};
73 $dat->{items} = \@items;
74 $dat->{TagLoop} = get_tags(
76 biblionumber => $_->{biblionumber},
77 'sort' => '-weight',
78 limit => 10
81 push( @results, $dat );
84 my $resultsarray = \@results;
86 $template->param(
87 tag => $tag,
88 titles => $resultsarray,
93 output_html_with_http_headers $query, $cookie, $template->output;