Add 3 more links to Ohloh to about page
[koha.git] / authorities / authorities-home.pl
blobfbaa1ba3dfd9c8457990bd7b4e69ba32157c0b19
1 #!/usr/bin/perl
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 use warnings;
23 use CGI;
24 use C4::Auth;
26 use C4::Context;
27 use C4::Auth;
28 use C4::Output;
29 use C4::AuthoritiesMarc;
30 use C4::Acquisition;
31 use C4::Koha; # XXX subfield_is_koha_internal_p
32 use C4::Biblio;
34 my $query = new CGI;
35 my $op = $query->param('op');
36 $op ||= q{};
37 my $authtypecode = $query->param('authtypecode');
38 $authtypecode ||= q{};
39 my $dbh = C4::Context->dbh;
41 my $authid = $query->param('authid');
42 my ( $template, $loggedinuser, $cookie );
44 my $authtypes = getauthtypes;
45 my @authtypesloop;
46 foreach my $thisauthtype ( sort { $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'} }
47 keys %$authtypes )
49 my %row = (
50 value => $thisauthtype,
51 selected => $thisauthtype eq $authtypecode,
52 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
54 push @authtypesloop, \%row;
57 if ( $op eq "do_search" ) {
58 my @marclist = $query->param('marclist');
59 my @and_or = $query->param('and_or');
60 my @excluding = $query->param('excluding');
61 my @operator = $query->param('operator');
62 my $orderby = $query->param('orderby');
63 my @value = $query->param('value');
65 my $startfrom = $query->param('startfrom') || 1;
66 my $resultsperpage = $query->param('resultsperpage') || 20;
68 my ( $results, $total ) =
69 SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value,
70 ( $startfrom - 1 ) * $resultsperpage,
71 $resultsperpage, $authtypecode, $orderby );
72 # use Data::Dumper; warn Data::Dumper::Dumper(@$results);
73 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
75 template_name => "authorities/searchresultlist.tmpl",
76 query => $query,
77 type => 'intranet',
78 authnotrequired => 0,
79 flagsrequired => { catalogue => 1 },
80 debug => 1,
84 my @field_data = ();
86 # we must get parameters once again. Because if there is a mainentry, it
87 # has been replaced by something else during the search, thus the links
88 # next/previous would not work anymore
89 my @marclist_ini = $query->param('marclist');
90 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
91 if ($value[$i]){
92 push @field_data, { term => "marclist", val => $marclist_ini[$i] };
93 if (!defined $and_or[$i]) {
94 $and_or[$i] = q{};
96 push @field_data, { term => "and_or", val => $and_or[$i] };
97 if (!defined $excluding[$i]) {
98 $excluding[$i] = q{};
100 push @field_data, { term => "excluding", val => $excluding[$i] };
101 push @field_data, { term => "operator", val => $operator[$i] };
102 push @field_data, { term => "value", val => $value[$i] };
106 # construction of the url of each page
107 my $base_url =
108 'authorities-home.pl?'
109 . join( '&amp;', map { $_->{term} . '=' . $_->{val} } @field_data )
110 . '&amp;'
111 . join(
112 '&amp;',
113 map { $_->{term} . '=' . $_->{val} } (
114 { term => 'resultsperpage', val => $resultsperpage },
115 { term => 'type', val => 'intranet' },
116 { term => 'op', val => 'do_search' },
117 { term => 'authtypecode', val => $authtypecode },
118 { term => 'orderby', val => $orderby },
122 my $from = ( $startfrom - 1 ) * $resultsperpage + 1;
123 my $to;
124 if (!defined $total) {
125 $total = 0;
128 if ( $total < $startfrom * $resultsperpage ) {
129 $to = $total;
131 else {
132 $to = $startfrom * $resultsperpage;
135 $template->param( result => $results ) if $results;
137 $template->param(
138 pagination_bar => pagination_bar(
139 $base_url, int( $total / $resultsperpage ) + 1,
140 $startfrom, 'startfrom'
142 total => $total,
143 from => $from,
144 to => $to,
145 isEDITORS => $authtypecode eq 'EDITORS',
149 elsif ( $op eq "delete" ) {
151 &DelAuthority( $authid, 1 );
153 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
155 template_name => "authorities/authorities-home.tmpl",
156 query => $query,
157 type => 'intranet',
158 authnotrequired => 0,
159 flagsrequired => { catalogue => 1 },
160 debug => 1,
164 # $template->param("statements" => \@statements,
165 # "nbstatements" => $nbstatements);
167 else {
168 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
170 template_name => "authorities/authorities-home.tmpl",
171 query => $query,
172 type => 'intranet',
173 authnotrequired => 0,
174 flagsrequired => { catalogue => 1 },
175 debug => 1,
181 $template->param(
182 authtypesloop => \@authtypesloop,
185 # Print the page
186 output_html_with_http_headers $query, $cookie, $template->output;