A new script to check URLs in 856$u field
[koha.git] / authorities / authorities.pl
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20
21 use strict;
22 use CGI;
23 use C4::Auth;
24 use C4::Output;
25 use C4::AuthoritiesMarc;
26 use C4::Context;
27 use C4::Koha; # XXX subfield_is_koha_internal_p
28 use Date::Calc qw(Today);
29 use MARC::File::USMARC;
30 use MARC::File::XML;
31 use C4::Biblio;
32 use vars qw( $tagslib);
33 use vars qw( $authorised_values_sth);
34 use vars qw( $is_a_modif );
35
36 my $itemtype; # created here because it can be used in build_authorized_values_list sub
37 our($authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
38
39 =item build_authorized_values_list
40
41 =cut
42
43 sub build_authorized_values_list ($$$$$$$) {
44     my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
45
46     my @authorised_values;
47     my %authorised_lib;
48
49     # builds list, depending on authorised value...
50
51     #---- branch
52     if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
53         my $sth =
54         $dbh->prepare(
55             "select branchcode,branchname from branches order by branchname");
56         $sth->execute;
57         push @authorised_values, ""
58         unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
59
60         while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
61             push @authorised_values, $branchcode;
62             $authorised_lib{$branchcode} = $branchname;
63         }
64
65         #----- itemtypes
66     }
67     elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
68         my $sth =
69         $dbh->prepare(
70             "select itemtype,description from itemtypes order by description");
71         $sth->execute;
72         push @authorised_values, ""
73         unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
74         
75         my $itemtype;
76         
77         while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
78             push @authorised_values, $itemtype;
79             $authorised_lib{$itemtype} = $description;
80         }
81         $value = $itemtype unless ($value);
82
83         #---- "true" authorised value
84     }
85     else {
86         $authorised_values_sth->execute(
87             $tagslib->{$tag}->{$subfield}->{authorised_value} );
88
89         push @authorised_values, ""
90         unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
91
92         while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
93             push @authorised_values, $value;
94             $authorised_lib{$value} = $lib;
95         }
96     }
97     return CGI::scrolling_list(
98         -name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
99         -values   => \@authorised_values,
100         -default  => $value,
101         -labels   => \%authorised_lib,
102         -override => 1,
103         -size     => 1,
104         -multiple => 0,
105         -tabindex => 1,
106         -id       => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
107         -class    => "input_marceditor",
108     );
109 }
110
111
112 =item create_input
113 builds the <input ...> entry for a subfield.
114 =cut
115
116 sub create_input {
117     my ( $tag, $subfield, $value, $index_tag, $tabloop, $rec, $authorised_values_sth,$cgi ) = @_;
118     
119     my $index_subfield = CreateKey(); # create a specifique key for each subfield
120
121     $value =~ s/"/&quot;/g;
122
123     # determine maximum length; 9999 bytes per ISO 2709 except for leader and MARC21 008
124     my $max_length = 9999;
125     if ($tag eq '000') {
126         $max_length = 24;
127     } elsif ($tag eq '008' and C4::Context->preference('marcflavour') eq 'MARC21')  {
128         $max_length = 40;
129     }
130
131     # if there is no value provided but a default value in parameters, get it
132     unless ($value) {
133         $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
134
135         # get today date & replace YYYY, MM, DD if provided in the default value
136         my ( $year, $month, $day ) = Today();
137         $month = sprintf( "%02d", $month );
138         $day   = sprintf( "%02d", $day );
139         $value =~ s/YYYY/$year/g;
140         $value =~ s/MM/$month/g;
141         $value =~ s/DD/$day/g;
142     }
143     my $dbh = C4::Context->dbh;
144     my %subfield_data = (
145         tag        => $tag,
146         subfield   => $subfield,
147         marc_lib   => substr( $tagslib->{$tag}->{$subfield}->{lib}, 0, 22 ),
148         marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib}, 
149         tag_mandatory  => $tagslib->{$tag}->{mandatory},
150         mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
151         repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
152         kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
153         index          => $index_tag,
154         id             => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
155         value          => $value,
156     );
157     if($subfield eq '@'){
158         $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_tag."_".$index_subfield;
159     } else {
160         $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield;
161     }
162
163     if(exists $mandatory_z3950->{$tag.$subfield}){
164         $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
165     }
166     
167     $subfield_data{visibility} = "display:none;"
168         if (    ($tagslib->{$tag}->{$subfield}->{hidden} % 2 == 1) and $value ne ''
169             or ($value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory})
170         );
171     
172     # it's an authorised field
173     if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
174         $subfield_data{marc_value} =
175         build_authorized_values_list( $tag, $subfield, $value, $dbh,
176             $authorised_values_sth,$index_tag,$index_subfield );
177
178     # it's a thesaurus / authority field
179     }
180     elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
181         $subfield_data{marc_value} =
182     "<input type=\"text\"
183                         id=\"".$subfield_data{id}."\"
184                         name=\"".$subfield_data{id}."\"
185     value=\"$value\"
186     class=\"input_marceditor\"
187     tabindex=\"1\"                     
188     disabled=\"disabled\"
189         readonly=\"readonly\" \/>
190     <span class=\"buttonDot\"
191         onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}')\">...</span>
192     ";
193     # it's a plugin field
194     }
195     elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) {
196
197         # opening plugin. Just check wether we are on a developper computer on a production one
198         # (the cgidir differs)
199         my $cgidir = C4::Context->intranetdir . "/cgi-bin/cataloguing/value_builder";
200         unless (-r $cgidir and -d $cgidir) {
201             $cgidir = C4::Context->intranetdir . "/cataloguing/value_builder";
202         }
203         my $plugin = $cgidir . "/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
204         do $plugin || die "Plugin Failed: ".$plugin;
205         my $extended_param = plugin_parameters( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
206         my ( $function_name, $javascript ) = plugin_javascript( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
207 #         my ( $function_name, $javascript,$extended_param );
208         
209         $subfield_data{marc_value} =
210             "<input tabindex=\"1\"
211                     type=\"text\"
212                     id=\"".$subfield_data{id}."\"
213                     size=\"67\"
214                     maxlength=\"$max_length\"
215                     name=\"".$subfield_data{id}."\"
216                     value=\"$value\"
217                     class=\"input_marceditor\"
218                     onfocus=\"Focus$function_name($index_tag)\"
219                     onblur=\"Blur$function_name($index_tag); \" \/>
220                     <a href=\"#\" class=\"buttonDot\" onclick=\"Clic$function_name('$subfield_data{id}'); return false;\" title=\"Tag Editor\">...</a>
221                     $javascript";
222         # it's an hidden field
223     }
224     elsif ( $tag eq '' ) {
225         $subfield_data{marc_value} =
226             "<input tabindex=\"1\"
227                     type=\"hidden\"
228                     id=\"".$subfield_data{id}."\"
229                     name=\"".$subfield_data{id}."\"
230                     size=\"67\"
231                     maxlength=\"$max_length\"
232                     value=\"$value\" \/>
233             ";
234     }
235     elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) {
236         $subfield_data{marc_value} =
237             "<input type=\"text\"
238                     id=\"".$subfield_data{id}."\"
239                     name=\"".$subfield_data{id}."\"
240                     class=\"input_marceditor\"
241                     tabindex=\"1\"
242                     size=\"67\"
243                     maxlength=\"$max_length\"
244                     value=\"$value\"
245             \/>";
246
247         # it's a standard field
248     }
249     else {
250         if (
251             length($value) > 100
252             or
253             ( C4::Context->preference("marcflavour") eq "UNIMARC" && $tag >= 300
254                 and $tag < 400 && $subfield eq 'a' )
255             or (    $tag >= 600
256                 and $tag < 700
257                 && C4::Context->preference("marcflavour") eq "MARC21" )
258         )
259         {
260             $subfield_data{marc_value} =
261                 "<textarea cols=\"70\"
262                         rows=\"4\"
263                         id=\"".$subfield_data{id}."\"
264                         name=\"".$subfield_data{id}."\"
265                         class=\"input_marceditor\"
266                         tabindex=\"1\"
267                         size=\"67\"
268                         maxlength=\"$max_length\"
269                         >$value</textarea>
270                 ";
271         }
272         else {
273             $subfield_data{marc_value} =
274                 "<input type=\"text\"
275                         id=\"".$subfield_data{id}."\"
276                         name=\"".$subfield_data{id}."\"
277                         value=\"$value\"
278                         tabindex=\"1\"
279                         size=\"67\"
280                         maxlength=\"$max_length\"
281                         class=\"input_marceditor\"
282                 \/>
283                 ";
284         }
285     }
286     $subfield_data{'index_subfield'} = $index_subfield;
287     return \%subfield_data;
288 }
289
290 =item format_indicator
291
292 Translate indicator value for output form - specifically, map
293 indicator = ' ' to ''.  This is for the convenience of a cataloger
294 using a mouse to select an indicator input.
295
296 =cut
297
298 sub format_indicator {
299     my $ind_value = shift;
300     return '' if not defined $ind_value;
301     return '' if $ind_value eq ' ';
302     return $ind_value;
303 }
304
305 =item CreateKey
306
307     Create a random value to set it into the input name
308
309 =cut
310
311 sub CreateKey(){
312     return int(rand(1000000));
313 }
314
315 sub build_tabs ($$$$$) {
316     my ( $template, $record, $dbh, $encoding,$input ) = @_;
317
318     # fill arrays
319     my @loop_data = ();
320     my $tag;
321
322     my $authorised_values_sth = $dbh->prepare(
323         "SELECT authorised_value,lib
324         FROM authorised_values
325         WHERE category=? ORDER BY lib"
326     );
327     
328     # in this array, we will push all the 10 tabs
329     # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
330     my @BIG_LOOP;
331     my %seen;
332     my @tab_data; # all tags to display
333     
334     foreach my $used ( keys %$tagslib ){
335         push @tab_data,$used if not $seen{$used};
336         $seen{$used}++;
337     }
338         
339     my $max_num_tab=9;
340     # loop through each tab 0 through 9
341     for ( my $tabloop = 0 ; $tabloop <= $max_num_tab ; $tabloop++ ) {
342         my @loop_data = (); #innerloop in the template.
343         my $i = 0;
344         foreach my $tag (sort @tab_data) {
345             $i++;
346             next if ! $tag;
347             my ($indicator1, $indicator2);
348             my $index_tag = CreateKey;
349
350             # if MARC::Record is not empty =>use it as master loop, then add missing subfields that should be in the tab.
351             # if MARC::Record is empty => use tab as master loop.
352             if ( $record ne -1 && ( $record->field($tag) || $tag eq '000' ) ) {
353                 my @fields;
354                 if ( $tag ne '000' ) {
355                                 @fields = $record->field($tag);
356                 }
357                 else {
358                 push @fields, $record->leader(); # if tag == 000
359                 }
360                 # loop through each field
361                 foreach my $field (@fields) {
362                     
363                     my @subfields_data;
364                     if ( $tag < 10 ) {
365                         my ( $value, $subfield );
366                         if ( $tag ne '000' ) {
367                             $value    = $field->data();
368                             $subfield = "@";
369                         }
370                         else {
371                             $value    = $field;
372                             $subfield = '@';
373                         }
374                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
375                         push(
376                             @subfields_data,
377                             &create_input(
378                                 $tag, $subfield, $value, $index_tag, $tabloop, $record,
379                                 $authorised_values_sth,$input
380                             )
381                         );
382                     }
383                     else {
384                         my @subfields = $field->subfields();
385                         foreach my $subfieldcount ( 0 .. $#subfields ) {
386                             my $subfield = $subfields[$subfieldcount][0];
387                             my $value    = $subfields[$subfieldcount][1];
388                             next if ( length $subfield != 1 );
389                             next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
390                             push(
391                                 @subfields_data,
392                                 &create_input(
393                                     $tag, $subfield, $value, $index_tag, $tabloop,
394                                     $record, $authorised_values_sth,$input
395                                 )
396                             );
397                         }
398                     }
399
400                     # now, loop again to add parameter subfield that are not in the MARC::Record
401                     foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
402                     {
403                         next if ( length $subfield != 1 );
404                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
405                         next if ( $tag < 10 );
406                         next
407                         if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4 )
408                             or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 )
409                         );    #check for visibility flag
410                         next if ( defined( $field->subfield($subfield) ) );
411                         push(
412                             @subfields_data,
413                             &create_input(
414                                 $tag, $subfield, '', $index_tag, $tabloop, $record,
415                                 $authorised_values_sth,$input
416                             )
417                         );
418                     }
419                     if ( $#subfields_data >= 0 ) {
420                         # build the tag entry.
421                         # note that the random() field is mandatory. Otherwise, on repeated fields, you'll 
422                         # have twice the same "name" value, and cgi->param() will return only one, making
423                         # all subfields to be merged in a single field.
424                         my %tag_data = (
425                             tag           => $tag,
426                             index         => $index_tag,
427                             tag_lib       => $tagslib->{$tag}->{lib},
428                             repeatable       => $tagslib->{$tag}->{repeatable},
429                             mandatory       => $tagslib->{$tag}->{mandatory},
430                             subfield_loop => \@subfields_data,
431                             fixedfield    => ($tag < 10)?(1):(0),
432                             random        => CreateKey,
433                         );
434                         if ($tag >= 010){ # no indicator for theses tag
435                             $tag_data{indicator1} = format_indicator($field->indicator(1)),
436                             $tag_data{indicator2} = format_indicator($field->indicator(2)),
437                         }
438                         push( @loop_data, \%tag_data );
439                     }
440                 } # foreach $field end
441
442             # if breeding is empty
443             }
444             else {
445                 my @subfields_data;
446                 foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
447                     next if ( length $subfield != 1 );
448                     next if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -5 )
449                                 or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 4 ) )
450                             ;    #check for visibility flag
451                     next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
452                     push(
453                         @subfields_data,
454                         &create_input(
455                             $tag, $subfield, '', $index_tag, $tabloop, $record,
456                             $authorised_values_sth,$input
457                         )
458                     );
459                 }
460                 if ( $#subfields_data >= 0 ) {
461                     my %tag_data = (
462                         tag              => $tag,
463                         index            => $index_tag,
464                         tag_lib          => $tagslib->{$tag}->{lib},
465                         repeatable       => $tagslib->{$tag}->{repeatable},
466                         mandatory       => $tagslib->{$tag}->{mandatory},
467                         indicator1       => $indicator1,
468                         indicator2       => $indicator2,
469                         subfield_loop    => \@subfields_data,
470                         tagfirstsubfield => $subfields_data[0],
471                         fixedfield       => ($tag < 10)?(1):(0)
472                     );
473                     
474                     push @loop_data, \%tag_data ;
475                 }
476             }
477         }
478         if ( $#loop_data >= 0 ) {
479             push @BIG_LOOP, {
480                 number    => $tabloop,
481                 innerloop => \@loop_data,
482             };
483         }
484     }
485     $template->param( BIG_LOOP => \@BIG_LOOP );
486 }
487
488
489 sub build_hidden_data () {
490     # build hidden data =>
491     # we store everything, even if we show only requested subfields.
492
493     my @loop_data =();
494     my $i=0;
495     foreach my $tag (keys %{$tagslib}) {
496         my $previous_tag = '';
497
498         # loop through each subfield
499         foreach my $subfield (keys %{$tagslib->{$tag}}) {
500             next if ($subfield eq 'lib');
501             next if ($subfield eq 'tab');
502             next if ($subfield eq 'mandatory');
503                 next if ($subfield eq 'repeatable');
504             next if ($tagslib->{$tag}->{$subfield}->{'tab'}  ne "-1");
505             my %subfield_data;
506             $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
507             $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
508             $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
509             $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value[]\">";
510             push(@loop_data, \%subfield_data);
511             $i++
512         }
513     }
514 }
515
516 # ======================== 
517 #          MAIN 
518 #=========================
519 my $input = new CGI;
520 my $z3950 = $input->param('z3950');
521 my $error = $input->param('error');
522 my $authid=$input->param('authid'); # if authid exists, it's a modif, not a new authority.
523 my $op = $input->param('op');
524 my $nonav = $input->param('nonav');
525 my $myindex = $input->param('index');
526 my $linkid=$input->param('linkid');
527 my $authtypecode = $input->param('authtypecode');
528
529 my $dbh = C4::Context->dbh;
530 $authtypecode = &GetAuthTypeCode($authid) if !$authtypecode;
531
532 my ($template, $loggedinuser, $cookie)
533     = get_template_and_user({template_name => "authorities/authorities.tmpl",
534                             query => $input,
535                             type => "intranet",
536                             authnotrequired => 0,
537                             flagsrequired => {editauthorities => 1},
538                             debug => 1,
539                             });
540 $template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,);
541 $tagslib = GetTagsLabels(1,$authtypecode);
542 my $record=-1;
543 my $encoding="";
544 $record = GetAuthority($authid) if ($authid);
545 my ($oldauthnumtagfield,$oldauthnumtagsubfield);
546 my ($oldauthtypetagfield,$oldauthtypetagsubfield);
547 $is_a_modif=0;
548 if ($authid) {
549     $is_a_modif=1;
550     ($oldauthnumtagfield,$oldauthnumtagsubfield) = &GetAuthMARCFromKohaField("auth_header.authid",$authtypecode);
551     ($oldauthtypetagfield,$oldauthtypetagsubfield) = &GetAuthMARCFromKohaField("auth_header.authtypecode",$authtypecode);
552 }
553
554 #------------------------------------------------------------------------------------------------------------------------------
555 if ($op eq "add") {
556 #------------------------------------------------------------------------------------------------------------------------------
557     # rebuild
558     my @tags = $input->param('tag');
559     my @subfields = $input->param('subfield');
560     my @values = $input->param('field_value');
561     # build indicator hash.
562     my @ind_tag = $input->param('ind_tag');
563     my @indicator = $input->param('indicator');
564     my @params = $input->param();
565     my $record = TransformHtmlToMarc(\@params,$input);
566     if  (C4::Context->preference("marcflavour") eq "UNIMARC"){
567         unless ($record->field('100')){
568         use POSIX qw(strftime);
569         my $string = strftime( "%Y%m%d", localtime(time) );
570         # set 50 to position 26 is biblios, 13 if authorities
571         my $pos=13;
572         $string = sprintf( "%-*s", 35, $string );
573         substr( $string, $pos , 2, "50" );
574         $record->append_fields(MARC::Field->new('100','','',"a"=>$string));
575         }    
576     }
577
578     my ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority($record,$authtypecode) if ($op eq "add") && (!$is_a_modif);
579     my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
580     # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
581     if (!$duplicateauthid or $confirm_not_duplicate) {
582         if ($is_a_modif ) {     
583             ModAuthority($authid,$record,$authtypecode);
584         } else {
585             ($authid) = AddAuthority($record,$authid,$authtypecode);
586         }
587         print $input->redirect("detail.pl?authid=$authid");
588         exit;
589     } else {
590     # it may be a duplicate, warn the user and do nothing
591         build_tabs($template, $record, $dbh, $encoding,$input);
592         build_hidden_data;
593         $template->param(authid =>$authid,
594                         duplicateauthid     => $duplicateauthid,
595                         duplicateauthvalue  => $duplicateauthvalue,
596                         );
597     }
598 } elsif ($op eq "delete") {
599 #------------------------------------------------------------------------------------------------------------------------------
600         &DelAuthority($authid);
601         if ($nonav){
602             print $input->redirect("auth_finder.pl");
603         }else{
604             print $input->redirect("authorities-home.pl?authid=0");
605         }
606                 exit;
607 } else {
608 if ($op eq "duplicate")
609         {
610                 $authid = "";
611         }
612         build_tabs ($template, $record, $dbh,$encoding,$input);
613         build_hidden_data;
614         $template->param(oldauthtypetagfield=>$oldauthtypetagfield, oldauthtypetagsubfield=>$oldauthtypetagsubfield,
615                         oldauthnumtagfield=>$oldauthnumtagfield, oldauthnumtagsubfield=>$oldauthnumtagsubfield,
616                         authid                      => $authid , authtypecode=>$authtypecode,   );
617 }
618
619 $template->param(authid                       => $authid,
620                  authtypecode => $authtypecode,
621                  linkid=>$linkid,
622 );
623
624 my $authtypes = getauthtypes;
625 my @authtypesloop;
626 foreach my $thisauthtype (keys %$authtypes) {
627     my $selected = 1 if $thisauthtype eq $authtypecode;
628     my %row =(value => $thisauthtype,
629                 selected => $selected,
630                 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
631             );
632     push @authtypesloop, \%row;
633 }
634
635 $template->param(authtypesloop => \@authtypesloop,
636                 authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
637                 hide_marc => C4::Context->preference('hide_marc'),
638                 );
639 output_html_with_http_headers $input, $cookie, $template->output;