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);
53 # use Smart::Comments;
56 # FIXME, shouldnt we store this stuff in the systempreferences table?
58 # FIXME: This uses hash in a backwards way. What we really want is:
59 # $tabsysprefs{key} = $array_ref;
61 # $tabsysprefs{Cataloguing} = [qw(autoBarcode ISBD marc ...)];
63 # Because some things *should* be on more than one tab.
64 # And the tabname is the unique part (the key).
68 $tabsysprefs{acquisitions}="Acquisitions";
69 $tabsysprefs{gist}="Acquisitions";
70 $tabsysprefs{emailPurchaseSuggestions}="Acquisitions";
73 $tabsysprefs{singleBranchMode}="Admin";
74 $tabsysprefs{staffClientBaseURL}="Admin";
75 $tabsysprefs{Version}="Admin";
76 $tabsysprefs{OpacMaintenance}="Admin";
77 $tabsysprefs{FrameworksLoaded}="Admin";
78 $tabsysprefs{libraryAddress}="Admin";
79 $tabsysprefs{delimiter}="Admin";
80 $tabsysprefs{IndependantBranches}="Admin";
81 $tabsysprefs{insecure}="Admin";
82 $tabsysprefs{KohaAdmin}="Admin";
83 $tabsysprefs{KohaAdminEmailAddress}="Admin";
84 $tabsysprefs{MIME}="Admin";
85 $tabsysprefs{timeout}="Admin";
86 $tabsysprefs{Intranet_includes}="Admin";
87 $tabsysprefs{AutoLocation}="Admin";
88 $tabsysprefs{DebugLevel}="Admin";
89 $tabsysprefs{SessionStorage}="Admin";
90 $tabsysprefs{noItemTypeImages}="Admin";
91 $tabsysprefs{OPACBaseURL}="Admin";
92 $tabsysprefs{GranularPermissions}="Admin";
95 $tabsysprefs{authoritysep}="Authorities";
96 $tabsysprefs{AuthDisplayHierarchy}="Authorities";
97 $tabsysprefs{dontmerge}="Authorities";
98 $tabsysprefs{BiblioAddsAuthorities}="Authorities";
100 $tabsysprefs{advancedMARCEditor}="Cataloguing";
101 $tabsysprefs{autoBarcode}="Cataloguing";
102 $tabsysprefs{hide_marc}="Cataloguing";
103 $tabsysprefs{IntranetBiblioDefaultView} = "Cataloguing";
104 $tabsysprefs{ISBD}="Cataloguing";
105 $tabsysprefs{itemcallnumber}="Cataloguing";
106 $tabsysprefs{LabelMARCView}="Cataloguing";
107 $tabsysprefs{marc}="Cataloguing";
108 $tabsysprefs{marcflavour}="Cataloguing";
109 $tabsysprefs{MARCOrgCode}="Cataloguing";
110 $tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
111 $tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
112 $tabsysprefs{Stemming}="Cataloguing";
113 $tabsysprefs{WeightFields}="Cataloguing";
114 $tabsysprefs{NoZebra}="Cataloguing";
115 $tabsysprefs{NoZebraIndexes}="Cataloguing";
116 $tabsysprefs{ReceiveBackIssues}="Cataloguing";
117 $tabsysprefs{DefaultClassificationSource}="Cataloguing";
118 $tabsysprefs{RoutingSerials}="Cataloguing";
119 $tabsysprefs{'item-level_itypes'}="Cataloguing";
122 $tabsysprefs{maxoutstanding}="Circulation";
123 $tabsysprefs{maxreserves}="Circulation";
124 $tabsysprefs{noissuescharge}="Circulation";
125 $tabsysprefs{IssuingInProcess}="Circulation";
126 $tabsysprefs{patronimages}="Circulation";
127 $tabsysprefs{printcirculationslips}="Circulation";
128 $tabsysprefs{ReturnBeforeExpiry}="Circulation";
129 $tabsysprefs{SpecifyDueDate}="Circulation";
130 $tabsysprefs{AutomaticItemReturn}="Circulation";
131 $tabsysprefs{ReservesMaxPickUpDelay}="Circulation";
132 $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
133 $tabsysprefs{useDaysMode}="Circulation";
134 $tabsysprefs{ReservesNeedReturns}="Circulation";
135 $tabsysprefs{CircAutocompl}="Circulation";
136 $tabsysprefs{canreservefromotherbranches}="Circulation";
137 $tabsysprefs{finesMode}="Circulation";
138 $tabsysprefs{emailLibrarianWhenHoldIsPlaced}="Circulation";
139 $tabsysprefs{globalDueDate}="Circulation";
140 $tabsysprefs{holdCancelLength}="Circulation";
141 $tabsysprefs{itemBarcodeInputFilter}="Circulation";
142 $tabsysprefs{noOPACHolds}="Circulation";
143 $tabsysprefs{WebBasedSelfCheck}="Circulation";
144 $tabsysprefs{CircControl}="Circulation";
145 $tabsysprefs{finesCalendar}="Circulation";
146 $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
147 $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
148 $tabsysprefs{HomeOrHoldingBranch}="Circulation";
151 $tabsysprefs{TemplateEncoding}="StaffClient";
152 $tabsysprefs{template}="StaffClient";
153 $tabsysprefs{intranetstylesheet}="StaffClient";
154 $tabsysprefs{IntranetNav}="StaffClient";
155 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
156 $tabsysprefs{intranetuserjs}="StaffClient";
157 $tabsysprefs{yuipath}="StaffClient";
158 $tabsysprefs{IntranetmainUserblock}="StaffClient";
161 $tabsysprefs{autoMemberNum}="Patrons";
162 $tabsysprefs{checkdigit}="Patrons";
163 $tabsysprefs{intranetreadinghistory}="Patrons";
164 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
165 $tabsysprefs{memberofinstitution}="Patrons";
166 $tabsysprefs{ReadingHistory}="Patrons";
167 $tabsysprefs{BorrowerMandatoryField}="Patrons";
168 $tabsysprefs{borrowerRelationship}="Patrons";
169 $tabsysprefs{BorrowersTitles}="Patrons";
170 $tabsysprefs{patronimages}="Patrons";
171 $tabsysprefs{MinPasswordLength}="Patrons";
172 $tabsysprefs{uppercasesurnames}="Patrons";
173 $tabsysprefs{NoReturnSetLost}="Patrons";
174 $tabsysprefs{MaxFine}="Patrons";
175 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
176 $tabsysprefs{PatronsPerPage}="Patrons";
179 $tabsysprefs{dateformat}="I18N/L10N";
180 $tabsysprefs{opaclanguages}="I18N/L10N";
181 $tabsysprefs{opacthemes}="I18N/L10N";
182 $tabsysprefs{language}="I18N/L10N";
185 $tabsysprefs{defaultSortField}="Searching";
186 $tabsysprefs{defaultSortOrder}="Searching";
187 $tabsysprefs{maxItemsInSearchResults}="Searching";
188 $tabsysprefs{numSearchResults}="Searching";
189 $tabsysprefs{OPACdefaultSortField}="Searching";
190 $tabsysprefs{OPACdefaultSortOrder}="Searching";
191 $tabsysprefs{OPACItemsResultsDisplay}="Searching";
192 $tabsysprefs{OPACnumSearchResults}="Searching";
193 $tabsysprefs{QueryFuzzy}="Searching";
194 $tabsysprefs{QueryStemming}="Searching";
195 $tabsysprefs{QueryWeightFields}="Searching";
196 $tabsysprefs{expandedSearchOption}="Searching";
197 $tabsysprefs{sortbynonfiling}="Searching";
198 $tabsysprefs{QueryAutoTruncate}="Searching";
199 $tabsysprefs{QueryRemoveStopwords}="Searching";
202 $tabsysprefs{AmazonContent}="EnhancedContent";
203 $tabsysprefs{AWSAccessKeyID}="EnhancedContent";
204 $tabsysprefs{AmazonLocale}="EnhancedContent";
205 $tabsysprefs{AmazonAssocTag}="EnhancedContent";
206 $tabsysprefs{AmazonSimilarItems}="EnhancedContent";
207 $tabsysprefs{OPACAmazonContent}="EnhancedContent";
208 $tabsysprefs{OPACAmazonSimilarItems}="EnhancedContent";
210 $tabsysprefs{BakerTaylorBookstoreURL} = 'EnhancedContent';
211 $tabsysprefs{BakerTaylorEnabled} = 'EnhancedContent';
212 $tabsysprefs{BakerTaylorPassword} = 'EnhancedContent';
213 $tabsysprefs{BakerTaylorUsername} = 'EnhancedContent';
215 $tabsysprefs{FRBRizeEditions}="EnhancedContent";
216 $tabsysprefs{XISBN}="EnhancedContent";
217 $tabsysprefs{OCLCAffiliateID}="EnhancedContent";
218 $tabsysprefs{XISBNDailyLimit}="EnhancedContent";
219 $tabsysprefs{PINESISBN}="EnhancedContent";
220 $tabsysprefs{ThingISBN}="EnhancedContent";
221 $tabsysprefs{OPACFRBRizeEditions}="EnhancedContent";
223 $tabsysprefs{TagsEnabled} = 'EnhancedContent';
224 $tabsysprefs{TagsExternalDictionary} = 'EnhancedContent';
225 $tabsysprefs{TagsInputOnDetail} = 'EnhancedContent';
226 $tabsysprefs{TagsInputOnList} = 'EnhancedContent';
227 $tabsysprefs{TagsShowOnDetail} = 'EnhancedContent';
228 $tabsysprefs{TagsShowOnList} = 'EnhancedContent';
229 $tabsysprefs{TagsModeration} = 'EnhancedContent';
232 $tabsysprefs{BiblioDefaultView}="OPAC";
233 $tabsysprefs{LibraryName}="OPAC";
234 $tabsysprefs{opaccolorstylesheet}="OPAC";
235 $tabsysprefs{opaccredits}="OPAC";
236 $tabsysprefs{opaclargeimage}="OPAC";
237 $tabsysprefs{opaclayoutstylesheet}="OPAC";
238 $tabsysprefs{OpacNav}="OPAC";
239 $tabsysprefs{opacsmallimage}="OPAC";
240 $tabsysprefs{opacstylesheet}="OPAC";
241 $tabsysprefs{opacthemes}="OPAC";
242 $tabsysprefs{opacuserjs}="OPAC";
243 $tabsysprefs{SubscriptionHistory}="OPAC";
244 $tabsysprefs{opacheader}="OPAC";
246 $tabsysprefs{hideBiblioNumber}="OPAC";
247 $tabsysprefs{noOPACUserLogin}="OPAC";
248 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
249 $tabsysprefs{OpacMainUserBlock}="OPAC";
250 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
251 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
252 $tabsysprefs{OPACUserCSS}="OPAC";
253 $tabsysprefs{OPACHighlightedWords}="OPAC";
254 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
255 $tabsysprefs{URLLinkText}="OPAC";
256 $tabsysprefs{OPACShelfBrowser}="OPAC";
259 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
260 $tabsysprefs{Disable_Dictionary}="OPAC";
261 $tabsysprefs{hidelostitems}="OPAC";
262 $tabsysprefs{opacbookbag}="OPAC";
263 $tabsysprefs{opaclanguagesdisplay}="OPAC";
264 $tabsysprefs{OpacPasswordChange}="OPAC";
265 $tabsysprefs{opacreadinghistory}="OPAC";
266 $tabsysprefs{virtualshelves}="OPAC";
267 $tabsysprefs{RequestOnOpac}="OPAC";
268 $tabsysprefs{reviewson}="OPAC";
269 $tabsysprefs{OpacTopissues}="OPAC";
270 $tabsysprefs{OpacAuthorities}="OPAC";
271 $tabsysprefs{OpacCloud}="OPAC";
272 $tabsysprefs{opacuserlogin}="OPAC";
273 $tabsysprefs{AnonSuggestions}="OPAC";
274 $tabsysprefs{suggestion}="OPAC";
275 $tabsysprefs{OpacTopissue}="OPAC";
276 $tabsysprefs{OpacBrowser}="OPAC";
277 $tabsysprefs{kohaspsuggest} = "OPAC";
278 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
281 $tabsysprefs{CataloguingLog} = "Logs";
282 $tabsysprefs{BorrowersLog} = "Logs";
283 $tabsysprefs{SubscriptionLog} = "Logs";
284 $tabsysprefs{IssueLog} = "Logs";
285 $tabsysprefs{ReturnLog} = "Logs";
286 $tabsysprefs{LetterLog} = "Logs";
287 $tabsysprefs{FinesLog} = "Logs";
290 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
291 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
292 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
293 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
294 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
297 my ($searchstring,$type)=@_;
298 my $dbh = C4::Context->dbh;
299 $searchstring=~ s/\'/\\\'/g;
300 my @data=split(' ',$searchstring);
305 # used for doing a plain-old sys-pref search
306 if ($type eq 'all' ){
307 my $sth=$dbh->prepare("SELECT * FROM systempreferences
308 WHERE variable LIKE ? OR explanation LIKE ?
310 $sth->execute("%$searchstring%", "%$searchstring%");
311 while (my $data=$sth->fetchrow_hashref){
312 $data->{value} =~ s/</</g;
313 $data->{value} =~ s/>/>/g;
314 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
315 push(@results,$data);
321 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
322 if ($tabsysprefs{$syspref} eq $type){
323 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
324 $sth->execute($syspref);
325 while (my $data=$sth->fetchrow_hashref){
326 $data->{value} =~ s/</</g;
327 $data->{value} =~ s/>/>/g;
328 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
329 push(@results,$data);
336 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
337 foreach my $syspref (keys %tabsysprefs){
338 $strsth .= $dbh->quote($syspref).",";
341 $strsth .= " order by variable";
342 my $sth=$dbh->prepare($strsth);
344 while (my $data=$sth->fetchrow_hashref){
345 $data->{value}=substr($data->{value},0,100);
346 push(@results,$data);
351 return ($cnt,\@results);
355 my $searchfield = $input->param('searchfield');
356 my $Tvalue = $input->param('Tvalue');
357 my $offset = $input->param('offset');
358 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
360 my ($template, $borrowernumber, $cookie)
361 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
364 authnotrequired => 0,
365 flagsrequired => {parameters => 1},
369 my $op = $input->param('op');
370 $searchfield=~ s/\,//g;
373 $template->param(script_name => $script_name,
374 $op => 1); # we show only the TMPL_VAR names $op
376 $template->param(script_name => $script_name,
377 else => 1); # we show only the TMPL_VAR names $op
380 if ($op eq 'update_and_reedit') {
381 foreach ($input->param) {
384 if (my $currentorder=$input->param('currentorder')) {
385 my @currentorder=split /\|/, $currentorder;
387 foreach my $param ($input->param) {
388 if ($param=~m#up-(\d+).x#) {
389 my $temp=$currentorder[$1];
390 $currentorder[$1]=$currentorder[$1-1];
391 $currentorder[$1-1]=$temp;
394 } elsif ($param=~m#down-(\d+).x#) {
395 my $temp=$currentorder[$1];
396 $currentorder[$1]=$currentorder[$1+1];
397 $currentorder[$1+1]=$temp;
402 $value=join ' ', @currentorder;
405 $template->param(script_name => $script_name,
406 $op => 1); # we show only the TMPL_VAR names $op
410 $template->param(script_name => $script_name,
411 else => 1); # we show only the TMPL_VAR names $op
414 my $dbh = C4::Context->dbh;
415 my $query="select * from systempreferences where variable=?";
416 my $sth=$dbh->prepare($query);
417 $sth->execute($input->param('variable'));
419 unless (C4::Context->config('demo') eq 1) {
420 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
421 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
423 warn "logaction !! mod ";
424 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
427 unless (C4::Context->config('demo') eq 1) {
428 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
429 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
431 warn "logaction !! add ";
432 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
439 ################## ADD_FORM ##################################
440 # called by default. Used to create form to add or modify a record
442 if ($op eq 'add_form') {
443 #---- if primkey exists, it's a modify action, so read values to modify...
446 my $dbh = C4::Context->dbh;
447 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
448 $sth->execute($searchfield);
449 $data=$sth->fetchrow_hashref;
451 $template->param(modify => 1);
452 # save tab to return to if user cancels edit
453 $template->param(return_tab => $tabsysprefs{$searchfield});
457 foreach my $option (split(/\|/, $data->{'options'})) {
459 $option eq $data->{'value'} and $selected=1;
460 push @options, { option => $option, selected => $selected };
462 if ($data->{'type'} eq 'Choice') {
463 $template->param('type-choice' => 1);
464 } elsif ($data->{'type'} eq 'YesNo') {
465 $template->param('type-yesno' => 1);
466 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
467 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
468 } elsif ($data->{'type'} eq 'Integer') {
469 $template->param('type-free' => 1);
470 $template->param('fieldlength' => $data->{'options'});
471 } elsif ($data->{'type'} eq 'Textarea') {
472 $template->param('type-textarea' => 1);
473 $data->{options} =~ /(.*)\|(.*)/;
474 $template->param('cols' => $1, 'rows' => $2);;
475 } elsif ($data->{'type'} eq 'Float') {
476 $template->param('type-free' => 1);
477 $template->param('fieldlength' => $data->{'options'});
478 } elsif ($data->{'type'} eq 'Themes') {
479 $template->param('type-choice' => 1);
481 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
483 my $currently_selected_themes;
485 foreach my $theme (split /\s+/, $data->{'value'}) {
486 push @options, { option => $theme, counter => $counter };
487 $currently_selected_themes->{$theme}=1;
490 foreach my $theme (getallthemes($type)) {
492 next if $currently_selected_themes->{$theme};
493 push @options, { option => $theme, counter => $counter };
496 } elsif ($data->{'type'} eq 'ClassSources') {
497 $template->param('type-choice' => 1);
500 my $sources = GetClassSources();
502 foreach my $cn_source (sort keys %$sources) {
503 if ($cn_source eq $data->{'value'}) {
504 push @options, { option => $cn_source, counter => $counter, selected => 1 };
506 push @options, { option => $cn_source, counter => $counter };
510 } elsif ($data->{'type'} eq 'Languages') {
511 my $currently_selected_languages;
512 foreach my $language (split /\s+/, $data->{'value'}) {
513 $currently_selected_languages->{$language}=1;
516 my $lang = $template->param('lang');
519 if ($data->{'variable'} =~ /opac/) {
522 $theme = C4::Context->preference('opacthemes');
525 # this is the staff client
526 $interface = 'intranet';
527 $theme = C4::Context->preference('template');
529 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
531 $template->param('languages_loop' => $languages_loop);
532 $template->param('type-langselector' => 1);
534 $template->param('type-free' => 1);
535 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
537 $template->param(explanation => $data->{'explanation'},
538 value => $data->{'value'},
539 type => $data->{'type'},
540 options => \@options,
541 preftype => $data->{'type'},
542 prefoptions => $data->{'options'},
543 searchfield => $searchfield);
545 ################## ADD_VALIDATE ##################################
546 # called by add_form, used to insert/modify data in DB
547 } elsif ($op eq 'add_validate') {
548 my $dbh = C4::Context->dbh;
549 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
550 $sth->execute($input->param('variable'));
551 # to handle multiple values
553 # handle multiple value strings (separated by ',')
554 my $params = $input->Vars;
555 my @values = split("\0",$params->{'value'}) if $params->{'value'};
556 for my $vl (@values) {
561 unless (C4::Context->config('demo') eq 1) {
562 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
563 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
565 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
568 unless (C4::Context->config('demo') eq 1) {
569 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
570 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
572 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
576 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
578 ################## DELETE_CONFIRM ##################################
579 # called by default form, used to confirm deletion of data in DB
580 } elsif ($op eq 'delete_confirm') {
581 my $dbh = C4::Context->dbh;
582 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
583 $sth->execute($searchfield);
584 my $data=$sth->fetchrow_hashref;
586 $template->param(searchfield => $searchfield,
587 Tvalue => $data->{'value'},
590 # END $OP eq DELETE_CONFIRM
591 ################## DELETE_CONFIRMED ##################################
592 # called by delete_confirm, used to effectively confirm deletion of data in DB
593 } elsif ($op eq 'delete_confirmed') {
594 my $dbh = C4::Context->dbh;
595 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
596 $sth->execute($searchfield);
597 my $logstring = $searchfield . " | " . $Tvalue ;
598 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
601 # END $OP eq DELETE_CONFIRMED
602 ################## DEFAULT ##################################
604 #Adding tab management for system preferences
605 my $tab=$input->param('tab');
606 $template->param($tab => 1);
607 my ($count,$results)=StringSearch($searchfield,$tab);
610 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
616 my %row_data; # get a fresh hash for the row data
617 $row_data{variable} = $results->[$i]{'variable'};
618 $row_data{value} = $results->[$i]{'value'};
619 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
620 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
621 $row_data{explanation} = $results->[$i]{'explanation'};
622 $row_data{toggle} = $toggle;
623 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
624 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
625 push(@loop_data, \%row_data);
627 $tab=($tab?$tab:"Local Use");
628 $template->param(loop => \@loop_data, $tab => 1);
630 my $prevpage = $offset-$pagesize;
631 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
633 if ($offset+$pagesize<$count) {
634 my $nextpage =$offset+$pagesize;
635 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
637 $template->param( tab => $tab,
639 } #---- END $OP eq DEFAULT
640 output_html_with_http_headers $input, $cookie, $template->output;