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)
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
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
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.
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
24 =head1 systempreferences.pl
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.
32 - if primkey exists, this is a modification,so we read the $primkey record
33 - builds the add/modify form
35 - the user has just send datas, so we create/modify the record
37 - we show the record having primkey=$primkey and ask for deletion validation form
39 - we delete the record having primkey=$primkey
48 use C4::Languages qw(getTranslatedLanguages);
54 # use Smart::Comments;
57 # FIXME, shouldnt we store this stuff in the systempreferences table?
61 $tabsysprefs{acquisitions}="Acquisitions";
62 $tabsysprefs{gist}="Acquisitions";
63 $tabsysprefs{emailPurchaseSuggestions}="Acquisitions";
66 $tabsysprefs{singleBranchMode}="Admin";
67 $tabsysprefs{staffClientBaseURL}="Admin";
68 $tabsysprefs{Version}="Admin";
69 $tabsysprefs{OpacMaintenance}="Admin";
70 $tabsysprefs{FrameworksLoaded}="Admin";
71 $tabsysprefs{libraryAddress}="Admin";
72 $tabsysprefs{delimiter}="Admin";
73 $tabsysprefs{IndependantBranches}="Admin";
74 $tabsysprefs{insecure}="Admin";
75 $tabsysprefs{KohaAdmin}="Admin";
76 $tabsysprefs{KohaAdminEmailAddress}="Admin";
77 $tabsysprefs{MIME}="Admin";
78 $tabsysprefs{timeout}="Admin";
79 $tabsysprefs{Intranet_includes}="Admin";
80 $tabsysprefs{AutoLocation}="Admin";
81 $tabsysprefs{DebugLevel}="Admin";
82 $tabsysprefs{SessionStorage}="Admin";
83 $tabsysprefs{noItemTypeImages}="Admin";
84 $tabsysprefs{OPACBaseURL}="Admin";
85 $tabsysprefs{CheckSpecificUserPermissions}="Admin";
88 $tabsysprefs{authoritysep}="Authorities";
89 $tabsysprefs{AuthDisplayHierarchy}="Authorities";
90 $tabsysprefs{dontmerge}="Authorities";
91 $tabsysprefs{BiblioAddsAuthorities}="Authorities";
93 $tabsysprefs{advancedMARCEditor}="Cataloguing";
94 $tabsysprefs{autoBarcode}="Cataloguing";
95 $tabsysprefs{hide_marc}="Cataloguing";
96 $tabsysprefs{IntranetBiblioDefaultView} = "Cataloguing";
97 $tabsysprefs{ISBD}="Cataloguing";
98 $tabsysprefs{itemcallnumber}="Cataloguing";
99 $tabsysprefs{LabelMARCView}="Cataloguing";
100 $tabsysprefs{marc}="Cataloguing";
101 $tabsysprefs{marcflavour}="Cataloguing";
102 $tabsysprefs{serialsadditems}="Cataloguing";
103 $tabsysprefs{MARCOrgCode}="Cataloguing";
104 $tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
105 $tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
106 $tabsysprefs{Stemming}="Cataloguing";
107 $tabsysprefs{WeightFields}="Cataloguing";
108 $tabsysprefs{NoZebra}="Cataloguing";
109 $tabsysprefs{NoZebraIndexes}="Cataloguing";
110 $tabsysprefs{ReceiveBackIssues}="Cataloguing";
111 $tabsysprefs{DefaultClassificationSource}="Cataloguing";
112 $tabsysprefs{RoutingSerials}="Cataloguing";
113 $tabsysprefs{'item-level_itypes'}="Cataloguing";
116 $tabsysprefs{maxoutstanding}="Circulation";
117 $tabsysprefs{maxreserves}="Circulation";
118 $tabsysprefs{noissuescharge}="Circulation";
119 $tabsysprefs{IssuingInProcess}="Circulation";
120 $tabsysprefs{patronimages}="Circulation";
121 $tabsysprefs{printcirculationslips}="Circulation";
122 $tabsysprefs{ReturnBeforeExpiry}="Circulation";
123 $tabsysprefs{SpecifyDueDate}="Circulation";
124 $tabsysprefs{AutomaticItemReturn}="Circulation";
125 $tabsysprefs{ReservesMaxPickUpDelay}="Circulation";
126 $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
127 $tabsysprefs{useDaysMode}="Circulation";
128 $tabsysprefs{ReservesNeedReturns}="Circulation";
129 $tabsysprefs{CircAutocompl}="Circulation";
130 $tabsysprefs{canreservefromotherbranches}="Circulation";
131 $tabsysprefs{finesMode}="Circulation";
132 $tabsysprefs{emailLibrarianWhenHoldIsPlaced}="Circulation";
133 $tabsysprefs{globalDueDate}="Circulation";
134 $tabsysprefs{holdCancelLength}="Circulation";
135 $tabsysprefs{itemBarcodeInputFilter}="Circulation";
136 $tabsysprefs{noOPACHolds}="Circulation";
137 $tabsysprefs{WebBasedSelfCheck}="Circulation";
138 $tabsysprefs{CircControl}="Circulation";
139 $tabsysprefs{finesCalendar}="Circulation";
140 $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
141 $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
142 $tabsysprefs{HomeOrHoldingBranch}="Circulation";
145 $tabsysprefs{TemplateEncoding}="StaffClient";
146 $tabsysprefs{template}="StaffClient";
147 $tabsysprefs{intranetstylesheet}="StaffClient";
148 $tabsysprefs{IntranetNav}="StaffClient";
149 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
150 $tabsysprefs{intranetuserjs}="StaffClient";
151 $tabsysprefs{yuipath}="StaffClient";
152 $tabsysprefs{IntranetmainUserblock}="StaffClient";
155 $tabsysprefs{autoMemberNum}="Patrons";
156 $tabsysprefs{checkdigit}="Patrons";
157 $tabsysprefs{intranetreadinghistory}="Patrons";
158 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
159 $tabsysprefs{memberofinstitution}="Patrons";
160 $tabsysprefs{ReadingHistory}="Patrons";
161 $tabsysprefs{BorrowerMandatoryField}="Patrons";
162 $tabsysprefs{borrowerRelationship}="Patrons";
163 $tabsysprefs{BorrowersTitles}="Patrons";
164 $tabsysprefs{patronimages}="Patrons";
165 $tabsysprefs{MinPasswordLength}="Patrons";
166 $tabsysprefs{uppercasesurnames}="Patrons";
167 $tabsysprefs{NoReturnSetLost}="Patrons";
168 $tabsysprefs{MaxFine}="Patrons";
169 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
170 $tabsysprefs{PatronsPerPage}="Patrons";
173 $tabsysprefs{FRBRizeEditions}="FRBR";
174 $tabsysprefs{XISBN}="FRBR";
175 $tabsysprefs{OCLCAffiliateID}="FRBR";
176 $tabsysprefs{XISBNDailyLimit}="FRBR";
177 $tabsysprefs{PINESISBN}="FRBR";
178 $tabsysprefs{ThingISBN}="FRBR";
179 $tabsysprefs{OPACFRBRizeEditions}="FRBR";
182 $tabsysprefs{dateformat}="I18N/L10N";
183 $tabsysprefs{opaclanguages}="I18N/L10N";
184 $tabsysprefs{opacthemes}="I18N/L10N";
185 $tabsysprefs{language}="I18N/L10N";
188 $tabsysprefs{defaultSortField}="Searching";
189 $tabsysprefs{defaultSortOrder}="Searching";
190 $tabsysprefs{maxItemsInSearchResults}="Searching";
191 $tabsysprefs{numSearchResults}="Searching";
192 $tabsysprefs{OPACdefaultSortField}="Searching";
193 $tabsysprefs{OPACdefaultSortOrder}="Searching";
194 $tabsysprefs{OPACItemsResultsDisplay}="Searching";
195 $tabsysprefs{OPACnumSearchResults}="Searching";
196 $tabsysprefs{QueryFuzzy}="Searching";
197 $tabsysprefs{QueryStemming}="Searching";
198 $tabsysprefs{QueryWeightFields}="Searching";
199 $tabsysprefs{expandedSearchOption}="Searching";
200 $tabsysprefs{sortbynonfiling}="Searching";
201 $tabsysprefs{QueryAutoTruncate}="Searching";
202 $tabsysprefs{QueryRemoveStopwords}="Searching";
205 $tabsysprefs{AmazonContent}="Amazon";
206 $tabsysprefs{AWSAccessKeyID}="Amazon";
207 $tabsysprefs{AmazonLocale}="Amazon";
208 $tabsysprefs{AmazonAssocTag}="Amazon";
209 $tabsysprefs{AmazonSimilarItems}="Amazon";
210 $tabsysprefs{OPACAmazonContent}="Amazon";
211 $tabsysprefs{OPACAmazonSimilarItems}="Amazon";
214 $tabsysprefs{BiblioDefaultView}="OPAC";
215 $tabsysprefs{LibraryName}="OPAC";
216 $tabsysprefs{opaccolorstylesheet}="OPAC";
217 $tabsysprefs{opaccredits}="OPAC";
218 $tabsysprefs{opaclargeimage}="OPAC";
219 $tabsysprefs{opaclayoutstylesheet}="OPAC";
220 $tabsysprefs{OpacNav}="OPAC";
221 $tabsysprefs{opacsmallimage}="OPAC";
222 $tabsysprefs{opacstylesheet}="OPAC";
223 $tabsysprefs{opacthemes}="OPAC";
224 $tabsysprefs{opacuserjs}="OPAC";
225 $tabsysprefs{SubscriptionHistory}="OPAC";
226 $tabsysprefs{opacheader}="OPAC";
228 $tabsysprefs{hideBiblioNumber}="OPAC";
229 $tabsysprefs{noOPACUserLogin}="OPAC";
230 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
231 $tabsysprefs{OpacMainUserBlock}="OPAC";
232 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
233 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
234 $tabsysprefs{OPACUserCSS}="OPAC";
235 $tabsysprefs{OPACHighlightedWords}="OPAC";
236 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
237 $tabsysprefs{URLLinkText}="OPAC";
238 $tabsysprefs{OPACShelfBrowser}="OPAC";
241 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
242 $tabsysprefs{Disable_Dictionary}="OPAC";
243 $tabsysprefs{hidelostitems}="OPAC";
244 $tabsysprefs{opacbookbag}="OPAC";
245 $tabsysprefs{opaclanguagesdisplay}="OPAC";
246 $tabsysprefs{OpacPasswordChange}="OPAC";
247 $tabsysprefs{opacreadinghistory}="OPAC";
248 $tabsysprefs{virtualshelves}="OPAC";
249 $tabsysprefs{RequestOnOpac}="OPAC";
250 $tabsysprefs{reviewson}="OPAC";
251 $tabsysprefs{OpacTopissues}="OPAC";
252 $tabsysprefs{OpacAuthorities}="OPAC";
253 $tabsysprefs{OpacCloud}="OPAC";
254 $tabsysprefs{opacuserlogin}="OPAC";
255 $tabsysprefs{AnonSuggestions}="OPAC";
256 $tabsysprefs{suggestion}="OPAC";
257 $tabsysprefs{OpacTopissue}="OPAC";
258 $tabsysprefs{OpacBrowser}="OPAC";
259 $tabsysprefs{kohaspsuggest} = "OPAC";
260 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
263 $tabsysprefs{CataloguingLog} = "LOGFeatures";
264 $tabsysprefs{BorrowersLog} = "LOGFeatures";
265 $tabsysprefs{SubscriptionLog} = "LOGFeatures";
266 $tabsysprefs{IssueLog} = "LOGFeatures";
267 $tabsysprefs{ReturnLog} = "LOGFeatures";
268 $tabsysprefs{LetterLog} = "LOGFeatures";
269 $tabsysprefs{FinesLog} = "LOGFeatures";
272 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
273 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
274 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
275 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
276 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
280 my ($searchstring,$type)=@_;
281 my $dbh = C4::Context->dbh;
282 $searchstring=~ s/\'/\\\'/g;
283 my @data=split(' ',$searchstring);
288 # used for doing a plain-old sys-pref search
289 if ($type eq 'all' ){
290 my $sth=$dbh->prepare("SELECT * FROM systempreferences
291 WHERE variable LIKE ? OR explanation LIKE ?
293 $sth->execute("%$searchstring%", "%$searchstring%");
294 while (my $data=$sth->fetchrow_hashref){
295 $data->{value} =~ s/</</g;
296 $data->{value} =~ s/>/>/g;
297 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
298 push(@results,$data);
304 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
305 if ($tabsysprefs{$syspref} eq $type){
306 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
307 $sth->execute($syspref);
308 while (my $data=$sth->fetchrow_hashref){
309 $data->{value} =~ s/</</g;
310 $data->{value} =~ s/>/>/g;
311 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
312 push(@results,$data);
319 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
320 foreach my $syspref (keys %tabsysprefs){
321 $strsth .= $dbh->quote($syspref).",";
324 $strsth .= " order by variable";
325 my $sth=$dbh->prepare($strsth);
327 while (my $data=$sth->fetchrow_hashref){
328 $data->{value}=substr($data->{value},0,100);
329 push(@results,$data);
334 return ($cnt,\@results);
338 my $searchfield = $input->param('searchfield');
339 my $Tvalue = $input->param('Tvalue');
340 my $offset = $input->param('offset');
341 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
343 my ($template, $borrowernumber, $cookie)
344 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
347 authnotrequired => 0,
348 flagsrequired => {parameters => 1},
352 my $op = $input->param('op');
353 $searchfield=~ s/\,//g;
356 $template->param(script_name => $script_name,
357 $op => 1); # we show only the TMPL_VAR names $op
359 $template->param(script_name => $script_name,
360 else => 1); # we show only the TMPL_VAR names $op
363 if ($op eq 'update_and_reedit') {
364 foreach ($input->param) {
367 if (my $currentorder=$input->param('currentorder')) {
368 my @currentorder=split /\|/, $currentorder;
370 foreach my $param ($input->param) {
371 if ($param=~m#up-(\d+).x#) {
372 my $temp=$currentorder[$1];
373 $currentorder[$1]=$currentorder[$1-1];
374 $currentorder[$1-1]=$temp;
377 } elsif ($param=~m#down-(\d+).x#) {
378 my $temp=$currentorder[$1];
379 $currentorder[$1]=$currentorder[$1+1];
380 $currentorder[$1+1]=$temp;
385 $value=join ' ', @currentorder;
388 $template->param(script_name => $script_name,
389 $op => 1); # we show only the TMPL_VAR names $op
393 $template->param(script_name => $script_name,
394 else => 1); # we show only the TMPL_VAR names $op
397 my $dbh = C4::Context->dbh;
398 my $query="select * from systempreferences where variable=?";
399 my $sth=$dbh->prepare($query);
400 $sth->execute($input->param('variable'));
402 unless (C4::Context->config('demo') eq 1) {
403 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
404 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
406 warn "logaction !! mod ";
407 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
410 unless (C4::Context->config('demo') eq 1) {
411 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
412 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
414 warn "logaction !! add ";
415 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
422 ################## ADD_FORM ##################################
423 # called by default. Used to create form to add or modify a record
425 if ($op eq 'add_form') {
426 #---- if primkey exists, it's a modify action, so read values to modify...
429 my $dbh = C4::Context->dbh;
430 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
431 $sth->execute($searchfield);
432 $data=$sth->fetchrow_hashref;
434 $template->param(modify => 1);
435 # save tab to return to if user cancels edit
436 $template->param(return_tab => $tabsysprefs{$searchfield});
440 foreach my $option (split(/\|/, $data->{'options'})) {
442 $option eq $data->{'value'} and $selected=1;
443 push @options, { option => $option, selected => $selected };
445 if ($data->{'type'} eq 'Choice') {
446 $template->param('type-choice' => 1);
447 } elsif ($data->{'type'} eq 'YesNo') {
448 $template->param('type-yesno' => 1);
449 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
450 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
451 } elsif ($data->{'type'} eq 'Integer') {
452 $template->param('type-free' => 1);
453 $template->param('fieldlength' => $data->{'options'});
454 } elsif ($data->{'type'} eq 'Textarea') {
455 $template->param('type-textarea' => 1);
456 $data->{options} =~ /(.*)\|(.*)/;
457 $template->param('cols' => $1, 'rows' => $2);;
458 } elsif ($data->{'type'} eq 'Float') {
459 $template->param('type-free' => 1);
460 $template->param('fieldlength' => $data->{'options'});
461 } elsif ($data->{'type'} eq 'Themes') {
462 $template->param('type-choice' => 1);
464 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
466 my $currently_selected_themes;
468 foreach my $theme (split /\s+/, $data->{'value'}) {
469 push @options, { option => $theme, counter => $counter };
470 $currently_selected_themes->{$theme}=1;
473 foreach my $theme (getallthemes($type)) {
475 next if $currently_selected_themes->{$theme};
476 push @options, { option => $theme, counter => $counter };
479 } elsif ($data->{'type'} eq 'ClassSources') {
480 $template->param('type-choice' => 1);
483 my $sources = GetClassSources();
485 foreach my $cn_source (sort keys %$sources) {
486 if ($cn_source eq $data->{'value'}) {
487 push @options, { option => $cn_source, counter => $counter, selected => 1 };
489 push @options, { option => $cn_source, counter => $counter };
493 } elsif ($data->{'type'} eq 'Languages') {
494 my $currently_selected_languages;
495 foreach my $language (split /\s+/, $data->{'value'}) {
496 $currently_selected_languages->{$language}=1;
499 my $lang = $template->param('lang');
502 if ($data->{'variable'} =~ /opac/) {
505 $theme = C4::Context->preference('opacthemes');
508 # this is the staff client
509 $interface = 'intranet';
510 $theme = C4::Context->preference('template');
512 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
514 $template->param('languages_loop' => $languages_loop);
515 $template->param('type-langselector' => 1);
517 $template->param('type-free' => 1);
518 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
520 $template->param(explanation => $data->{'explanation'},
521 value => $data->{'value'},
522 type => $data->{'type'},
523 options => \@options,
524 preftype => $data->{'type'},
525 prefoptions => $data->{'options'},
526 searchfield => $searchfield);
528 ################## ADD_VALIDATE ##################################
529 # called by add_form, used to insert/modify data in DB
530 } elsif ($op eq 'add_validate') {
531 my $dbh = C4::Context->dbh;
532 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
533 $sth->execute($input->param('variable'));
534 # to handle multiple values
536 # handle multiple value strings (separated by ',')
537 my $params = $input->Vars;
538 my @values = split("\0",$params->{'value'}) if $params->{'value'};
539 for my $vl (@values) {
544 unless (C4::Context->config('demo') eq 1) {
545 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
546 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
548 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
551 unless (C4::Context->config('demo') eq 1) {
552 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
553 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
555 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
559 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
561 ################## DELETE_CONFIRM ##################################
562 # called by default form, used to confirm deletion of data in DB
563 } elsif ($op eq 'delete_confirm') {
564 my $dbh = C4::Context->dbh;
565 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
566 $sth->execute($searchfield);
567 my $data=$sth->fetchrow_hashref;
569 $template->param(searchfield => $searchfield,
570 Tvalue => $data->{'value'},
573 # END $OP eq DELETE_CONFIRM
574 ################## DELETE_CONFIRMED ##################################
575 # called by delete_confirm, used to effectively confirm deletion of data in DB
576 } elsif ($op eq 'delete_confirmed') {
577 my $dbh = C4::Context->dbh;
578 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
579 $sth->execute($searchfield);
580 my $logstring = $searchfield . " | " . $Tvalue ;
581 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
584 # END $OP eq DELETE_CONFIRMED
585 ################## DEFAULT ##################################
587 #Adding tab management for system preferences
588 my $tab=$input->param('tab');
589 $template->param($tab => 1);
590 my ($count,$results)=StringSearch($searchfield,$tab);
593 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
599 my %row_data; # get a fresh hash for the row data
600 $row_data{variable} = $results->[$i]{'variable'};
601 $row_data{value} = $results->[$i]{'value'};
602 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
603 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
604 $row_data{explanation} = $results->[$i]{'explanation'};
605 $row_data{toggle} = $toggle;
606 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
607 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
608 push(@loop_data, \%row_data);
610 $tab=($tab?$tab:"Local Use");
611 $template->param(loop => \@loop_data, $tab => 1);
613 my $prevpage = $offset-$pagesize;
614 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
616 if ($offset+$pagesize<$count) {
617 my $nextpage =$offset+$pagesize;
618 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
620 $template->param( tab => $tab,
622 } #---- END $OP eq DEFAULT
623 output_html_with_http_headers $input, $cookie, $template->output;