bug 2884: followup patch
[koha.git] / admin / auth_subfields_structure.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 use C4::Output;
22 use C4::Auth;
23 use CGI;
24 use C4::Context;
25
26
27 sub string_search  {
28         my ($searchstring,$authtypecode)=@_;
29         my $dbh = C4::Context->dbh;
30         $searchstring=~ s/\'/\\\'/g;
31         my @data=split(' ',$searchstring);
32         my $count=@data;
33         my $sth=$dbh->prepare("Select * from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield");
34         $sth->execute("$searchstring%",$authtypecode);
35         my @results;
36         my $cnt=0;
37         my $u=1;
38         while (my $data=$sth->fetchrow_hashref){
39                 push(@results,$data);
40                 $cnt ++;
41                 $u++;
42         }
43         $sth->finish;
44         return ($cnt,\@results);
45 }
46
47 sub auth_subfield_structure_exists {
48         my ($authtypecode, $tagfield, $tagsubfield) = @_;
49         my $dbh  = C4::Context->dbh;
50         my $sql  = "select tagfield from auth_subfield_structure where authtypecode = ? and tagfield = ? and tagsubfield = ?";
51         my $rows = $dbh->selectall_arrayref($sql, {}, $authtypecode, $tagfield, $tagsubfield);
52         return @$rows > 0;
53 }
54
55 my $input = new CGI;
56 my $tagfield=$input->param('tagfield');
57 my $tagsubfield=$input->param('tagsubfield');
58 my $authtypecode=$input->param('authtypecode');
59 my $pkfield="tagfield";
60 my $offset=$input->param('offset');
61 my $script_name="/cgi-bin/koha/admin/auth_subfields_structure.pl";
62
63 my ($template, $borrowernumber, $cookie)
64     = get_template_and_user({template_name => "admin/auth_subfields_structure.tmpl",
65                              query => $input,
66                              type => "intranet",
67                              authnotrequired => 0,
68                              flagsrequired => {parameters => 1},
69                              debug => 1,
70                              });
71 my $pagesize=30;
72 my $op = $input->param('op');
73 $tagfield=~ s/\,//g;
74
75 if ($op) {
76 $template->param(script_name => $script_name,
77                                                 tagfield =>$tagfield,
78                                                 authtypecode => $authtypecode,
79                                                 $op              => 1); # we show only the TMPL_VAR names $op
80 } else {
81 $template->param(script_name => $script_name,
82                                                 tagfield =>$tagfield,
83                                                 authtypecode => $authtypecode,
84                                                 else              => 1); # we show only the TMPL_VAR names $op
85 }
86
87 ################## ADD_FORM ##################################
88 # called by default. Used to create form to add or  modify a record
89 if ($op eq 'add_form') {
90         my $data;
91         my $dbh = C4::Context->dbh;
92         my $more_subfields = $input->param("more_subfields")+1;
93         # builds kohafield tables
94         my @kohafields;
95         push @kohafields, "";
96         my $sth2=$dbh->prepare("SHOW COLUMNS from auth_header");
97         $sth2->execute;
98         while ((my $field) = $sth2->fetchrow_array) {
99                 push @kohafields, "auth_header.".$field;
100         }
101         
102         # build authorised value list
103         $sth2->finish;
104         $sth2 = $dbh->prepare("select distinct category from authorised_values");
105         $sth2->execute;
106         my @authorised_values;
107         push @authorised_values,"";
108         while ((my $category) = $sth2->fetchrow_array) {
109                 push @authorised_values, $category;
110         }
111         push (@authorised_values,"branches");
112         push (@authorised_values,"itemtypes");
113     
114     # build thesaurus categories list
115     $sth2->finish;
116     $sth2 = $dbh->prepare("select authtypecode from auth_types");
117     $sth2->execute;
118     my @authtypes;
119     push @authtypes, "";
120     while ( ( my $authtypecode ) = $sth2->fetchrow_array ) {
121         push @authtypes, $authtypecode;
122     }
123
124         # build value_builder list
125         my @value_builder=('');
126
127         # read value_builder directory.
128         # 2 cases here : on CVS install, $cgidir does not need a /cgi-bin
129         # on a standard install, /cgi-bin need to be added. 
130         # test one, then the other
131         my $cgidir = C4::Context->intranetdir ."/cgi-bin";
132         unless (opendir(DIR, "$cgidir/cataloguing/value_builder")) {
133                 $cgidir = C4::Context->intranetdir;
134                 opendir(DIR, "$cgidir/cataloguing/value_builder") || die "can't opendir $cgidir/value_builder: $!";
135         } 
136         while (my $line = readdir(DIR)) {
137                 if ($line =~ /\.pl$/) {
138                         push (@value_builder,$line);
139                 }
140         }
141         @value_builder= sort {$a cmp $b} @value_builder;
142         closedir DIR;
143
144         # build values list
145         my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and authtypecode=?"); # and tagsubfield='$tagsubfield'");
146         $sth->execute($tagfield,$authtypecode);
147         my @loop_data = ();
148         my $toggle=1;
149         my $i=0;
150         while ($data =$sth->fetchrow_hashref) {
151
152                 my %row_data;  # get a fresh hash for the row data
153                 if ($toggle eq 1){
154                         $toggle=0;
155                 } else {
156                         $toggle=1;
157                 }
158                 $row_data{tab} = CGI::scrolling_list(-name=>'tab',
159                                         -id=>"tab$i",
160                                         -values =>
161                                         [ '-1', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ],
162                                         -labels => {
163                                             '-1' => 'ignore',
164                                             '0'  => '0',
165                                             '1'  => '1',
166                                             '2'  => '2',
167                                             '3'  => '3',
168                                             '4'  => '4',
169                                             '5'  => '5',
170                                             '6'  => '6',
171                                             '7'  => '7',
172                                             '8'  => '8',
173                                             '9'  => '9',
174                                         },
175                                         -default=>$data->{'tab'},
176                                         -size=>1,
177                                         -tabindex=>'',
178                                         -multiple=>0,
179                                         );
180                 $row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
181                                         -id=>"ohidden$i",
182                                         #-values=>['0','1','2'],
183                                         #-labels => {'0'=>'Show','1'=>'Show Collapsed',
184                                         #                               '2' =>'Hide',
185                                         #                               },
186                                         -values=>['0','-5'],
187                                         -labels => {'0'=>'Show All','-5'=>'Hide All',},
188                                         -default=>$data->{'hidden'},
189                                         #-default=>"-5",
190                                         -size=>1,
191                                         -multiple=>0,
192                                         );
193                 #$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
194                 #                       -id=>"ihidden$i",
195                 #                       -values=>['0','1','2'],
196                 #                       -labels => {'0'=>'Show','1'=>'Show Collapsed',
197                 #                                                       '2' =>'Hide',
198                 #                                                       },
199                 #                       -default=>substr($data->{'hidden'},1,1),
200                 #                       -size=>1,
201                 #                       -multiple=>0,
202                 #                       );
203                 #$row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden',
204                 #                       -id=>"ehidden$i",
205                 #                       -values=>['0','1','2'],
206                 #                       -labels => {'0'=>'Show','1'=>'Show Collapsed',
207                 #                                                       '2' =>'Hide',
208                 #                                                       },
209                 #                       -default=>substr($data->{'hidden'}."  ",2,1),
210                 #                       -size=>1,
211                 #                       -multiple=>0,
212                 #                       );
213                 $row_data{tagsubfieldinput} = "<input type=\"hidden\" name=\"tagsubfield\" value=\"".$data->{'tagsubfield'}."\" id=\"tagsubfield\" />";
214                 $row_data{tagsubfield} = $data->{'tagsubfield'};
215                 $row_data{liblibrarian} = CGI::escapeHTML($data->{'liblibrarian'});
216                 $row_data{libopac} = CGI::escapeHTML($data->{'libopac'});
217                 $row_data{seealso} = CGI::escapeHTML($data->{'seealso'});
218                 $row_data{kohafield}= CGI::scrolling_list( -name=>"kohafield",
219                                         -id=>"kohafield$i",
220                                         -values=> \@kohafields,
221                                         -default=> "$data->{'kohafield'}",
222                                         -size=>1,
223                                         -multiple=>0,
224                                         );
225                 $row_data{authorised_value}  = CGI::scrolling_list(-name=>'authorised_value',
226                                         -id=>"authorised_value$i",
227                                         -values=> \@authorised_values,
228                                         -default=>$data->{'authorised_value'},
229                                         -size=>1,
230                                         -tabindex=>'',
231                                         -multiple=>0,
232                                         );
233                 $row_data{frameworkcode}  = CGI::scrolling_list(-name=>'frameworkcode',
234                                         -id=>"frameworkcode$i",
235                                         -values=> \@authtypes,
236                                         -default=>$data->{'frameworkcode'},
237                                         -size=>1,
238                                         -tabindex=>'',
239                                         -multiple=>0,
240                                         );
241                 $row_data{value_builder}  = CGI::scrolling_list(-name=>'value_builder',
242                                         -id=>"value_builder$i",
243                                         -values=> \@value_builder,
244                                         -default=>$data->{'value_builder'},
245                                         -size=>1,
246                                         -tabindex=>'',
247                                         -multiple=>0,
248                                         );
249                 
250                 $row_data{repeatable} = CGI::checkbox(-name=>"repeatable$i",
251         -checked => $data->{'repeatable'}?'checked':'',
252         -value => 1,
253         -label => '',
254         -id => "repeatable$i");
255                 $row_data{mandatory} = CGI::checkbox(-name => "mandatory$i",
256         -checked => $data->{'mandatory'}?'checked':'',
257         -value => 1,
258         -label => '',
259         -id => "mandatory$i");
260                 $row_data{hidden} = CGI::escapeHTML($data->{hidden}) ;
261                 $row_data{isurl} = CGI::checkbox( -name => "isurl$i",
262                         -id => "isurl$i",
263                         -checked => $data->{'isurl'}?'checked':'',
264                         -value => 1,
265                         -label => '');
266                 $row_data{row} = $i;
267                 $row_data{toggle} = $toggle;
268                 push(@loop_data, \%row_data);
269                 $i++;
270         }
271         # add more_subfields empty lines for add if needed
272         for (my $i=1;$i<=$more_subfields;$i++) {
273                 my %row_data;  # get a fresh hash for the row data
274         $row_data{'new_subfield'} = 1;
275                 $row_data{tab} = CGI::scrolling_list(-name=>'tab',
276                                         -id => "tab$i",
277                                         -values =>
278                                         [ '-1', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ],
279                                         -labels => {
280                                             '-1' => 'ignore',
281                                             '0'  => '0',
282                                             '1'  => '1',
283                                             '2'  => '2',
284                                             '3'  => '3',
285                                             '4'  => '4',
286                                             '5'  => '5',
287                                             '6'  => '6',
288                                             '7'  => '7',
289                                             '8'  => '8',
290                                             '9'  => '9',
291                                         },
292                                         -default=>"",
293                                         -size=>1,
294                                         -tabindex=>'',
295                                         -multiple=>0,
296                                         );
297                 $row_data{ohidden} = CGI::scrolling_list(-name=>'ohidden',
298                                         -id=>"ohidden$i",
299                                         #-values=>['0','1','2'],
300                                         #-labels => {'0'=>'Show','1'=>'Show Collapsed',
301                                         #                               '2' =>'Hide',
302                                         #                               },
303                                         -values=>['0','-5'],
304                                         -labels => {'0'=>'Show All','-5'=>'Hide All',},
305                                         #-default=>"0",
306                                         -default=>$data->{'hidden'},
307                                         #-default=>"-5",
308                                         -size=>1,
309                                         -multiple=>0,
310                                         );
311
312                 #$row_data{ihidden} = CGI::scrolling_list(-name=>'ihidden',
313                 #                       -id=>"ihidden$i",
314                 #                       -values=>['0','1','2'],
315                 #                       -labels => {'0'=>'Show','1'=>'Show Collapsed',
316                 #                                                       '2' =>'Hide',
317                 #                                                       },
318                 #                       -default=>"0",
319                 #                       -size=>1,
320                 #                       -multiple=>0,
321                 #                       );
322                 #$row_data{ehidden} = CGI::scrolling_list(-name=>'ehidden',
323                 #                       -id=>"ehidden$i",
324                 #                       -values=>['0','1','2'],
325                 #                       -labels => {'0'=>'Show','1'=>'Show Collapsed',
326                 #                                                       '2' =>'Hide',
327                 #                                                       },
328                 #                       -default=>"0",
329                 #                       -size=>1,
330                 #                       -multiple=>0,
331                 #                       );
332                 $row_data{tagsubfieldinput} = "<input type=\"text\" name=\"tagsubfield\" value=\"".$data->{'tagsubfield'}."\" size=\"1\" id=\"tagsubfield\" maxlength=\"1\" />";
333                 $row_data{tagsubfieldinput} = 
334                         "<label><input type=\"text\" name=\"tagsubfield\" value=\""
335                         . $data->{'tagsubfield'}
336                         . "\" size=\"1\" id=\"tagsubfield\" maxlength=\"1\" /></label>";
337                 $row_data{tagsubfield} = $data->{'tagsubfield'};
338                 $row_data{liblibrarian} = "";
339                 $row_data{libopac} = "";
340                 $row_data{seealso} = "";
341                 $row_data{hidden} = "000";
342                 $row_data{repeatable} = CGI::checkbox( -name=> 'repeatable',
343                                 -id => "repeatable$i",
344                                 -checked => '',
345                                 -value => 1,
346                                 -label => '');
347                 $row_data{mandatory} = CGI::checkbox( -name=> 'mandatory',
348                         -id => "mandatory$i",
349                         -checked => '',
350                         -value => 1,
351                         -label => '');
352                 $row_data{isurl} = CGI::checkbox(-name => 'isurl',
353                         -id => "isurl$i",
354                         -checked => '',
355                         -value => 1,
356                         -label => '');
357                 $row_data{kohafield}= CGI::scrolling_list( -name=>'kohafield',
358                                         -id => "kohafield$i",
359                                         -values=> \@kohafields,
360                                         -default=> "",
361                                         -size=>1,
362                                         -multiple=>0,
363                                         );
364                 $row_data{frameworkcode}  = CGI::scrolling_list(-name=>'frameworkcode',
365                                         -id=>'frameworkcode',
366                                         -values=> \@authtypes,
367                                         -default=>$data->{'frameworkcode'},
368                                         -size=>1,
369                                         -tabindex=>'',
370                                         -multiple=>0,
371                                         );
372                 $row_data{authorised_value}  = CGI::scrolling_list(-name=>'authorised_value',
373                                         -id => 'authorised_value',
374                                         -values=> \@authorised_values,
375                                         -size=>1,
376                                         -tabindex=>'',
377                                         -multiple=>0,
378                                         );
379                 $row_data{value_builder}  = CGI::scrolling_list(-name=>'value_builder',
380                                         -id=>'value_builder',
381                                         -values=> \@value_builder,
382                                         -default=>$data->{'value_builder'},
383                                         -size=>1,
384                                         -tabindex=>'',
385                                         -multiple=>0,
386                                         );
387                 $row_data{toggle} = $toggle;
388                 $row_data{row} = $i;
389                 push(@loop_data, \%row_data);
390         }
391         $template->param('use-heading-flags-p' => 1);
392         $template->param('heading-edit-subfields-p' => 1);
393         $template->param(action => "Edit subfields",
394                                                         tagfield => $tagfield,
395                                                         tagfieldinput => "<input type=\"hidden\" name=\"tagfield\" value=\"$tagfield\" />",
396                                                         loop => \@loop_data,
397                                                         more_subfields => $more_subfields,
398                                                         more_tag => $tagfield);
399
400                                                                                                 # END $OP eq ADD_FORM
401 ################## ADD_VALIDATE ##################################
402 # called by add_form, used to insert/modify data in DB
403 } elsif ($op eq 'add_validate') {
404         my $dbh = C4::Context->dbh;
405         $template->param(tagfield => "$input->param('tagfield')");
406 #       my $sth=$dbh->prepare("replace auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl)
407 #                                                                       values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
408         my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl)
409                                                                         values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
410         my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?
411                                                                         where authtypecode=? and tagfield=? and tagsubfield=?");
412         my @tagsubfield = $input->param('tagsubfield');
413         my @liblibrarian        = $input->param('liblibrarian');
414         my @libopac             = $input->param('libopac');
415         my @kohafield           = ''.$input->param('kohafield');
416         my @tab                         = $input->param('tab');
417         my @seealso             = $input->param('seealso');
418         my @hidden;
419         my @ohidden             = $input->param('ohidden');
420         #my @ihidden            = $input->param('ihidden');
421         #my @ehidden            = $input->param('ehidden');
422         my @authorised_values   = $input->param('authorised_value');
423         my $authtypecode        = $input->param('authtypecode');
424         my @frameworkcodes      = $input->param('frameworkcode');
425         my @value_builder       =$input->param('value_builder');
426         for (my $i=0; $i<= $#tagsubfield ; $i++) {
427                 my $tagfield                    =$input->param('tagfield');
428                 my $tagsubfield         =$tagsubfield[$i];
429                 $tagsubfield="@" unless $tagsubfield ne '';
430                 my $liblibrarian                =$liblibrarian[$i];
431                 my $libopac                     =$libopac[$i];
432                 my $repeatable          =$input->param("repeatable$i")?1:0;
433                 my $mandatory           =$input->param("mandatory$i")?1:0;
434                 my $kohafield           =$kohafield[$i];
435                 my $tab                         =$tab[$i];
436                 my $seealso                             =$seealso[$i];
437                 my $authorised_value            =$authorised_values[$i];
438                 my $frameworkcode               =$frameworkcodes[$i];
439                 my $value_builder=$value_builder[$i];
440                 #my $hidden = $ohidden[$i].$ihidden[$i].$ehidden[$i]; #collate from 3 hiddens;
441                 my $hidden = $ohidden[$i]; #collate from 3 hiddens;
442                 my $isurl = $input->param("isurl$i")?1:0;
443                 if ($liblibrarian) {
444                         unless (C4::Context->config('demo') eq 1) {
445                                 if (auth_subfield_structure_exists($authtypecode, $tagfield, $tagsubfield)) {
446                                         $sth_update->execute(
447                                                 $authtypecode,
448                                                 $tagfield,
449                                                 $tagsubfield,
450                                                 $liblibrarian,
451                                                 $libopac,
452                                                 $repeatable,
453                                                 $mandatory,
454                                                 $kohafield,
455                                                 $tab,
456                                                 $seealso,
457                                                 $authorised_value,
458                                                 $frameworkcode,
459                                                 $value_builder,
460                                                 $hidden,
461                                                 $isurl,
462                                                 (
463                                                         $authtypecode,
464                                                         $tagfield,
465                                                         $tagsubfield
466                                                 ),
467                                         );
468                                 } else {
469                                         $sth_insert->execute(
470                                                 $authtypecode,
471                                                 $tagfield,
472                                                 $tagsubfield,
473                                                 $liblibrarian,
474                                                 $libopac,
475                                                 $repeatable,
476                                                 $mandatory,
477                                                 $kohafield,
478                                                 $tab,
479                                                 $seealso,
480                                                 $authorised_value,
481                                                 $frameworkcode,
482                                                 $value_builder,
483                                                 $hidden,
484                                                 $isurl,
485                                         );
486                                 }
487                         }
488                 }
489         }
490         $sth_insert->finish;
491         $sth_update->finish;
492         print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode\"></html>";
493         exit;
494
495                                                                                                         # END $OP eq ADD_VALIDATE
496 ################## DELETE_CONFIRM ##################################
497 # called by default form, used to confirm deletion of data in DB
498 } elsif ($op eq 'delete_confirm') {
499         my $dbh = C4::Context->dbh;
500         my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?");
501         $sth->execute($tagfield,$tagsubfield,$authtypecode);
502         my $data=$sth->fetchrow_hashref;
503         $sth->finish;
504         $template->param(liblibrarian => $data->{'liblibrarian'},
505                                                         tagsubfield => $data->{'tagsubfield'},
506                                                         delete_link => $script_name,
507                                                         tagfield      =>$tagfield,
508                                                         tagsubfield => $tagsubfield,
509                                                         authtypecode => $authtypecode,
510                                                         );
511                                                                                                         # END $OP eq DELETE_CONFIRM
512 ################## DELETE_CONFIRMED ##################################
513 # called by delete_confirm, used to effectively confirm deletion of data in DB
514 } elsif ($op eq 'delete_confirmed') {
515         my $dbh = C4::Context->dbh;
516         unless (C4::Context->config('demo') eq 1) {
517                 my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?");
518                 $sth->execute($tagfield,$tagsubfield,$authtypecode);
519                 $sth->finish;
520         }
521         print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode\"></html>";
522         exit;
523         $template->param(tagfield => $tagfield);
524                                                                                                         # END $OP eq DELETE_CONFIRMED
525 ################## DEFAULT ##################################
526 } else { # DEFAULT
527         my ($count,$results)=string_search($tagfield,$authtypecode);
528         my $toggle=1;
529         my @loop_data = ();
530         for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
531                 if ($toggle eq 1){
532                         $toggle=0;
533                 } else {
534                         $toggle=1;
535                 }
536                 my %row_data;  # get a fresh hash for the row data
537                 $row_data{tagfield} = $results->[$i]{'tagfield'};
538                 $row_data{tagsubfield} = $results->[$i]{'tagsubfield'};
539                 $row_data{liblibrarian} = $results->[$i]{'liblibrarian'};
540                 $row_data{kohafield} = $results->[$i]{'kohafield'};
541                 $row_data{repeatable} = $results->[$i]{'repeatable'};
542                 $row_data{mandatory} = $results->[$i]{'mandatory'};
543                 $row_data{tab} = $results->[$i]{'tab'};
544                 $row_data{seealso} = $results->[$i]{'seealso'};
545                 $row_data{authorised_value} = $results->[$i]{'authorised_value'};
546                 $row_data{authtypecode} = $results->[$i]{'authtypecode'};
547                 $row_data{value_builder}        = $results->[$i]{'value_builder'};
548                 $row_data{hidden}       = $results->[$i]{'hidden'} if($results->[$i]{'hidden'} gt "000") ;
549                 $row_data{isurl}        = $results->[$i]{'isurl'};
550                 $row_data{delete} = "$script_name?op=delete_confirm&amp;tagfield=$tagfield&amp;tagsubfield=".$results->[$i]{'tagsubfield'}."&amp;authtypecode=$authtypecode";
551                 $row_data{toggle} = $toggle;
552                 if ($row_data{tab} eq -1) {
553                         $row_data{subfield_ignored} = 1;
554                 }
555
556                 push(@loop_data, \%row_data);
557         }
558         $template->param(loop => \@loop_data);
559         $template->param(edit_tagfield => $tagfield,
560                 edit_authtypecode => $authtypecode);
561         
562         if ($offset>0) {
563                 my $prevpage = $offset-$pagesize;
564                 $template->param(prev =>"<a href=\"$script_name?offset=$prevpage\">");
565         }
566         if ($offset+$pagesize<$count) {
567                 my $nextpage =$offset+$pagesize;
568                 $template->param(next => "<a href=\"$script_name?offset=$nextpage\">");
569         }
570 } #---- END $OP eq DEFAULT
571 output_html_with_http_headers $input, $cookie, $template->output;