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?
59 # FIXME: This uses hash in a backwards way. What we really want is:
60 # $tabsysprefs{key} = $array_ref;
62 # $tabsysprefs{Cataloguing} = [qw(autoBarcode ISBD marc ...)];
64 # Because some things *should* be on more than one tab.
65 # And the tabname is the unique part (the key).
69 $tabsysprefs{acquisitions}="Acquisitions";
70 $tabsysprefs{gist}="Acquisitions";
71 $tabsysprefs{emailPurchaseSuggestions}="Acquisitions";
74 $tabsysprefs{singleBranchMode}="Admin";
75 $tabsysprefs{staffClientBaseURL}="Admin";
76 $tabsysprefs{Version}="Admin";
77 $tabsysprefs{OpacMaintenance}="Admin";
78 $tabsysprefs{FrameworksLoaded}="Admin";
79 $tabsysprefs{libraryAddress}="Admin";
80 $tabsysprefs{delimiter}="Admin";
81 $tabsysprefs{IndependantBranches}="Admin";
82 $tabsysprefs{insecure}="Admin";
83 $tabsysprefs{KohaAdmin}="Admin";
84 $tabsysprefs{KohaAdminEmailAddress}="Admin";
85 $tabsysprefs{MIME}="Admin";
86 $tabsysprefs{timeout}="Admin";
87 $tabsysprefs{Intranet_includes}="Admin";
88 $tabsysprefs{AutoLocation}="Admin";
89 $tabsysprefs{DebugLevel}="Admin";
90 $tabsysprefs{SessionStorage}="Admin";
91 $tabsysprefs{noItemTypeImages}="Admin";
92 $tabsysprefs{OPACBaseURL}="Admin";
93 $tabsysprefs{GranularPermissions}="Admin";
96 $tabsysprefs{authoritysep}="Authorities";
97 $tabsysprefs{AuthDisplayHierarchy}="Authorities";
98 $tabsysprefs{dontmerge}="Authorities";
99 $tabsysprefs{BiblioAddsAuthorities}="Authorities";
101 $tabsysprefs{advancedMARCEditor}="Cataloguing";
102 $tabsysprefs{autoBarcode}="Cataloguing";
103 $tabsysprefs{hide_marc}="Cataloguing";
104 $tabsysprefs{IntranetBiblioDefaultView} = "Cataloguing";
105 $tabsysprefs{ISBD}="Cataloguing";
106 $tabsysprefs{itemcallnumber}="Cataloguing";
107 $tabsysprefs{LabelMARCView}="Cataloguing";
108 $tabsysprefs{marc}="Cataloguing";
109 $tabsysprefs{marcflavour}="Cataloguing";
110 $tabsysprefs{MARCOrgCode}="Cataloguing";
111 $tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
112 $tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
113 $tabsysprefs{Stemming}="Cataloguing";
114 $tabsysprefs{WeightFields}="Cataloguing";
115 $tabsysprefs{NoZebra}="Cataloguing";
116 $tabsysprefs{NoZebraIndexes}="Cataloguing";
117 $tabsysprefs{ReceiveBackIssues}="Cataloguing";
118 $tabsysprefs{DefaultClassificationSource}="Cataloguing";
119 $tabsysprefs{RoutingSerials}="Cataloguing";
120 $tabsysprefs{'item-level_itypes'}="Cataloguing";
123 $tabsysprefs{maxoutstanding}="Circulation";
124 $tabsysprefs{maxreserves}="Circulation";
125 $tabsysprefs{noissuescharge}="Circulation";
126 $tabsysprefs{IssuingInProcess}="Circulation";
127 $tabsysprefs{patronimages}="Circulation";
128 $tabsysprefs{printcirculationslips}="Circulation";
129 $tabsysprefs{ReturnBeforeExpiry}="Circulation";
130 $tabsysprefs{SpecifyDueDate}="Circulation";
131 $tabsysprefs{AutomaticItemReturn}="Circulation";
132 $tabsysprefs{ReservesMaxPickUpDelay}="Circulation";
133 $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
134 $tabsysprefs{useDaysMode}="Circulation";
135 $tabsysprefs{ReservesNeedReturns}="Circulation";
136 $tabsysprefs{CircAutocompl}="Circulation";
137 $tabsysprefs{canreservefromotherbranches}="Circulation";
138 $tabsysprefs{finesMode}="Circulation";
139 $tabsysprefs{emailLibrarianWhenHoldIsPlaced}="Circulation";
140 $tabsysprefs{globalDueDate}="Circulation";
141 $tabsysprefs{holdCancelLength}="Circulation";
142 $tabsysprefs{itemBarcodeInputFilter}="Circulation";
143 $tabsysprefs{noOPACHolds}="Circulation";
144 $tabsysprefs{WebBasedSelfCheck}="Circulation";
145 $tabsysprefs{CircControl}="Circulation";
146 $tabsysprefs{finesCalendar}="Circulation";
147 $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
148 $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
149 $tabsysprefs{HomeOrHoldingBranch}="Circulation";
152 $tabsysprefs{TemplateEncoding}="StaffClient";
153 $tabsysprefs{template}="StaffClient";
154 $tabsysprefs{intranetstylesheet}="StaffClient";
155 $tabsysprefs{IntranetNav}="StaffClient";
156 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
157 $tabsysprefs{intranetuserjs}="StaffClient";
158 $tabsysprefs{yuipath}="StaffClient";
159 $tabsysprefs{IntranetmainUserblock}="StaffClient";
162 $tabsysprefs{autoMemberNum}="Patrons";
163 $tabsysprefs{checkdigit}="Patrons";
164 $tabsysprefs{intranetreadinghistory}="Patrons";
165 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
166 $tabsysprefs{memberofinstitution}="Patrons";
167 $tabsysprefs{ReadingHistory}="Patrons";
168 $tabsysprefs{BorrowerMandatoryField}="Patrons";
169 $tabsysprefs{borrowerRelationship}="Patrons";
170 $tabsysprefs{BorrowersTitles}="Patrons";
171 $tabsysprefs{patronimages}="Patrons";
172 $tabsysprefs{MinPasswordLength}="Patrons";
173 $tabsysprefs{uppercasesurnames}="Patrons";
174 $tabsysprefs{NoReturnSetLost}="Patrons";
175 $tabsysprefs{MaxFine}="Patrons";
176 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
177 $tabsysprefs{PatronsPerPage}="Patrons";
180 $tabsysprefs{FRBRizeEditions}="FRBR";
181 $tabsysprefs{XISBN}="FRBR";
182 $tabsysprefs{OCLCAffiliateID}="FRBR";
183 $tabsysprefs{XISBNDailyLimit}="FRBR";
184 $tabsysprefs{PINESISBN}="FRBR";
185 $tabsysprefs{ThingISBN}="FRBR";
186 $tabsysprefs{OPACFRBRizeEditions}="FRBR";
189 $tabsysprefs{dateformat}="I18N/L10N";
190 $tabsysprefs{opaclanguages}="I18N/L10N";
191 $tabsysprefs{opacthemes}="I18N/L10N";
192 $tabsysprefs{language}="I18N/L10N";
195 $tabsysprefs{defaultSortField}="Searching";
196 $tabsysprefs{defaultSortOrder}="Searching";
197 $tabsysprefs{maxItemsInSearchResults}="Searching";
198 $tabsysprefs{numSearchResults}="Searching";
199 $tabsysprefs{OPACdefaultSortField}="Searching";
200 $tabsysprefs{OPACdefaultSortOrder}="Searching";
201 $tabsysprefs{OPACItemsResultsDisplay}="Searching";
202 $tabsysprefs{OPACnumSearchResults}="Searching";
203 $tabsysprefs{QueryFuzzy}="Searching";
204 $tabsysprefs{QueryStemming}="Searching";
205 $tabsysprefs{QueryWeightFields}="Searching";
206 $tabsysprefs{expandedSearchOption}="Searching";
207 $tabsysprefs{sortbynonfiling}="Searching";
208 $tabsysprefs{QueryAutoTruncate}="Searching";
209 $tabsysprefs{QueryRemoveStopwords}="Searching";
212 $tabsysprefs{AmazonContent}="Amazon";
213 $tabsysprefs{AWSAccessKeyID}="Amazon";
214 $tabsysprefs{AmazonLocale}="Amazon";
215 $tabsysprefs{AmazonAssocTag}="Amazon";
216 $tabsysprefs{AmazonSimilarItems}="Amazon";
217 $tabsysprefs{OPACAmazonContent}="Amazon";
218 $tabsysprefs{OPACAmazonSimilarItems}="Amazon";
221 $tabsysprefs{BiblioDefaultView}="OPAC";
222 $tabsysprefs{LibraryName}="OPAC";
223 $tabsysprefs{opaccolorstylesheet}="OPAC";
224 $tabsysprefs{opaccredits}="OPAC";
225 $tabsysprefs{opaclargeimage}="OPAC";
226 $tabsysprefs{opaclayoutstylesheet}="OPAC";
227 $tabsysprefs{OpacNav}="OPAC";
228 $tabsysprefs{opacsmallimage}="OPAC";
229 $tabsysprefs{opacstylesheet}="OPAC";
230 $tabsysprefs{opacthemes}="OPAC";
231 $tabsysprefs{opacuserjs}="OPAC";
232 $tabsysprefs{SubscriptionHistory}="OPAC";
233 $tabsysprefs{opacheader}="OPAC";
235 $tabsysprefs{hideBiblioNumber}="OPAC";
236 $tabsysprefs{noOPACUserLogin}="OPAC";
237 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
238 $tabsysprefs{OpacMainUserBlock}="OPAC";
239 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
240 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
241 $tabsysprefs{OPACUserCSS}="OPAC";
242 $tabsysprefs{OPACHighlightedWords}="OPAC";
243 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
244 $tabsysprefs{URLLinkText}="OPAC";
245 $tabsysprefs{OPACShelfBrowser}="OPAC";
248 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
249 $tabsysprefs{Disable_Dictionary}="OPAC";
250 $tabsysprefs{hidelostitems}="OPAC";
251 $tabsysprefs{opacbookbag}="OPAC";
252 $tabsysprefs{opaclanguagesdisplay}="OPAC";
253 $tabsysprefs{OpacPasswordChange}="OPAC";
254 $tabsysprefs{opacreadinghistory}="OPAC";
255 $tabsysprefs{virtualshelves}="OPAC";
256 $tabsysprefs{RequestOnOpac}="OPAC";
257 $tabsysprefs{reviewson}="OPAC";
258 $tabsysprefs{OpacTopissues}="OPAC";
259 $tabsysprefs{OpacAuthorities}="OPAC";
260 $tabsysprefs{OpacCloud}="OPAC";
261 $tabsysprefs{opacuserlogin}="OPAC";
262 $tabsysprefs{AnonSuggestions}="OPAC";
263 $tabsysprefs{suggestion}="OPAC";
264 $tabsysprefs{OpacTopissue}="OPAC";
265 $tabsysprefs{OpacBrowser}="OPAC";
266 $tabsysprefs{kohaspsuggest} = "OPAC";
267 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
270 $tabsysprefs{CataloguingLog} = "Logs";
271 $tabsysprefs{BorrowersLog} = "Logs";
272 $tabsysprefs{SubscriptionLog} = "Logs";
273 $tabsysprefs{IssueLog} = "Logs";
274 $tabsysprefs{ReturnLog} = "Logs";
275 $tabsysprefs{LetterLog} = "Logs";
276 $tabsysprefs{FinesLog} = "Logs";
279 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
280 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
281 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
282 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
283 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
286 $tabsysprefs{TagsEnabled} = 'Tags';
287 $tabsysprefs{TagsExternalDictionary} = 'Tags';
288 $tabsysprefs{TagsInputOnDetail} = 'Tags';
289 $tabsysprefs{TagsInputOnList} = 'Tags';
290 $tabsysprefs{TagsShowOnDetail} = 'Tags';
291 $tabsysprefs{TagsShowOnList} = 'Tags';
292 $tabsysprefs{TagsModeration} = 'Tags';
295 $tabsysprefs{BakerTaylorBookstoreURL} = 'BakerTaylor';
296 $tabsysprefs{BakerTaylorEnabled} = 'BakerTaylor';
297 $tabsysprefs{BakerTaylorPassword} = 'BakerTaylor';
298 $tabsysprefs{BakerTaylorUsername} = 'BakerTaylor';
302 my ($searchstring,$type)=@_;
303 my $dbh = C4::Context->dbh;
304 $searchstring=~ s/\'/\\\'/g;
305 my @data=split(' ',$searchstring);
310 # used for doing a plain-old sys-pref search
311 if ($type eq 'all' ){
312 my $sth=$dbh->prepare("SELECT * FROM systempreferences
313 WHERE variable LIKE ? OR explanation LIKE ?
315 $sth->execute("%$searchstring%", "%$searchstring%");
316 while (my $data=$sth->fetchrow_hashref){
317 $data->{value} =~ s/</</g;
318 $data->{value} =~ s/>/>/g;
319 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
320 push(@results,$data);
326 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
327 if ($tabsysprefs{$syspref} eq $type){
328 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
329 $sth->execute($syspref);
330 while (my $data=$sth->fetchrow_hashref){
331 $data->{value} =~ s/</</g;
332 $data->{value} =~ s/>/>/g;
333 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
334 push(@results,$data);
341 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
342 foreach my $syspref (keys %tabsysprefs){
343 $strsth .= $dbh->quote($syspref).",";
346 $strsth .= " order by variable";
347 my $sth=$dbh->prepare($strsth);
349 while (my $data=$sth->fetchrow_hashref){
350 $data->{value}=substr($data->{value},0,100);
351 push(@results,$data);
356 return ($cnt,\@results);
360 my $searchfield = $input->param('searchfield');
361 my $Tvalue = $input->param('Tvalue');
362 my $offset = $input->param('offset');
363 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
365 my ($template, $borrowernumber, $cookie)
366 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
369 authnotrequired => 0,
370 flagsrequired => {parameters => 1},
374 my $op = $input->param('op');
375 $searchfield=~ s/\,//g;
378 $template->param(script_name => $script_name,
379 $op => 1); # we show only the TMPL_VAR names $op
381 $template->param(script_name => $script_name,
382 else => 1); # we show only the TMPL_VAR names $op
385 if ($op eq 'update_and_reedit') {
386 foreach ($input->param) {
389 if (my $currentorder=$input->param('currentorder')) {
390 my @currentorder=split /\|/, $currentorder;
392 foreach my $param ($input->param) {
393 if ($param=~m#up-(\d+).x#) {
394 my $temp=$currentorder[$1];
395 $currentorder[$1]=$currentorder[$1-1];
396 $currentorder[$1-1]=$temp;
399 } elsif ($param=~m#down-(\d+).x#) {
400 my $temp=$currentorder[$1];
401 $currentorder[$1]=$currentorder[$1+1];
402 $currentorder[$1+1]=$temp;
407 $value=join ' ', @currentorder;
410 $template->param(script_name => $script_name,
411 $op => 1); # we show only the TMPL_VAR names $op
415 $template->param(script_name => $script_name,
416 else => 1); # we show only the TMPL_VAR names $op
419 my $dbh = C4::Context->dbh;
420 my $query="select * from systempreferences where variable=?";
421 my $sth=$dbh->prepare($query);
422 $sth->execute($input->param('variable'));
424 unless (C4::Context->config('demo') eq 1) {
425 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
426 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
428 warn "logaction !! mod ";
429 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
432 unless (C4::Context->config('demo') eq 1) {
433 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
434 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
436 warn "logaction !! add ";
437 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
444 ################## ADD_FORM ##################################
445 # called by default. Used to create form to add or modify a record
447 if ($op eq 'add_form') {
448 #---- if primkey exists, it's a modify action, so read values to modify...
451 my $dbh = C4::Context->dbh;
452 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
453 $sth->execute($searchfield);
454 $data=$sth->fetchrow_hashref;
456 $template->param(modify => 1);
457 # save tab to return to if user cancels edit
458 $template->param(return_tab => $tabsysprefs{$searchfield});
462 foreach my $option (split(/\|/, $data->{'options'})) {
464 $option eq $data->{'value'} and $selected=1;
465 push @options, { option => $option, selected => $selected };
467 if ($data->{'type'} eq 'Choice') {
468 $template->param('type-choice' => 1);
469 } elsif ($data->{'type'} eq 'YesNo') {
470 $template->param('type-yesno' => 1);
471 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
472 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
473 } elsif ($data->{'type'} eq 'Integer') {
474 $template->param('type-free' => 1);
475 $template->param('fieldlength' => $data->{'options'});
476 } elsif ($data->{'type'} eq 'Textarea') {
477 $template->param('type-textarea' => 1);
478 $data->{options} =~ /(.*)\|(.*)/;
479 $template->param('cols' => $1, 'rows' => $2);;
480 } elsif ($data->{'type'} eq 'Float') {
481 $template->param('type-free' => 1);
482 $template->param('fieldlength' => $data->{'options'});
483 } elsif ($data->{'type'} eq 'Themes') {
484 $template->param('type-choice' => 1);
486 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
488 my $currently_selected_themes;
490 foreach my $theme (split /\s+/, $data->{'value'}) {
491 push @options, { option => $theme, counter => $counter };
492 $currently_selected_themes->{$theme}=1;
495 foreach my $theme (getallthemes($type)) {
497 next if $currently_selected_themes->{$theme};
498 push @options, { option => $theme, counter => $counter };
501 } elsif ($data->{'type'} eq 'ClassSources') {
502 $template->param('type-choice' => 1);
505 my $sources = GetClassSources();
507 foreach my $cn_source (sort keys %$sources) {
508 if ($cn_source eq $data->{'value'}) {
509 push @options, { option => $cn_source, counter => $counter, selected => 1 };
511 push @options, { option => $cn_source, counter => $counter };
515 } elsif ($data->{'type'} eq 'Languages') {
516 my $currently_selected_languages;
517 foreach my $language (split /\s+/, $data->{'value'}) {
518 $currently_selected_languages->{$language}=1;
521 my $lang = $template->param('lang');
524 if ($data->{'variable'} =~ /opac/) {
527 $theme = C4::Context->preference('opacthemes');
530 # this is the staff client
531 $interface = 'intranet';
532 $theme = C4::Context->preference('template');
534 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
536 $template->param('languages_loop' => $languages_loop);
537 $template->param('type-langselector' => 1);
539 $template->param('type-free' => 1);
540 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
542 $template->param(explanation => $data->{'explanation'},
543 value => $data->{'value'},
544 type => $data->{'type'},
545 options => \@options,
546 preftype => $data->{'type'},
547 prefoptions => $data->{'options'},
548 searchfield => $searchfield);
550 ################## ADD_VALIDATE ##################################
551 # called by add_form, used to insert/modify data in DB
552 } elsif ($op eq 'add_validate') {
553 my $dbh = C4::Context->dbh;
554 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
555 $sth->execute($input->param('variable'));
556 # to handle multiple values
558 # handle multiple value strings (separated by ',')
559 my $params = $input->Vars;
560 my @values = split("\0",$params->{'value'}) if $params->{'value'};
561 for my $vl (@values) {
566 unless (C4::Context->config('demo') eq 1) {
567 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
568 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
570 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
573 unless (C4::Context->config('demo') eq 1) {
574 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
575 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
577 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
581 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
583 ################## DELETE_CONFIRM ##################################
584 # called by default form, used to confirm deletion of data in DB
585 } elsif ($op eq 'delete_confirm') {
586 my $dbh = C4::Context->dbh;
587 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
588 $sth->execute($searchfield);
589 my $data=$sth->fetchrow_hashref;
591 $template->param(searchfield => $searchfield,
592 Tvalue => $data->{'value'},
595 # END $OP eq DELETE_CONFIRM
596 ################## DELETE_CONFIRMED ##################################
597 # called by delete_confirm, used to effectively confirm deletion of data in DB
598 } elsif ($op eq 'delete_confirmed') {
599 my $dbh = C4::Context->dbh;
600 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
601 $sth->execute($searchfield);
602 my $logstring = $searchfield . " | " . $Tvalue ;
603 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
606 # END $OP eq DELETE_CONFIRMED
607 ################## DEFAULT ##################################
609 #Adding tab management for system preferences
610 my $tab=$input->param('tab');
611 $template->param($tab => 1);
612 my ($count,$results)=StringSearch($searchfield,$tab);
615 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
621 my %row_data; # get a fresh hash for the row data
622 $row_data{variable} = $results->[$i]{'variable'};
623 $row_data{value} = $results->[$i]{'value'};
624 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
625 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
626 $row_data{explanation} = $results->[$i]{'explanation'};
627 $row_data{toggle} = $toggle;
628 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
629 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
630 push(@loop_data, \%row_data);
632 $tab=($tab?$tab:"Local Use");
633 $template->param(loop => \@loop_data, $tab => 1);
635 my $prevpage = $offset-$pagesize;
636 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
638 if ($offset+$pagesize<$count) {
639 my $nextpage =$offset+$pagesize;
640 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
642 $template->param( tab => $tab,
644 } #---- END $OP eq DEFAULT
645 output_html_with_http_headers $input, $cookie, $template->output;