bug 1570: return to same tab if cancelling preference edit
[koha.git] / admin / systempreferences.pl
1 #!/usr/bin/perl
2
3 #script to administer the systempref table
4 #written 20/02/2002 by paul.poulain@free.fr
5 # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 =head1 systempreferences.pl
25
26 ALGO :
27  this script use an $op to know what to do.
28  if $op is empty or none of the above values,
29     - the default screen is build (with all records, or filtered datas).
30     - the   user can clic on add, modify or delete record.
31  if $op=add_form
32     - if primkey exists, this is a modification,so we read the $primkey record
33     - builds the add/modify form
34  if $op=add_validate
35     - the user has just send datas, so we create/modify the record
36  if $op=delete_form
37     - we show the record having primkey=$primkey and ask for deletion validation form
38  if $op=delete_confirm
39     - we delete the record having primkey=$primkey
40
41 =cut
42
43 use strict;
44 use CGI;
45 use C4::Auth;
46 use C4::Context;
47 use C4::Koha;
48 use C4::Languages;
49 use C4::ClassSource;
50 use C4::Output;
51 use C4::Context;
52
53 # use Smart::Comments;
54
55
56 # FIXME, shouldnt we store this stuff in the systempreferences table? 
57
58 my %tabsysprefs;
59 # Acquisitions
60     $tabsysprefs{acquisitions}="Acquisitions";
61     $tabsysprefs{gist}="Acquisitions";
62 # Admin
63     $tabsysprefs{dateformat}="Admin";
64     $tabsysprefs{delimiter}="Admin";
65     $tabsysprefs{IndependantBranches}="Admin";
66     $tabsysprefs{HomeOrHoldingBranch}="Admin";
67     $tabsysprefs{insecure}="Admin";
68     $tabsysprefs{KohaAdmin}="Admin";
69     $tabsysprefs{KohaAdminEmailAddress}="Admin";
70     $tabsysprefs{MIME}="Admin";
71     $tabsysprefs{timeout}="Admin";
72     $tabsysprefs{Intranet_includes}="Admin";
73     $tabsysprefs{AutoLocation}="Admin";
74     $tabsysprefs{DebugLevel}="Admin";
75     $tabsysprefs{SessionStorage}="Admin";
76
77 # Authorities
78     $tabsysprefs{authoritysep}="Authorities";
79     $tabsysprefs{AuthDisplayHierarchy}="Authorities";
80     $tabsysprefs{dontmerge}="Authorities";
81     $tabsysprefs{BiblioAddsAuthorities}="Authorities";
82 # Catalogue
83     $tabsysprefs{advancedMARCEditor}="Catalogue";
84     $tabsysprefs{autoBarcode}="Catalogue";
85     $tabsysprefs{hide_marc}="Catalogue";
86     $tabsysprefs{IntranetBiblioDefaultView} = "Catalogue";
87     $tabsysprefs{ISBD}="Catalogue";
88     $tabsysprefs{itemcallnumber}="Catalogue";
89     $tabsysprefs{LabelMARCView}="Catalogue";
90     $tabsysprefs{marc}="Catalogue";
91     $tabsysprefs{marcflavour}="Catalogue";
92     $tabsysprefs{serialsadditems}="Catalogue";
93     $tabsysprefs{sortbynonfiling}="Catalogue";
94     $tabsysprefs{MARCOrgCode}="Catalogue";
95     $tabsysprefs{z3950AuthorAuthFields}="Catalogue";
96     $tabsysprefs{z3950NormalizeAuthor}="Catalogue";
97     $tabsysprefs{Stemming}="Catalogue";
98     $tabsysprefs{WeightFields}="Catalogue";
99     $tabsysprefs{expandedSearchOption}="Catalogue";
100     $tabsysprefs{NoZebra}="Catalogue";
101     $tabsysprefs{NoZebraIndexes}="Catalogue";
102     $tabsysprefs{ReceiveBackIssues}="Catalogue";
103     $tabsysprefs{DefaultClassificationSource}="Catalogue";
104     $tabsysprefs{RoutingSerials}="Catalogue";
105     $tabsysprefs{'item-level_itypes'}="Catalogue";
106
107 # Circulation
108     $tabsysprefs{maxoutstanding}="Circulation";
109     $tabsysprefs{maxreserves}="Circulation";
110     $tabsysprefs{noissuescharge}="Circulation";
111     $tabsysprefs{IssuingInProcess}="Circulation";
112     $tabsysprefs{patronimages}="Circulation";
113     $tabsysprefs{printcirculationslips}="Circulation";
114     $tabsysprefs{ReturnBeforeExpiry}="Circulation";
115     $tabsysprefs{SpecifyDueDate}="Circulation";
116     $tabsysprefs{AutomaticItemReturn}="Circulation";
117     $tabsysprefs{ReservesMaxPickUpDelay}="Circulation";
118     $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
119     $tabsysprefs{useDaysMode}="Circulation";
120     $tabsysprefs{ReservesNeedReturns}="Circulation";
121     $tabsysprefs{CircAutocompl}="Circulation";
122     $tabsysprefs{canreservefromotherbranches}="Circulation";
123
124 # Intranet
125     $tabsysprefs{TemplateEncoding}="Intranet";
126     $tabsysprefs{template}="Intranet";
127     $tabsysprefs{intranetstylesheet}="Intranet";
128     $tabsysprefs{IntranetNav}="Intranet";
129     $tabsysprefs{intranetcolorstylesheet}="Intranet";
130     $tabsysprefs{intranetuserjs}="Intranet";
131         $tabsysprefs{yuipath}="Intranet";
132         $tabsysprefs{IntranetmainUserblock}="Intranet";
133         
134 # Members
135     $tabsysprefs{automembernum}="Members";
136     $tabsysprefs{checkdigit}="Members";
137     $tabsysprefs{intranetreadinghistory}="Members";
138     $tabsysprefs{NotifyBorrowerDeparture}="Members";
139     $tabsysprefs{memberofinstitution}="Members";
140     $tabsysprefs{ReadingHistory}="Members";
141     $tabsysprefs{BorrowerMandatoryField}="Members";
142     $tabsysprefs{borrowerRelationship}="Members";
143     $tabsysprefs{BorrowersTitles}="Members";    
144     $tabsysprefs{patronimages}="Members";
145     $tabsysprefs{MinPasswordLength}="Members";
146     $tabsysprefs{uppercasesurnames}="Members";
147     $tabsysprefs{NoReturnSetLost}="Members";
148     $tabsysprefs{MaxFine}="Members";
149     $tabsysprefs{NotifyBorrowerDeparture}="Members";
150 # FRBA
151         $tabsysprefs{FRBRizeEditions}="FRBR";
152         $tabsysprefs{XISBN}="FRBR";
153         $tabsysprefs{OCLCAffiliateID}="FRBR";
154         $tabsysprefs{XISBNDailyLimit}="FRBR";
155         $tabsysprefs{PINESISBN}="FRBR";
156     $tabsysprefs{ThingISBN}="FRBR";
157     $tabsysprefs{OPACFRBRizeEditions}="FRBR";
158     $tabsysprefs{XISBNAmazonSimilarItems}="FRBR";
159
160 # OPAC
161     $tabsysprefs{AmazonAssocTag}="OPAC";
162     $tabsysprefs{AmazonSimilarItems}="OPAC";
163     $tabsysprefs{AmazonContent}="OPAC";
164     $tabsysprefs{OPACAmazonContent}="OPAC";
165     $tabsysprefs{AmazonDevKey}="OPAC";
166     $tabsysprefs{BiblioDefaultView}="OPAC";
167     $tabsysprefs{LibraryName}="OPAC";
168     $tabsysprefs{opaccolorstylesheet}="OPAC";
169     $tabsysprefs{opaccredits}="OPAC";
170     $tabsysprefs{opaclanguages}="OPAC";
171     $tabsysprefs{opaclargeimage}="OPAC";
172     $tabsysprefs{opaclayoutstylesheet}="OPAC";
173     $tabsysprefs{OpacNav}="OPAC";
174     $tabsysprefs{opacsmallimage}="OPAC";
175     $tabsysprefs{opacstylesheet}="OPAC";
176     $tabsysprefs{opacthemes}="OPAC";
177     $tabsysprefs{opacuserjs}="OPAC";
178     $tabsysprefs{SubscriptionHistory}="OPAC";
179     $tabsysprefs{opacheader}="OPAC";
180     $tabsysprefs{OPACAmazonSimilarItems}="OPAC";
181     $tabsysprefs{OPACXISBNAmazonSimilarItems}="OPAC";
182     
183 # OPACFeatures
184         $tabsysprefs{SearchMyLibraryFirst}="OPACFeatures";
185     $tabsysprefs{Disable_Dictionary}="OPACFeatures";
186     $tabsysprefs{hidelostitems}="OPACFeatures";
187     $tabsysprefs{opacbookbag}="OPACFeatures";
188     $tabsysprefs{opaclanguagesdisplay}="OPACFeatures";
189     $tabsysprefs{OpacPasswordChange}="OPACFeatures";
190     $tabsysprefs{opacreadinghistory}="OPACFeatures";
191     $tabsysprefs{virtualshelves}="OPACFeatures";
192     $tabsysprefs{RequestOnOpac}="OPACFeatures";
193     $tabsysprefs{reviewson}="OPACFeatures";
194     $tabsysprefs{OpacTopissues}="OPACFeatures";
195     $tabsysprefs{OpacAuthorities}="OPACFeatures";
196     $tabsysprefs{OpacCloud}="OPACFeatures";
197     $tabsysprefs{opacuserlogin}="OPACFeatures";
198     $tabsysprefs{AnonSuggestions}="OPACFeatures";
199     $tabsysprefs{suggestion}="OPACFeatures";
200     $tabsysprefs{OpacTopissue}="OPACFeatures";
201     $tabsysprefs{OpacBrowser}="OPACFeatures";
202     $tabsysprefs{kohaspsuggest} = "OPACFeatures";
203
204 # LOGFeatures
205     $tabsysprefs{CataloguingLog}  = "LOGFeatures";
206     $tabsysprefs{BorrowersLog}    = "LOGFeatures";
207     $tabsysprefs{SubscriptionLog} = "LOGFeatures";
208     $tabsysprefs{IssueLog}        = "LOGFeatures";
209     $tabsysprefs{ReturnLog}       = "LOGFeatures";
210     $tabsysprefs{LetterLog}       = "LOGFeatures";
211     $tabsysprefs{FinesLog}        = "LOGFeatures";
212     
213 sub StringSearch  {
214     my ($searchstring,$type)=@_;
215     my $dbh = C4::Context->dbh;
216     $searchstring=~ s/\'/\\\'/g;
217     my @data=split(' ',$searchstring);
218     my $count=@data;
219     my @results;
220     my $cnt=0;
221
222     # used for doing a plain-old sys-pref search
223     if ($type eq 'all' ){
224         my $sth=$dbh->prepare("SELECT * FROM systempreferences 
225                 WHERE variable LIKE ? OR explanation LIKE ? 
226                 ORDER BY VARIABLE");
227         $sth->execute("%$searchstring%", "%$searchstring%");
228         while (my $data=$sth->fetchrow_hashref){
229             $data->{value} =~ s/</&lt;/g;
230             $data->{value} =~ s/>/&gt;/g;
231             $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
232             push(@results,$data);
233             $cnt++;
234         }
235         $sth->finish;
236
237     }  elsif ($type){
238         foreach my $syspref (sort keys %tabsysprefs){
239             if ($tabsysprefs{$syspref} eq $type){
240                 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
241                 $sth->execute($syspref);
242                 while (my $data=$sth->fetchrow_hashref){
243                     $data->{value} =~ s/</&lt;/g;
244                     $data->{value} =~ s/>/&gt;/g;
245                     $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
246                     push(@results,$data);
247                     $cnt++;
248                 }
249                 $sth->finish;
250             }
251         }
252     } else {
253         my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
254         foreach my $syspref (keys %tabsysprefs){
255             $strsth .= $dbh->quote($syspref).",";
256         }
257         $strsth =~ s/,$/) /;
258         $strsth .= " order by variable";
259         my $sth=$dbh->prepare($strsth);
260         $sth->execute();
261         while (my $data=$sth->fetchrow_hashref){
262             $data->{value}=substr($data->{value},0,100);
263             push(@results,$data);
264             $cnt++;
265         }
266         $sth->finish;
267     }
268     return ($cnt,\@results);
269 }
270
271 my $input = new CGI;
272 my $searchfield=$input->param('searchfield');
273 my $offset=$input->param('offset');
274 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
275
276 my ($template, $borrowernumber, $cookie)
277     = get_template_and_user({template_name => "admin/systempreferences.tmpl",
278                  query => $input,
279                  type => "intranet",
280                  authnotrequired => 0,
281                  flagsrequired => {parameters => 1},
282                  debug => 1,
283                  });
284 my $pagesize=100;
285 my $op = $input->param('op');
286 $searchfield=~ s/\,//g;
287
288 if ($op) {
289 $template->param(script_name => $script_name,
290                         $op              => 1); # we show only the TMPL_VAR names $op
291 } else {
292 $template->param(script_name => $script_name,
293                         else              => 1); # we show only the TMPL_VAR names $op
294 }
295
296 if ($op eq 'update_and_reedit') {
297     foreach ($input->param) {
298     }
299     my $value='';
300     if (my $currentorder=$input->param('currentorder')) {
301         my @currentorder=split /\|/, $currentorder;
302         my $orderchanged=0;
303         foreach my $param ($input->param) {
304             if ($param=~m#up-(\d+).x#) {
305                 my $temp=$currentorder[$1];
306                 $currentorder[$1]=$currentorder[$1-1];
307                 $currentorder[$1-1]=$temp;
308                 $orderchanged=1;
309                 last;
310             } elsif ($param=~m#down-(\d+).x#) {
311                 my $temp=$currentorder[$1];
312                 $currentorder[$1]=$currentorder[$1+1];
313                 $currentorder[$1+1]=$temp;
314                 $orderchanged=1;
315                 last;
316             }
317         }
318         $value=join ' ', @currentorder;
319         if ($orderchanged) {
320             $op='add_form';
321             $template->param(script_name => $script_name,
322                             $op              => 1); # we show only the TMPL_VAR names $op
323         } else {
324             $op='';
325             $searchfield='';
326             $template->param(script_name => $script_name,
327                             else              => 1); # we show only the TMPL_VAR names $op
328         }
329     }
330     my $dbh = C4::Context->dbh;
331     my $query="select * from systempreferences where variable=?";
332     my $sth=$dbh->prepare($query);
333     $sth->execute($input->param('variable'));
334     if ($sth->rows) {
335         unless (C4::Context->config('demo') eq 1) {
336             my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
337             $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
338             $sth->finish;
339         }
340     } else {
341         unless (C4::Context->config('demo') eq 1) {
342             my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
343             $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
344             $sth->finish;
345         }
346     }
347     $sth->finish;
348
349 }
350
351 ################## ADD_FORM ##################################
352 # called by default. Used to create form to add or  modify a record
353
354 if ($op eq 'add_form') {
355     #---- if primkey exists, it's a modify action, so read values to modify...
356     my $data;
357     if ($searchfield) {
358         my $dbh = C4::Context->dbh;
359         my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
360         $sth->execute($searchfield);
361         $data=$sth->fetchrow_hashref;
362         $sth->finish;
363         $template->param(modify => 1);
364         # save tab to return to if user cancels edit
365         $template->param(return_tab => $tabsysprefs{$searchfield});
366     }
367
368     my @options;
369     foreach my $option (split(/\|/, $data->{'options'})) {
370         my $selected='0';
371         $option eq $data->{'value'} and $selected=1;
372         push @options, { option => $option, selected => $selected };
373     }
374     if ($data->{'type'} eq 'Choice') {
375         $template->param('type-choice' => 1);
376     } elsif ($data->{'type'} eq 'YesNo') {
377         $template->param('type-yesno' => 1);
378         $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
379         ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
380     } elsif ($data->{'type'} eq 'Integer') {
381         $template->param('type-free' => 1);
382         $template->param('fieldlength' => $data->{'options'});
383     } elsif ($data->{'type'} eq 'Textarea') {
384         $template->param('type-textarea' => 1);
385         $data->{options} =~ /(.*)\|(.*)/;
386         $template->param('cols' => $1, 'rows' => $2);;
387     } elsif ($data->{'type'} eq 'Float') {
388         $template->param('type-free' => 1);
389         $template->param('fieldlength' => $data->{'options'});
390     } elsif ($data->{'type'} eq 'Themes') {
391         $template->param('type-choice' => 1);
392         my $type='';
393         ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
394         @options=();
395         my $currently_selected_themes;
396         my $counter=0;
397         foreach my $theme (split /\s+/, $data->{'value'}) {
398             push @options, { option => $theme, counter => $counter };
399             $currently_selected_themes->{$theme}=1;
400             $counter++;
401         }
402         foreach my $theme (getallthemes($type)) {
403             my $selected='0';
404             next if $currently_selected_themes->{$theme};
405             push @options, { option => $theme, counter => $counter };
406             $counter++;
407         }
408     } elsif ($data->{'type'} eq 'ClassSources') {
409         $template->param('type-choice' => 1);
410         my $type='';
411         @options=();
412         my $sources = GetClassSources();
413         my $counter=0;
414         foreach my $cn_source (sort keys %$sources) {
415             if ($cn_source eq $data->{'value'}) {
416                 push @options, { option => $cn_source, counter => $counter, selected => 1 };
417             } else {
418                 push @options, { option => $cn_source, counter => $counter };
419             }
420             $counter++; 
421         }
422     } elsif ($data->{'type'} eq 'Languages') {
423         $template->param('type-choice' => 1);
424         my $type='';
425         @options=();
426         my $currently_selected_languages;
427         my $counter=0;
428         foreach my $language (split /\s+/, $data->{'value'}) {
429             next if $language eq 'images';
430             push @options, { option => $language, counter => $counter };
431             $currently_selected_languages->{$language}=1;
432             $counter++;
433         }
434                 my $langavail = getTranslatedLanguages();
435         foreach my $language (@$langavail) {
436             my $selected='0';
437             next if $currently_selected_languages->{$language->{'language_code'}};
438                         #FIXME: could add language_name and language_locale_name for better display
439             push @options, { option => $language->{'language_code'}, counter => $counter };
440             $counter++;
441         }
442     } else {
443         $template->param('type-free' => 1);
444         $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
445     }
446     $template->param(explanation => $data->{'explanation'},
447              value => $data->{'value'},
448              type => $data->{'type'},
449              options => \@options,
450              preftype => $data->{'type'},
451              prefoptions => $data->{'options'},
452              searchfield => $searchfield);
453
454 ################## ADD_VALIDATE ##################################
455 # called by add_form, used to insert/modify data in DB
456 } elsif ($op eq 'add_validate') {
457     my $dbh = C4::Context->dbh;
458     my $sth=$dbh->prepare("select * from systempreferences where variable=?");
459     $sth->execute($input->param('variable'));
460     if ($sth->rows) {
461         unless (C4::Context->config('demo') eq 1) {
462             my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
463             $sth->execute($input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
464             $sth->finish;
465         }
466     } else {
467         unless (C4::Context->config('demo') eq 1) {
468             my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
469             $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
470             $sth->finish;
471         }
472     }
473     $sth->finish;
474     print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
475     exit;
476 ################## DELETE_CONFIRM ##################################
477 # called by default form, used to confirm deletion of data in DB
478 } elsif ($op eq 'delete_confirm') {
479     my $dbh = C4::Context->dbh;
480     my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
481     $sth->execute($searchfield);
482     my $data=$sth->fetchrow_hashref;
483     $sth->finish;
484     $template->param(searchfield => $searchfield,
485                             Tvalue => $data->{'value'},
486                             );
487
488                                                     # END $OP eq DELETE_CONFIRM
489 ################## DELETE_CONFIRMED ##################################
490 # called by delete_confirm, used to effectively confirm deletion of data in DB
491 } elsif ($op eq 'delete_confirmed') {
492     my $dbh = C4::Context->dbh;
493     my $sth=$dbh->prepare("delete from systempreferences where variable=?");
494     $sth->execute($searchfield);
495     $sth->finish;
496
497                                                     # END $OP eq DELETE_CONFIRMED
498 ################## DEFAULT ##################################
499 } else { # DEFAULT
500     #Adding tab management for system preferences
501     my $tab=$input->param('tab');
502     my ($count,$results)=StringSearch($searchfield,$tab);
503     my $toggle=0;
504     my @loop_data = ();
505     for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
506           if ($toggle eq 0){
507             $toggle=1;
508           } else {
509             $toggle=0;
510           }
511         my %row_data;  # get a fresh hash for the row data
512         $row_data{variable} = $results->[$i]{'variable'};
513         $row_data{value} = $results->[$i]{'value'};
514                 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
515                 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
516         $row_data{explanation} = $results->[$i]{'explanation'};
517         $row_data{toggle} = $toggle;
518         $row_data{edit} = "$script_name?op=add_form&amp;searchfield=".$results->[$i]{'variable'};
519         $row_data{delete} = "$script_name?op=delete_confirm&amp;searchfield=".$results->[$i]{'variable'};
520         push(@loop_data, \%row_data);
521     }
522     $tab=($tab?$tab:"Others");
523     $template->param(loop => \@loop_data, $tab => 1);
524     if ($offset>0) {
525         my $prevpage = $offset-$pagesize;
526         $template->param("<a href=$script_name?offset=".$prevpage.'&lt;&lt; Prev</a>');
527     }
528     if ($offset+$pagesize<$count) {
529         my $nextpage =$offset+$pagesize;
530         $template->param("a href=$script_name?offset=".$nextpage.'Next &gt;&gt;</a>');
531     }
532     $template->param(        tab => $tab,
533             );
534 } #---- END $OP eq DEFAULT
535 output_html_with_http_headers $input, $cookie, $template->output;