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";
72 $tabsysprefs{serialsadditems}="Acquisitions";
75 $tabsysprefs{singleBranchMode}="Admin";
76 $tabsysprefs{staffClientBaseURL}="Admin";
77 $tabsysprefs{Version}="Admin";
78 $tabsysprefs{OpacMaintenance}="Admin";
79 $tabsysprefs{FrameworksLoaded}="Admin";
80 $tabsysprefs{libraryAddress}="Admin";
81 $tabsysprefs{delimiter}="Admin";
82 $tabsysprefs{IndependantBranches}="Admin";
83 $tabsysprefs{insecure}="Admin";
84 $tabsysprefs{KohaAdmin}="Admin";
85 $tabsysprefs{KohaAdminEmailAddress}="Admin";
86 $tabsysprefs{MIME}="Admin";
87 $tabsysprefs{timeout}="Admin";
88 $tabsysprefs{Intranet_includes}="Admin";
89 $tabsysprefs{AutoLocation}="Admin";
90 $tabsysprefs{DebugLevel}="Admin";
91 $tabsysprefs{SessionStorage}="Admin";
92 $tabsysprefs{noItemTypeImages}="Admin";
93 $tabsysprefs{OPACBaseURL}="Admin";
94 $tabsysprefs{GranularPermissions}="Admin";
97 $tabsysprefs{authoritysep}="Authorities";
98 $tabsysprefs{AuthDisplayHierarchy}="Authorities";
99 $tabsysprefs{dontmerge}="Authorities";
100 $tabsysprefs{BiblioAddsAuthorities}="Authorities";
102 $tabsysprefs{advancedMARCEditor}="Cataloguing";
103 $tabsysprefs{autoBarcode}="Cataloguing";
104 $tabsysprefs{hide_marc}="Cataloguing";
105 $tabsysprefs{IntranetBiblioDefaultView} = "Cataloguing";
106 $tabsysprefs{ISBD}="Cataloguing";
107 $tabsysprefs{itemcallnumber}="Cataloguing";
108 $tabsysprefs{LabelMARCView}="Cataloguing";
109 $tabsysprefs{marc}="Cataloguing";
110 $tabsysprefs{marcflavour}="Cataloguing";
111 $tabsysprefs{MARCOrgCode}="Cataloguing";
112 $tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
113 $tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
114 $tabsysprefs{Stemming}="Cataloguing";
115 $tabsysprefs{WeightFields}="Cataloguing";
116 $tabsysprefs{NoZebra}="Cataloguing";
117 $tabsysprefs{NoZebraIndexes}="Cataloguing";
118 $tabsysprefs{ReceiveBackIssues}="Cataloguing";
119 $tabsysprefs{DefaultClassificationSource}="Cataloguing";
120 $tabsysprefs{RoutingSerials}="Cataloguing";
121 $tabsysprefs{'item-level_itypes'}="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{noOPACHolds}="Circulation";
145 $tabsysprefs{WebBasedSelfCheck}="Circulation";
146 $tabsysprefs{CircControl}="Circulation";
147 $tabsysprefs{finesCalendar}="Circulation";
148 $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
149 $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
150 $tabsysprefs{HomeOrHoldingBranch}="Circulation";
151 $tabsysprefs{RandomizeHoldsQueueWeight}="Circulation";
152 $tabsysprefs{StaticHoldsQueueWeight}="Circulation";
153 $tabsysprefs{AllowOnShelfHolds}="Circulation";
154 $tabsysprefs{AllowHoldsOnDamagedItems}="Circulation";
157 $tabsysprefs{TemplateEncoding}="StaffClient";
158 $tabsysprefs{template}="StaffClient";
159 $tabsysprefs{intranetstylesheet}="StaffClient";
160 $tabsysprefs{IntranetNav}="StaffClient";
161 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
162 $tabsysprefs{intranetuserjs}="StaffClient";
163 $tabsysprefs{yuipath}="StaffClient";
164 $tabsysprefs{IntranetmainUserblock}="StaffClient";
167 $tabsysprefs{autoMemberNum}="Patrons";
168 $tabsysprefs{checkdigit}="Patrons";
169 $tabsysprefs{intranetreadinghistory}="Patrons";
170 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
171 $tabsysprefs{memberofinstitution}="Patrons";
172 $tabsysprefs{ReadingHistory}="Patrons";
173 $tabsysprefs{BorrowerMandatoryField}="Patrons";
174 $tabsysprefs{borrowerRelationship}="Patrons";
175 $tabsysprefs{BorrowersTitles}="Patrons";
176 $tabsysprefs{patronimages}="Patrons";
177 $tabsysprefs{MinPasswordLength}="Patrons";
178 $tabsysprefs{uppercasesurnames}="Patrons";
179 $tabsysprefs{NoReturnSetLost}="Patrons";
180 $tabsysprefs{MaxFine}="Patrons";
181 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
182 $tabsysprefs{AddPatronLists}="Patrons";
183 $tabsysprefs{PatronsPerPage}="Patrons";
184 $tabsysprefs{ExtendedPatronAttributes}="Patrons";
185 $tabsysprefs{AutoEmailOpacUser}="Patrons";
186 $tabsysprefs{AutoEmailPrimaryAddress}="Patrons";
187 $tabsysprefs{EnhancedMessagingPreferences}="Patrons";
190 $tabsysprefs{dateformat}="I18N/L10N";
191 $tabsysprefs{opaclanguages}="I18N/L10N";
192 $tabsysprefs{opacthemes}="I18N/L10N";
193 $tabsysprefs{language}="I18N/L10N";
196 $tabsysprefs{defaultSortField}="Searching";
197 $tabsysprefs{defaultSortOrder}="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";
210 $tabsysprefs{AdvancedSearchTypes}="Searching";
213 $tabsysprefs{AmazonContent}="EnhancedContent";
214 $tabsysprefs{AWSAccessKeyID}="EnhancedContent";
215 $tabsysprefs{AmazonLocale}="EnhancedContent";
216 $tabsysprefs{AmazonAssocTag}="EnhancedContent";
217 $tabsysprefs{AmazonSimilarItems}="EnhancedContent";
218 $tabsysprefs{OPACAmazonContent}="EnhancedContent";
219 $tabsysprefs{OPACAmazonSimilarItems}="EnhancedContent";
222 $tabsysprefs{BakerTaylorBookstoreURL} = 'EnhancedContent';
223 $tabsysprefs{BakerTaylorEnabled} = 'EnhancedContent';
224 $tabsysprefs{BakerTaylorPassword} = 'EnhancedContent';
225 $tabsysprefs{BakerTaylorUsername} = 'EnhancedContent';
227 $tabsysprefs{FRBRizeEditions}="EnhancedContent";
228 $tabsysprefs{XISBN}="EnhancedContent";
229 $tabsysprefs{OCLCAffiliateID}="EnhancedContent";
230 $tabsysprefs{XISBNDailyLimit}="EnhancedContent";
231 $tabsysprefs{PINESISBN}="EnhancedContent";
232 $tabsysprefs{ThingISBN}="EnhancedContent";
233 $tabsysprefs{OPACFRBRizeEditions}="EnhancedContent";
235 $tabsysprefs{TagsEnabled} = 'EnhancedContent';
236 $tabsysprefs{TagsExternalDictionary} = 'EnhancedContent';
237 $tabsysprefs{TagsInputOnDetail} = 'EnhancedContent';
238 $tabsysprefs{TagsInputOnList} = 'EnhancedContent';
239 $tabsysprefs{TagsShowOnDetail} = 'EnhancedContent';
240 $tabsysprefs{TagsShowOnList} = 'EnhancedContent';
241 $tabsysprefs{TagsModeration} = 'EnhancedContent';
242 $tabsysprefs{GoogleJackets} = 'EnhancedContent';
243 $tabsysprefs{AuthorisedValueImages} = "EnhancedContent";
246 $tabsysprefs{BiblioDefaultView}="OPAC";
247 $tabsysprefs{LibraryName}="OPAC";
248 $tabsysprefs{opaccolorstylesheet}="OPAC";
249 $tabsysprefs{opaccredits}="OPAC";
250 $tabsysprefs{opaclayoutstylesheet}="OPAC";
251 $tabsysprefs{OpacNav}="OPAC";
252 $tabsysprefs{opacsmallimage}="OPAC";
253 $tabsysprefs{opacstylesheet}="OPAC";
254 $tabsysprefs{opacthemes}="OPAC";
255 $tabsysprefs{opacuserjs}="OPAC";
256 $tabsysprefs{SubscriptionHistory}="OPAC";
257 $tabsysprefs{opacheader}="OPAC";
258 $tabsysprefs{noOPACUserLogin}="OPAC";
259 $tabsysprefs{hideBiblioNumber}="OPAC";
260 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
261 $tabsysprefs{OpacMainUserBlock}="OPAC";
262 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
263 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
264 $tabsysprefs{OPACUserCSS}="OPAC";
265 $tabsysprefs{OPACHighlightedWords}="OPAC";
266 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
267 $tabsysprefs{URLLinkText}="OPAC";
268 $tabsysprefs{OPACShelfBrowser}="OPAC";
271 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
272 $tabsysprefs{Disable_Dictionary}="OPAC";
273 $tabsysprefs{hidelostitems}="OPAC";
274 $tabsysprefs{opacbookbag}="OPAC";
275 $tabsysprefs{opaclanguagesdisplay}="OPAC";
276 $tabsysprefs{OpacPasswordChange}="OPAC";
277 $tabsysprefs{opacreadinghistory}="OPAC";
278 $tabsysprefs{virtualshelves}="OPAC";
279 $tabsysprefs{RequestOnOpac}="OPAC";
280 $tabsysprefs{reviewson}="OPAC";
281 $tabsysprefs{OpacTopissues}="OPAC";
282 $tabsysprefs{OpacAuthorities}="OPAC";
283 $tabsysprefs{OpacCloud}="OPAC";
284 $tabsysprefs{opacuserlogin}="OPAC";
285 $tabsysprefs{AnonSuggestions}="OPAC";
286 $tabsysprefs{suggestion}="OPAC";
287 $tabsysprefs{OpacTopissue}="OPAC";
288 $tabsysprefs{OpacBrowser}="OPAC";
289 $tabsysprefs{kohaspsuggest} = "OPAC";
290 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
291 $tabsysprefs{OPACItemHolds} = "OPAC";
292 $tabsysprefs{OPACGroupResults}="OPAC";
293 $tabsysprefs{XSLTDetailsDisplay}="OPAC";
294 $tabsysprefs{XSLTResultsDisplay}="OPAC";
297 $tabsysprefs{CataloguingLog} = "Logs";
298 $tabsysprefs{BorrowersLog} = "Logs";
299 $tabsysprefs{SubscriptionLog} = "Logs";
300 $tabsysprefs{IssueLog} = "Logs";
301 $tabsysprefs{ReturnLog} = "Logs";
302 $tabsysprefs{LetterLog} = "Logs";
303 $tabsysprefs{FinesLog} = "Logs";
306 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
307 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
308 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
309 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
310 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
313 my ($searchstring,$type)=@_;
314 my $dbh = C4::Context->dbh;
315 $searchstring=~ s/\'/\\\'/g;
316 my @data=split(' ',$searchstring);
321 # used for doing a plain-old sys-pref search
322 if ($type eq 'all' ){
323 my $sth=$dbh->prepare("SELECT * FROM systempreferences
324 WHERE variable LIKE ? OR explanation LIKE ?
326 $sth->execute("%$searchstring%", "%$searchstring%");
327 while (my $data=$sth->fetchrow_hashref){
328 $data->{value} =~ s/</</g;
329 $data->{value} =~ s/>/>/g;
330 $data->{value}=substr($data->{value},0,60)."..." if length($data->{value}) >60;
331 push(@results,$data);
337 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
338 if ($tabsysprefs{$syspref} eq $type){
339 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
340 $sth->execute($syspref);
341 while (my $data=$sth->fetchrow_hashref){
342 $data->{value} =~ s/</</g;
343 $data->{value} =~ s/>/>/g;
344 $data->{value}=substr($data->{value},0,60)."..." if length($data->{value}) >60;
345 push(@results,$data);
352 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
353 foreach my $syspref (keys %tabsysprefs){
354 $strsth .= $dbh->quote($syspref).",";
357 $strsth .= " order by variable";
358 my $sth=$dbh->prepare($strsth);
360 while (my $data=$sth->fetchrow_hashref){
361 $data->{value}=substr($data->{value},0,60);
362 push(@results,$data);
367 return ($cnt,\@results);
371 my $searchfield = $input->param('searchfield');
372 my $Tvalue = $input->param('Tvalue');
373 my $offset = $input->param('offset');
374 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
376 my ($template, $borrowernumber, $cookie)
377 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
380 authnotrequired => 0,
381 flagsrequired => {parameters => 1},
385 my $op = $input->param('op');
386 $searchfield=~ s/\,//g;
389 $template->param(script_name => $script_name,
390 $op => 1); # we show only the TMPL_VAR names $op
392 $template->param(script_name => $script_name,
393 else => 1); # we show only the TMPL_VAR names $op
396 if ($op eq 'update_and_reedit') {
397 foreach ($input->param) {
400 if (my $currentorder=$input->param('currentorder')) {
401 my @currentorder=split /\|/, $currentorder;
403 foreach my $param ($input->param) {
404 if ($param=~m#up-(\d+).x#) {
405 my $temp=$currentorder[$1];
406 $currentorder[$1]=$currentorder[$1-1];
407 $currentorder[$1-1]=$temp;
410 } elsif ($param=~m#down-(\d+).x#) {
411 my $temp=$currentorder[$1];
412 $currentorder[$1]=$currentorder[$1+1];
413 $currentorder[$1+1]=$temp;
418 $value=join ' ', @currentorder;
421 $template->param(script_name => $script_name,
422 $op => 1); # we show only the TMPL_VAR names $op
426 $template->param(script_name => $script_name,
427 else => 1); # we show only the TMPL_VAR names $op
430 my $dbh = C4::Context->dbh;
431 my $query="select * from systempreferences where variable=?";
432 my $sth=$dbh->prepare($query);
433 $sth->execute($input->param('variable'));
435 unless (C4::Context->config('demo') eq 1) {
436 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
437 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
439 warn "logaction !! mod ";
440 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
443 unless (C4::Context->config('demo') eq 1) {
444 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
445 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
447 warn "logaction !! add ";
448 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
455 ################## ADD_FORM ##################################
456 # called by default. Used to create form to add or modify a record
458 if ($op eq 'add_form') {
459 #---- if primkey exists, it's a modify action, so read values to modify...
462 my $dbh = C4::Context->dbh;
463 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
464 $sth->execute($searchfield);
465 $data=$sth->fetchrow_hashref;
467 $template->param(modify => 1);
468 # save tab to return to if user cancels edit
469 $template->param(return_tab => $tabsysprefs{$searchfield});
473 foreach my $option (split(/\|/, $data->{'options'})) {
475 $option eq $data->{'value'} and $selected=1;
476 push @options, { option => $option, selected => $selected };
478 if ($data->{'type'} eq 'Choice') {
479 $template->param('type-choice' => 1);
480 } elsif ($data->{'type'} eq 'YesNo') {
481 $template->param('type-yesno' => 1);
482 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
483 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
484 } elsif ($data->{'type'} eq 'Integer') {
485 $template->param('type-free' => 1);
486 $template->param('fieldlength' => $data->{'options'});
487 } elsif ($data->{'type'} eq 'Textarea') {
488 $template->param('type-textarea' => 1);
489 $data->{options} =~ /(.*)\|(.*)/;
490 $template->param('cols' => $1, 'rows' => $2);;
491 } elsif ($data->{'type'} eq 'Float') {
492 $template->param('type-free' => 1);
493 $template->param('fieldlength' => $data->{'options'});
494 } elsif ($data->{'type'} eq 'Themes') {
495 $template->param('type-choice' => 1);
497 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
499 my $currently_selected_themes;
501 foreach my $theme (split /\s+/, $data->{'value'}) {
502 push @options, { option => $theme, counter => $counter };
503 $currently_selected_themes->{$theme}=1;
506 foreach my $theme (getallthemes($type)) {
508 next if $currently_selected_themes->{$theme};
509 push @options, { option => $theme, counter => $counter };
512 } elsif ($data->{'type'} eq 'ClassSources') {
513 $template->param('type-choice' => 1);
516 my $sources = GetClassSources();
518 foreach my $cn_source (sort keys %$sources) {
519 if ($cn_source eq $data->{'value'}) {
520 push @options, { option => $cn_source, counter => $counter, selected => 1 };
522 push @options, { option => $cn_source, counter => $counter };
526 } elsif ($data->{'type'} eq 'Languages') {
527 my $currently_selected_languages;
528 foreach my $language (split /\s+/, $data->{'value'}) {
529 $currently_selected_languages->{$language}=1;
532 my $lang = $template->param('lang');
535 if ($data->{'variable'} =~ /opac/) {
538 $theme = C4::Context->preference('opacthemes');
541 # this is the staff client
542 $interface = 'intranet';
543 $theme = C4::Context->preference('template');
545 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
547 $template->param('languages_loop' => $languages_loop);
548 $template->param('type-langselector' => 1);
550 $template->param('type-free' => 1);
551 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
553 $template->param(explanation => $data->{'explanation'},
554 value => $data->{'value'},
555 type => $data->{'type'},
556 options => \@options,
557 preftype => $data->{'type'},
558 prefoptions => $data->{'options'},
559 searchfield => $searchfield);
561 ################## ADD_VALIDATE ##################################
562 # called by add_form, used to insert/modify data in DB
563 } elsif ($op eq 'add_validate') {
564 my $dbh = C4::Context->dbh;
565 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
566 $sth->execute($input->param('variable'));
567 # to handle multiple values
569 # handle multiple value strings (separated by ',')
570 my $params = $input->Vars;
571 my @values = split("\0",$params->{'value'}) if $params->{'value'};
572 for my $vl (@values) {
577 unless (C4::Context->config('demo') eq 1) {
578 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
579 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
581 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
584 unless (C4::Context->config('demo') eq 1) {
585 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
586 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
588 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
592 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
594 ################## DELETE_CONFIRM ##################################
595 # called by default form, used to confirm deletion of data in DB
596 } elsif ($op eq 'delete_confirm') {
597 my $dbh = C4::Context->dbh;
598 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
599 $sth->execute($searchfield);
600 my $data=$sth->fetchrow_hashref;
602 $template->param(searchfield => $searchfield,
603 Tvalue => $data->{'value'},
606 # END $OP eq DELETE_CONFIRM
607 ################## DELETE_CONFIRMED ##################################
608 # called by delete_confirm, used to effectively confirm deletion of data in DB
609 } elsif ($op eq 'delete_confirmed') {
610 my $dbh = C4::Context->dbh;
611 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
612 $sth->execute($searchfield);
613 my $logstring = $searchfield . " | " . $Tvalue ;
614 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
617 # END $OP eq DELETE_CONFIRMED
618 ################## DEFAULT ##################################
620 #Adding tab management for system preferences
621 my $tab=$input->param('tab');
622 $template->param($tab => 1);
623 my ($count,$results)=StringSearch($searchfield,$tab);
626 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
632 my %row_data; # get a fresh hash for the row data
633 $row_data{variable} = $results->[$i]{'variable'};
634 $row_data{value} = $results->[$i]{'value'};
635 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
636 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
637 $row_data{explanation} = $results->[$i]{'explanation'};
638 $row_data{toggle} = $toggle;
639 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
640 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
641 push(@loop_data, \%row_data);
643 $tab=($tab?$tab:"Local Use");
644 $template->param(loop => \@loop_data, $tab => 1);
646 my $prevpage = $offset-$pagesize;
647 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
649 if ($offset+$pagesize<$count) {
650 my $nextpage =$offset+$pagesize;
651 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
653 $template->param( tab => $tab,
655 } #---- END $OP eq DEFAULT
656 output_html_with_http_headers $input, $cookie, $template->output;