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";
71 $tabsysprefs{RenewSerialAddsSuggestion}="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";
121 $tabsysprefs{OpacSuppression}="Cataloguing";
124 $tabsysprefs{maxoutstanding}="Circulation";
125 $tabsysprefs{maxreserves}="Circulation";
126 $tabsysprefs{noissuescharge}="Circulation";
127 $tabsysprefs{IssuingInProcess}="Circulation";
128 $tabsysprefs{patronimages}="Circulation";
129 $tabsysprefs{printcirculationslips}="Circulation";
130 $tabsysprefs{ReturnBeforeExpiry}="Circulation";
131 $tabsysprefs{SpecifyDueDate}="Circulation";
132 $tabsysprefs{AutomaticItemReturn}="Circulation";
133 $tabsysprefs{ReservesMaxPickUpDelay}="Circulation";
134 $tabsysprefs{TransfersMaxDaysWarning}="Circulation";
135 $tabsysprefs{useDaysMode}="Circulation";
136 $tabsysprefs{ReservesNeedReturns}="Circulation";
137 $tabsysprefs{CircAutocompl}="Circulation";
138 $tabsysprefs{canreservefromotherbranches}="Circulation";
139 $tabsysprefs{finesMode}="Circulation";
140 $tabsysprefs{emailLibrarianWhenHoldIsPlaced}="Circulation";
141 $tabsysprefs{globalDueDate}="Circulation";
142 $tabsysprefs{holdCancelLength}="Circulation";
143 $tabsysprefs{itemBarcodeInputFilter}="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";
150 $tabsysprefs{RandomizeHoldsQueueWeight}="Circulation";
151 $tabsysprefs{StaticHoldsQueueWeight}="Circulation";
152 $tabsysprefs{AllowOnShelfHolds}="Circulation";
153 $tabsysprefs{AllowHoldsOnDamagedItems}="Circulation";
156 $tabsysprefs{TemplateEncoding}="StaffClient";
157 $tabsysprefs{template}="StaffClient";
158 $tabsysprefs{intranetstylesheet}="StaffClient";
159 $tabsysprefs{IntranetNav}="StaffClient";
160 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
161 $tabsysprefs{intranetuserjs}="StaffClient";
162 $tabsysprefs{yuipath}="StaffClient";
163 $tabsysprefs{IntranetmainUserblock}="StaffClient";
166 $tabsysprefs{autoMemberNum}="Patrons";
167 $tabsysprefs{checkdigit}="Patrons";
168 $tabsysprefs{intranetreadinghistory}="Patrons";
169 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
170 $tabsysprefs{memberofinstitution}="Patrons";
171 $tabsysprefs{ReadingHistory}="Patrons";
172 $tabsysprefs{BorrowerMandatoryField}="Patrons";
173 $tabsysprefs{borrowerRelationship}="Patrons";
174 $tabsysprefs{BorrowersTitles}="Patrons";
175 $tabsysprefs{patronimages}="Patrons";
176 $tabsysprefs{MinPasswordLength}="Patrons";
177 $tabsysprefs{uppercasesurnames}="Patrons";
178 $tabsysprefs{NoReturnSetLost}="Patrons";
179 $tabsysprefs{MaxFine}="Patrons";
180 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
181 $tabsysprefs{AddPatronLists}="Patrons";
182 $tabsysprefs{PatronsPerPage}="Patrons";
183 $tabsysprefs{ExtendedPatronAttributes}="Patrons";
184 $tabsysprefs{AutoEmailOpacUser}="Patrons";
185 $tabsysprefs{AutoEmailPrimaryAddress}="Patrons";
186 $tabsysprefs{EnhancedMessagingPreferences}="Patrons";
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{numSearchResults}="Searching";
198 $tabsysprefs{OPACdefaultSortField}="Searching";
199 $tabsysprefs{OPACdefaultSortOrder}="Searching";
200 $tabsysprefs{OPACItemsResultsDisplay}="Searching";
201 $tabsysprefs{OPACnumSearchResults}="Searching";
202 $tabsysprefs{QueryFuzzy}="Searching";
203 $tabsysprefs{QueryStemming}="Searching";
204 $tabsysprefs{QueryWeightFields}="Searching";
205 $tabsysprefs{expandedSearchOption}="Searching";
206 $tabsysprefs{sortbynonfiling}="Searching";
207 $tabsysprefs{QueryAutoTruncate}="Searching";
208 $tabsysprefs{QueryRemoveStopwords}="Searching";
209 $tabsysprefs{AdvancedSearchTypes}="Searching";
212 $tabsysprefs{AmazonContent}="EnhancedContent";
213 $tabsysprefs{AWSAccessKeyID}="EnhancedContent";
214 $tabsysprefs{AmazonLocale}="EnhancedContent";
215 $tabsysprefs{AmazonAssocTag}="EnhancedContent";
216 $tabsysprefs{AmazonSimilarItems}="EnhancedContent";
217 $tabsysprefs{OPACAmazonContent}="EnhancedContent";
218 $tabsysprefs{OPACAmazonSimilarItems}="EnhancedContent";
221 $tabsysprefs{BakerTaylorBookstoreURL} = 'EnhancedContent';
222 $tabsysprefs{BakerTaylorEnabled} = 'EnhancedContent';
223 $tabsysprefs{BakerTaylorPassword} = 'EnhancedContent';
224 $tabsysprefs{BakerTaylorUsername} = 'EnhancedContent';
226 $tabsysprefs{FRBRizeEditions}="EnhancedContent";
227 $tabsysprefs{XISBN}="EnhancedContent";
228 $tabsysprefs{OCLCAffiliateID}="EnhancedContent";
229 $tabsysprefs{XISBNDailyLimit}="EnhancedContent";
230 $tabsysprefs{PINESISBN}="EnhancedContent";
231 $tabsysprefs{ThingISBN}="EnhancedContent";
232 $tabsysprefs{OPACFRBRizeEditions}="EnhancedContent";
234 $tabsysprefs{TagsEnabled} = 'EnhancedContent';
235 $tabsysprefs{TagsExternalDictionary} = 'EnhancedContent';
236 $tabsysprefs{TagsInputOnDetail} = 'EnhancedContent';
237 $tabsysprefs{TagsInputOnList} = 'EnhancedContent';
238 $tabsysprefs{TagsShowOnDetail} = 'EnhancedContent';
239 $tabsysprefs{TagsShowOnList} = 'EnhancedContent';
240 $tabsysprefs{TagsModeration} = 'EnhancedContent';
241 $tabsysprefs{GoogleJackets} = 'EnhancedContent';
242 $tabsysprefs{AuthorisedValueImages} = "EnhancedContent";
245 $tabsysprefs{BiblioDefaultView}="OPAC";
246 $tabsysprefs{LibraryName}="OPAC";
247 $tabsysprefs{opaccolorstylesheet}="OPAC";
248 $tabsysprefs{opaccredits}="OPAC";
249 $tabsysprefs{opaclayoutstylesheet}="OPAC";
250 $tabsysprefs{OpacNav}="OPAC";
251 $tabsysprefs{opacsmallimage}="OPAC";
252 $tabsysprefs{opacstylesheet}="OPAC";
253 $tabsysprefs{opacthemes}="OPAC";
254 $tabsysprefs{opacuserjs}="OPAC";
255 $tabsysprefs{SubscriptionHistory}="OPAC";
256 $tabsysprefs{opacheader}="OPAC";
257 $tabsysprefs{noOPACUserLogin}="OPAC";
258 $tabsysprefs{hideBiblioNumber}="OPAC";
259 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
260 $tabsysprefs{OpacMainUserBlock}="OPAC";
261 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
262 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
263 $tabsysprefs{OPACUserCSS}="OPAC";
264 $tabsysprefs{OPACHighlightedWords}="OPAC";
265 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
266 $tabsysprefs{URLLinkText}="OPAC";
267 $tabsysprefs{OPACShelfBrowser}="OPAC";
270 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
271 $tabsysprefs{hidelostitems}="OPAC";
272 $tabsysprefs{opacbookbag}="OPAC";
273 $tabsysprefs{opaclanguagesdisplay}="OPAC";
274 $tabsysprefs{OpacPasswordChange}="OPAC";
275 $tabsysprefs{opacreadinghistory}="OPAC";
276 $tabsysprefs{virtualshelves}="OPAC";
277 $tabsysprefs{RequestOnOpac}="OPAC";
278 $tabsysprefs{reviewson}="OPAC";
279 $tabsysprefs{OpacTopissues}="OPAC";
280 $tabsysprefs{OpacAuthorities}="OPAC";
281 $tabsysprefs{OpacCloud}="OPAC";
282 $tabsysprefs{opacuserlogin}="OPAC";
283 $tabsysprefs{AnonSuggestions}="OPAC";
284 $tabsysprefs{suggestion}="OPAC";
285 $tabsysprefs{OpacTopissue}="OPAC";
286 $tabsysprefs{OpacBrowser}="OPAC";
287 $tabsysprefs{kohaspsuggest} = "OPAC";
288 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
289 $tabsysprefs{OPACItemHolds} = "OPAC";
290 $tabsysprefs{OPACGroupResults}="OPAC";
291 $tabsysprefs{XSLTDetailsDisplay}="OPAC";
292 $tabsysprefs{XSLTResultsDisplay}="OPAC";
295 $tabsysprefs{CataloguingLog} = "Logs";
296 $tabsysprefs{BorrowersLog} = "Logs";
297 $tabsysprefs{SubscriptionLog} = "Logs";
298 $tabsysprefs{IssueLog} = "Logs";
299 $tabsysprefs{ReturnLog} = "Logs";
300 $tabsysprefs{LetterLog} = "Logs";
301 $tabsysprefs{FinesLog} = "Logs";
304 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
305 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
306 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
307 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
308 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
311 my ($searchstring,$type)=@_;
312 my $dbh = C4::Context->dbh;
313 $searchstring=~ s/\'/\\\'/g;
314 my @data=split(' ',$searchstring);
319 # used for doing a plain-old sys-pref search
320 if ($type eq 'all' ){
321 my $sth=$dbh->prepare("SELECT * FROM systempreferences
322 WHERE variable LIKE ? OR explanation LIKE ?
324 $sth->execute("%$searchstring%", "%$searchstring%");
325 while (my $data=$sth->fetchrow_hashref){
326 $data->{value} =~ s/</</g;
327 $data->{value} =~ s/>/>/g;
328 $data->{value}=substr($data->{value},0,60)."..." if length($data->{value}) >60;
329 push(@results,$data);
335 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
336 if ($tabsysprefs{$syspref} eq $type){
337 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
338 $sth->execute($syspref);
339 while (my $data=$sth->fetchrow_hashref){
340 $data->{value} =~ s/</</g;
341 $data->{value} =~ s/>/>/g;
342 $data->{value}=substr($data->{value},0,60)."..." if length($data->{value}) >60;
343 push(@results,$data);
350 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
351 foreach my $syspref (keys %tabsysprefs){
352 $strsth .= $dbh->quote($syspref).",";
355 $strsth .= " order by variable";
356 my $sth=$dbh->prepare($strsth);
358 while (my $data=$sth->fetchrow_hashref){
359 $data->{value}=substr($data->{value},0,60);
360 push(@results,$data);
365 return ($cnt,\@results);
369 my $searchfield = $input->param('searchfield');
370 my $Tvalue = $input->param('Tvalue');
371 my $offset = $input->param('offset');
372 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
374 my ($template, $borrowernumber, $cookie)
375 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
378 authnotrequired => 0,
379 flagsrequired => {parameters => 1},
383 my $op = $input->param('op');
384 $searchfield=~ s/\,//g;
387 $template->param(script_name => $script_name,
388 $op => 1); # we show only the TMPL_VAR names $op
390 $template->param(script_name => $script_name,
391 else => 1); # we show only the TMPL_VAR names $op
394 if ($op eq 'update_and_reedit') {
395 foreach ($input->param) {
398 if (my $currentorder=$input->param('currentorder')) {
399 my @currentorder=split /\|/, $currentorder;
401 foreach my $param ($input->param) {
402 if ($param=~m#up-(\d+).x#) {
403 my $temp=$currentorder[$1];
404 $currentorder[$1]=$currentorder[$1-1];
405 $currentorder[$1-1]=$temp;
408 } elsif ($param=~m#down-(\d+).x#) {
409 my $temp=$currentorder[$1];
410 $currentorder[$1]=$currentorder[$1+1];
411 $currentorder[$1+1]=$temp;
416 $value=join ' ', @currentorder;
419 $template->param(script_name => $script_name,
420 $op => 1); # we show only the TMPL_VAR names $op
424 $template->param(script_name => $script_name,
425 else => 1); # we show only the TMPL_VAR names $op
428 my $dbh = C4::Context->dbh;
429 my $query="select * from systempreferences where variable=?";
430 my $sth=$dbh->prepare($query);
431 $sth->execute($input->param('variable'));
433 unless (C4::Context->config('demo') eq 1) {
434 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
435 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
437 warn "logaction !! mod ";
438 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
441 unless (C4::Context->config('demo') eq 1) {
442 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
443 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
445 warn "logaction !! add ";
446 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
453 ################## ADD_FORM ##################################
454 # called by default. Used to create form to add or modify a record
456 if ($op eq 'add_form') {
457 #---- if primkey exists, it's a modify action, so read values to modify...
460 my $dbh = C4::Context->dbh;
461 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
462 $sth->execute($searchfield);
463 $data=$sth->fetchrow_hashref;
465 $template->param(modify => 1);
466 # save tab to return to if user cancels edit
467 $template->param(return_tab => $tabsysprefs{$searchfield});
471 foreach my $option (split(/\|/, $data->{'options'})) {
473 $option eq $data->{'value'} and $selected=1;
474 push @options, { option => $option, selected => $selected };
476 if ($data->{'type'} eq 'Choice') {
477 $template->param('type-choice' => 1);
478 } elsif ($data->{'type'} eq 'YesNo') {
479 $template->param('type-yesno' => 1);
480 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
481 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
482 } elsif ($data->{'type'} eq 'Integer') {
483 $template->param('type-free' => 1);
484 $template->param('fieldlength' => $data->{'options'});
485 } elsif ($data->{'type'} eq 'Textarea') {
486 $template->param('type-textarea' => 1);
487 $data->{options} =~ /(.*)\|(.*)/;
488 $template->param('cols' => $1, 'rows' => $2);;
489 } elsif ($data->{'type'} eq 'Float') {
490 $template->param('type-free' => 1);
491 $template->param('fieldlength' => $data->{'options'});
492 } elsif ($data->{'type'} eq 'Themes') {
493 $template->param('type-choice' => 1);
495 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
497 my $currently_selected_themes;
499 foreach my $theme (split /\s+/, $data->{'value'}) {
500 push @options, { option => $theme, counter => $counter };
501 $currently_selected_themes->{$theme}=1;
504 foreach my $theme (getallthemes($type)) {
506 next if $currently_selected_themes->{$theme};
507 push @options, { option => $theme, counter => $counter };
510 } elsif ($data->{'type'} eq 'ClassSources') {
511 $template->param('type-choice' => 1);
514 my $sources = GetClassSources();
516 foreach my $cn_source (sort keys %$sources) {
517 if ($cn_source eq $data->{'value'}) {
518 push @options, { option => $cn_source, counter => $counter, selected => 1 };
520 push @options, { option => $cn_source, counter => $counter };
524 } elsif ($data->{'type'} eq 'Languages') {
525 my $currently_selected_languages;
526 foreach my $language (split /\s+/, $data->{'value'}) {
527 $currently_selected_languages->{$language}=1;
530 my $lang = $template->param('lang');
533 if ($data->{'variable'} =~ /opac/) {
536 $theme = C4::Context->preference('opacthemes');
539 # this is the staff client
540 $interface = 'intranet';
541 $theme = C4::Context->preference('template');
543 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
545 $template->param('languages_loop' => $languages_loop);
546 $template->param('type-langselector' => 1);
548 $template->param('type-free' => 1);
549 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
551 $template->param(explanation => $data->{'explanation'},
552 value => $data->{'value'},
553 type => $data->{'type'},
554 options => \@options,
555 preftype => $data->{'type'},
556 prefoptions => $data->{'options'},
557 searchfield => $searchfield);
559 ################## ADD_VALIDATE ##################################
560 # called by add_form, used to insert/modify data in DB
561 } elsif ($op eq 'add_validate') {
562 my $dbh = C4::Context->dbh;
563 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
564 $sth->execute($input->param('variable'));
565 # to handle multiple values
567 # handle multiple value strings (separated by ',')
568 my $params = $input->Vars;
569 my @values = split("\0",$params->{'value'}) if $params->{'value'};
570 for my $vl (@values) {
575 unless (C4::Context->config('demo') eq 1) {
576 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
577 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
579 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
582 unless (C4::Context->config('demo') eq 1) {
583 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
584 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
586 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
590 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
592 ################## DELETE_CONFIRM ##################################
593 # called by default form, used to confirm deletion of data in DB
594 } elsif ($op eq 'delete_confirm') {
595 my $dbh = C4::Context->dbh;
596 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
597 $sth->execute($searchfield);
598 my $data=$sth->fetchrow_hashref;
600 $template->param(searchfield => $searchfield,
601 Tvalue => $data->{'value'},
604 # END $OP eq DELETE_CONFIRM
605 ################## DELETE_CONFIRMED ##################################
606 # called by delete_confirm, used to effectively confirm deletion of data in DB
607 } elsif ($op eq 'delete_confirmed') {
608 my $dbh = C4::Context->dbh;
609 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
610 $sth->execute($searchfield);
611 my $logstring = $searchfield . " | " . $Tvalue ;
612 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
615 # END $OP eq DELETE_CONFIRMED
616 ################## DEFAULT ##################################
618 #Adding tab management for system preferences
619 my $tab=$input->param('tab');
620 $template->param($tab => 1);
621 my ($count,$results)=StringSearch($searchfield,$tab);
624 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
630 my %row_data; # get a fresh hash for the row data
631 $row_data{variable} = $results->[$i]{'variable'};
632 $row_data{value} = $results->[$i]{'value'};
633 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
634 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
635 $row_data{explanation} = $results->[$i]{'explanation'};
636 $row_data{toggle} = $toggle;
637 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
638 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
639 push(@loop_data, \%row_data);
641 $tab=($tab?$tab:"Local Use");
642 $template->param(loop => \@loop_data, $tab => 1);
644 my $prevpage = $offset-$pagesize;
645 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
647 if ($offset+$pagesize<$count) {
648 my $nextpage =$offset+$pagesize;
649 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
651 $template->param( tab => $tab,
653 } #---- END $OP eq DEFAULT
654 output_html_with_http_headers $input, $cookie, $template->output;