Bug 11030 - Add 359, 947 and 969 fields in french unimarc_complete framework - followup
[koha_fer] / acqui / ajax-getauthvaluedropbox.pl
index 57c1f99..0a74ada 100755 (executable)
@@ -1,21 +1,21 @@
 #!/usr/bin/perl
 
-# Copyright 2012 BibLibre
-#
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Copyright 2012 BibLibre
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 =head1 NAME
 
@@ -48,8 +48,19 @@ Default value for the dropbox.
 use Modern::Perl;
 
 use CGI;
-use C4::Budgets;
+use C4::Koha;
 use C4::Charset;
+use C4::Auth qw/check_api_auth/;
+
+my $query = CGI->new();
+binmode STDOUT, ':encoding(UTF-8)';
+
+my ($status, $cookie, $sessionID) = check_api_auth($query, { catalogue => '*'} );
+unless ($status eq "ok") {
+    print $query->header(-type => 'text/plain', -status => '403 Forbidden');
+    print '<option></option>';
+    exit 0;
+}
 
 my $input = new CGI;
 my $name = $input->param('name');
@@ -59,7 +70,7 @@ $default = C4::Charset::NormalizeString($default);
 
 binmode STDOUT, ':encoding(UTF-8)';
 print $input->header(-type => 'text/plain', -charset => 'UTF-8');
-my $avs = GetAuthvalueDropbox($category, $default);
+my $avs = C4::Koha::GetAuthvalueDropbox($category, $default);
 my $html = qq|<select id="$name" name="$name">|;
 for my $av ( @$avs ) {
     if ( $av->{default} ) {