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";
187 $tabsysprefs{'SMSSendDriver'} = '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{hidelostitems}="OPAC";
273 $tabsysprefs{opacbookbag}="OPAC";
274 $tabsysprefs{opaclanguagesdisplay}="OPAC";
275 $tabsysprefs{OpacPasswordChange}="OPAC";
276 $tabsysprefs{opacreadinghistory}="OPAC";
277 $tabsysprefs{virtualshelves}="OPAC";
278 $tabsysprefs{RequestOnOpac}="OPAC";
279 $tabsysprefs{reviewson}="OPAC";
280 $tabsysprefs{OpacTopissues}="OPAC";
281 $tabsysprefs{OpacAuthorities}="OPAC";
282 $tabsysprefs{OpacCloud}="OPAC";
283 $tabsysprefs{opacuserlogin}="OPAC";
284 $tabsysprefs{AnonSuggestions}="OPAC";
285 $tabsysprefs{suggestion}="OPAC";
286 $tabsysprefs{OpacTopissue}="OPAC";
287 $tabsysprefs{OpacBrowser}="OPAC";
288 $tabsysprefs{kohaspsuggest} = "OPAC";
289 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
290 $tabsysprefs{OPACItemHolds} = "OPAC";
291 $tabsysprefs{OPACGroupResults}="OPAC";
292 $tabsysprefs{XSLTDetailsDisplay}="OPAC";
293 $tabsysprefs{XSLTResultsDisplay}="OPAC";
296 $tabsysprefs{CataloguingLog} = "Logs";
297 $tabsysprefs{BorrowersLog} = "Logs";
298 $tabsysprefs{SubscriptionLog} = "Logs";
299 $tabsysprefs{IssueLog} = "Logs";
300 $tabsysprefs{ReturnLog} = "Logs";
301 $tabsysprefs{LetterLog} = "Logs";
302 $tabsysprefs{FinesLog} = "Logs";
305 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
306 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
307 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
308 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
309 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
312 my ($searchstring,$type)=@_;
313 my $dbh = C4::Context->dbh;
314 $searchstring=~ s/\'/\\\'/g;
315 my @data=split(' ',$searchstring);
320 # used for doing a plain-old sys-pref search
321 if ($type eq 'all' ){
322 my $sth=$dbh->prepare("SELECT * FROM systempreferences
323 WHERE variable LIKE ? OR explanation LIKE ?
325 $sth->execute("%$searchstring%", "%$searchstring%");
326 while (my $data=$sth->fetchrow_hashref){
327 $data->{value} =~ s/</</g;
328 $data->{value} =~ s/>/>/g;
329 $data->{value}=substr($data->{value},0,60)."..." if length($data->{value}) >60;
330 push(@results,$data);
336 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
337 if ($tabsysprefs{$syspref} eq $type){
338 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
339 $sth->execute($syspref);
340 while (my $data=$sth->fetchrow_hashref){
341 $data->{value} =~ s/</</g;
342 $data->{value} =~ s/>/>/g;
343 $data->{value}=substr($data->{value},0,60)."..." if length($data->{value}) >60;
344 push(@results,$data);
351 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
352 foreach my $syspref (keys %tabsysprefs){
353 $strsth .= $dbh->quote($syspref).",";
356 $strsth .= " order by variable";
357 my $sth=$dbh->prepare($strsth);
359 while (my $data=$sth->fetchrow_hashref){
360 $data->{value}=substr($data->{value},0,60);
361 push(@results,$data);
366 return ($cnt,\@results);
370 my $searchfield = $input->param('searchfield');
371 my $Tvalue = $input->param('Tvalue');
372 my $offset = $input->param('offset');
373 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
375 my ($template, $borrowernumber, $cookie)
376 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
379 authnotrequired => 0,
380 flagsrequired => {parameters => 1},
384 my $op = $input->param('op');
385 $searchfield=~ s/\,//g;
388 $template->param(script_name => $script_name,
389 $op => 1); # we show only the TMPL_VAR names $op
391 $template->param(script_name => $script_name,
392 else => 1); # we show only the TMPL_VAR names $op
395 if ($op eq 'update_and_reedit') {
396 foreach ($input->param) {
399 if (my $currentorder=$input->param('currentorder')) {
400 my @currentorder=split /\|/, $currentorder;
402 foreach my $param ($input->param) {
403 if ($param=~m#up-(\d+).x#) {
404 my $temp=$currentorder[$1];
405 $currentorder[$1]=$currentorder[$1-1];
406 $currentorder[$1-1]=$temp;
409 } elsif ($param=~m#down-(\d+).x#) {
410 my $temp=$currentorder[$1];
411 $currentorder[$1]=$currentorder[$1+1];
412 $currentorder[$1+1]=$temp;
417 $value=join ' ', @currentorder;
420 $template->param(script_name => $script_name,
421 $op => 1); # we show only the TMPL_VAR names $op
425 $template->param(script_name => $script_name,
426 else => 1); # we show only the TMPL_VAR names $op
429 my $dbh = C4::Context->dbh;
430 my $query="select * from systempreferences where variable=?";
431 my $sth=$dbh->prepare($query);
432 $sth->execute($input->param('variable'));
434 unless (C4::Context->config('demo') eq 1) {
435 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
436 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
438 warn "logaction !! mod ";
439 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
442 unless (C4::Context->config('demo') eq 1) {
443 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
444 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
446 warn "logaction !! add ";
447 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
454 ################## ADD_FORM ##################################
455 # called by default. Used to create form to add or modify a record
457 if ($op eq 'add_form') {
458 #---- if primkey exists, it's a modify action, so read values to modify...
461 my $dbh = C4::Context->dbh;
462 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
463 $sth->execute($searchfield);
464 $data=$sth->fetchrow_hashref;
466 $template->param(modify => 1);
467 # save tab to return to if user cancels edit
468 $template->param(return_tab => $tabsysprefs{$searchfield});
472 foreach my $option (split(/\|/, $data->{'options'})) {
474 $option eq $data->{'value'} and $selected=1;
475 push @options, { option => $option, selected => $selected };
477 if ($data->{'type'} eq 'Choice') {
478 $template->param('type-choice' => 1);
479 } elsif ($data->{'type'} eq 'YesNo') {
480 $template->param('type-yesno' => 1);
481 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
482 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
483 } elsif ($data->{'type'} eq 'Integer') {
484 $template->param('type-free' => 1);
485 $template->param('fieldlength' => $data->{'options'});
486 } elsif ($data->{'type'} eq 'Textarea') {
487 $template->param('type-textarea' => 1);
488 $data->{options} =~ /(.*)\|(.*)/;
489 $template->param('cols' => $1, 'rows' => $2);;
490 } elsif ($data->{'type'} eq 'Float') {
491 $template->param('type-free' => 1);
492 $template->param('fieldlength' => $data->{'options'});
493 } elsif ($data->{'type'} eq 'Themes') {
494 $template->param('type-choice' => 1);
496 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
498 my $currently_selected_themes;
500 foreach my $theme (split /\s+/, $data->{'value'}) {
501 push @options, { option => $theme, counter => $counter };
502 $currently_selected_themes->{$theme}=1;
505 foreach my $theme (getallthemes($type)) {
507 next if $currently_selected_themes->{$theme};
508 push @options, { option => $theme, counter => $counter };
511 } elsif ($data->{'type'} eq 'ClassSources') {
512 $template->param('type-choice' => 1);
515 my $sources = GetClassSources();
517 foreach my $cn_source (sort keys %$sources) {
518 if ($cn_source eq $data->{'value'}) {
519 push @options, { option => $cn_source, counter => $counter, selected => 1 };
521 push @options, { option => $cn_source, counter => $counter };
525 } elsif ($data->{'type'} eq 'Languages') {
526 my $currently_selected_languages;
527 foreach my $language (split /\s+/, $data->{'value'}) {
528 $currently_selected_languages->{$language}=1;
531 my $lang = $template->param('lang');
534 if ($data->{'variable'} =~ /opac/) {
537 $theme = C4::Context->preference('opacthemes');
540 # this is the staff client
541 $interface = 'intranet';
542 $theme = C4::Context->preference('template');
544 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
546 $template->param('languages_loop' => $languages_loop);
547 $template->param('type-langselector' => 1);
549 $template->param('type-free' => 1);
550 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
552 $template->param(explanation => $data->{'explanation'},
553 value => $data->{'value'},
554 type => $data->{'type'},
555 options => \@options,
556 preftype => $data->{'type'},
557 prefoptions => $data->{'options'},
558 searchfield => $searchfield);
560 ################## ADD_VALIDATE ##################################
561 # called by add_form, used to insert/modify data in DB
562 } elsif ($op eq 'add_validate') {
563 my $dbh = C4::Context->dbh;
564 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
565 $sth->execute($input->param('variable'));
566 # to handle multiple values
568 # handle multiple value strings (separated by ',')
569 my $params = $input->Vars;
570 my @values = split("\0",$params->{'value'}) if $params->{'value'};
571 for my $vl (@values) {
576 unless (C4::Context->config('demo') eq 1) {
577 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
578 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
580 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
583 unless (C4::Context->config('demo') eq 1) {
584 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
585 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
587 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
591 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
593 ################## DELETE_CONFIRM ##################################
594 # called by default form, used to confirm deletion of data in DB
595 } elsif ($op eq 'delete_confirm') {
596 my $dbh = C4::Context->dbh;
597 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
598 $sth->execute($searchfield);
599 my $data=$sth->fetchrow_hashref;
601 $template->param(searchfield => $searchfield,
602 Tvalue => $data->{'value'},
605 # END $OP eq DELETE_CONFIRM
606 ################## DELETE_CONFIRMED ##################################
607 # called by delete_confirm, used to effectively confirm deletion of data in DB
608 } elsif ($op eq 'delete_confirmed') {
609 my $dbh = C4::Context->dbh;
610 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
611 $sth->execute($searchfield);
612 my $logstring = $searchfield . " | " . $Tvalue ;
613 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
616 # END $OP eq DELETE_CONFIRMED
617 ################## DEFAULT ##################################
619 #Adding tab management for system preferences
620 my $tab=$input->param('tab');
621 $template->param($tab => 1);
622 my ($count,$results)=StringSearch($searchfield,$tab);
625 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
631 my %row_data; # get a fresh hash for the row data
632 $row_data{variable} = $results->[$i]{'variable'};
633 $row_data{value} = $results->[$i]{'value'};
634 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
635 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
636 $row_data{explanation} = $results->[$i]{'explanation'};
637 $row_data{toggle} = $toggle;
638 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
639 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
640 push(@loop_data, \%row_data);
642 $tab=($tab?$tab:"Local Use");
643 $template->param(loop => \@loop_data, $tab => 1);
645 my $prevpage = $offset-$pagesize;
646 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
648 if ($offset+$pagesize<$count) {
649 my $nextpage =$offset+$pagesize;
650 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
652 $template->param( tab => $tab,
654 } #---- END $OP eq DEFAULT
655 output_html_with_http_headers $input, $cookie, $template->output;