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";
155 $tabsysprefs{TemplateEncoding}="StaffClient";
156 $tabsysprefs{template}="StaffClient";
157 $tabsysprefs{intranetstylesheet}="StaffClient";
158 $tabsysprefs{IntranetNav}="StaffClient";
159 $tabsysprefs{intranetcolorstylesheet}="StaffClient";
160 $tabsysprefs{intranetuserjs}="StaffClient";
161 $tabsysprefs{yuipath}="StaffClient";
162 $tabsysprefs{IntranetmainUserblock}="StaffClient";
165 $tabsysprefs{autoMemberNum}="Patrons";
166 $tabsysprefs{checkdigit}="Patrons";
167 $tabsysprefs{intranetreadinghistory}="Patrons";
168 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
169 $tabsysprefs{memberofinstitution}="Patrons";
170 $tabsysprefs{ReadingHistory}="Patrons";
171 $tabsysprefs{BorrowerMandatoryField}="Patrons";
172 $tabsysprefs{borrowerRelationship}="Patrons";
173 $tabsysprefs{BorrowersTitles}="Patrons";
174 $tabsysprefs{patronimages}="Patrons";
175 $tabsysprefs{MinPasswordLength}="Patrons";
176 $tabsysprefs{uppercasesurnames}="Patrons";
177 $tabsysprefs{NoReturnSetLost}="Patrons";
178 $tabsysprefs{MaxFine}="Patrons";
179 $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
180 $tabsysprefs{AddPatronLists}="Patrons";
181 $tabsysprefs{PatronsPerPage}="Patrons";
182 $tabsysprefs{ExtendedPatronAttributes}="Patrons";
183 $tabsysprefs{AutoEmailOpacUser}="Patrons";
184 $tabsysprefs{AutoEmailPrimaryAddress}="Patrons";
187 $tabsysprefs{dateformat}="I18N/L10N";
188 $tabsysprefs{opaclanguages}="I18N/L10N";
189 $tabsysprefs{opacthemes}="I18N/L10N";
190 $tabsysprefs{language}="I18N/L10N";
193 $tabsysprefs{defaultSortField}="Searching";
194 $tabsysprefs{defaultSortOrder}="Searching";
195 $tabsysprefs{maxItemsInSearchResults}="Searching";
196 $tabsysprefs{numSearchResults}="Searching";
197 $tabsysprefs{OPACdefaultSortField}="Searching";
198 $tabsysprefs{OPACdefaultSortOrder}="Searching";
199 $tabsysprefs{OPACItemsResultsDisplay}="Searching";
200 $tabsysprefs{OPACnumSearchResults}="Searching";
201 $tabsysprefs{QueryFuzzy}="Searching";
202 $tabsysprefs{QueryStemming}="Searching";
203 $tabsysprefs{QueryWeightFields}="Searching";
204 $tabsysprefs{expandedSearchOption}="Searching";
205 $tabsysprefs{sortbynonfiling}="Searching";
206 $tabsysprefs{QueryAutoTruncate}="Searching";
207 $tabsysprefs{QueryRemoveStopwords}="Searching";
210 $tabsysprefs{AmazonContent}="EnhancedContent";
211 $tabsysprefs{AWSAccessKeyID}="EnhancedContent";
212 $tabsysprefs{AmazonLocale}="EnhancedContent";
213 $tabsysprefs{AmazonAssocTag}="EnhancedContent";
214 $tabsysprefs{AmazonSimilarItems}="EnhancedContent";
215 $tabsysprefs{OPACAmazonContent}="EnhancedContent";
216 $tabsysprefs{OPACAmazonSimilarItems}="EnhancedContent";
218 $tabsysprefs{BakerTaylorBookstoreURL} = 'EnhancedContent';
219 $tabsysprefs{BakerTaylorEnabled} = 'EnhancedContent';
220 $tabsysprefs{BakerTaylorPassword} = 'EnhancedContent';
221 $tabsysprefs{BakerTaylorUsername} = 'EnhancedContent';
223 $tabsysprefs{FRBRizeEditions}="EnhancedContent";
224 $tabsysprefs{XISBN}="EnhancedContent";
225 $tabsysprefs{OCLCAffiliateID}="EnhancedContent";
226 $tabsysprefs{XISBNDailyLimit}="EnhancedContent";
227 $tabsysprefs{PINESISBN}="EnhancedContent";
228 $tabsysprefs{ThingISBN}="EnhancedContent";
229 $tabsysprefs{OPACFRBRizeEditions}="EnhancedContent";
231 $tabsysprefs{TagsEnabled} = 'EnhancedContent';
232 $tabsysprefs{TagsExternalDictionary} = 'EnhancedContent';
233 $tabsysprefs{TagsInputOnDetail} = 'EnhancedContent';
234 $tabsysprefs{TagsInputOnList} = 'EnhancedContent';
235 $tabsysprefs{TagsShowOnDetail} = 'EnhancedContent';
236 $tabsysprefs{TagsShowOnList} = 'EnhancedContent';
237 $tabsysprefs{TagsModeration} = 'EnhancedContent';
238 $tabsysprefs{GoogleJackets} = 'EnhancedContent';
241 $tabsysprefs{BiblioDefaultView}="OPAC";
242 $tabsysprefs{LibraryName}="OPAC";
243 $tabsysprefs{opaccolorstylesheet}="OPAC";
244 $tabsysprefs{opaccredits}="OPAC";
245 $tabsysprefs{opaclargeimage}="OPAC";
246 $tabsysprefs{opaclayoutstylesheet}="OPAC";
247 $tabsysprefs{OpacNav}="OPAC";
248 $tabsysprefs{opacsmallimage}="OPAC";
249 $tabsysprefs{opacstylesheet}="OPAC";
250 $tabsysprefs{opacthemes}="OPAC";
251 $tabsysprefs{opacuserjs}="OPAC";
252 $tabsysprefs{SubscriptionHistory}="OPAC";
253 $tabsysprefs{opacheader}="OPAC";
255 $tabsysprefs{hideBiblioNumber}="OPAC";
256 $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
257 $tabsysprefs{OpacMainUserBlock}="OPAC";
258 $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
259 $tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
260 $tabsysprefs{OPACUserCSS}="OPAC";
261 $tabsysprefs{OPACHighlightedWords}="OPAC";
262 $tabsysprefs{OPACViewOthersSuggestions}="OPAC";
263 $tabsysprefs{URLLinkText}="OPAC";
264 $tabsysprefs{OPACShelfBrowser}="OPAC";
267 $tabsysprefs{SearchMyLibraryFirst}="OPAC";
268 $tabsysprefs{Disable_Dictionary}="OPAC";
269 $tabsysprefs{hidelostitems}="OPAC";
270 $tabsysprefs{opacbookbag}="OPAC";
271 $tabsysprefs{opaclanguagesdisplay}="OPAC";
272 $tabsysprefs{OpacPasswordChange}="OPAC";
273 $tabsysprefs{opacreadinghistory}="OPAC";
274 $tabsysprefs{virtualshelves}="OPAC";
275 $tabsysprefs{RequestOnOpac}="OPAC";
276 $tabsysprefs{reviewson}="OPAC";
277 $tabsysprefs{OpacTopissues}="OPAC";
278 $tabsysprefs{OpacAuthorities}="OPAC";
279 $tabsysprefs{OpacCloud}="OPAC";
280 $tabsysprefs{opacuserlogin}="OPAC";
281 $tabsysprefs{AnonSuggestions}="OPAC";
282 $tabsysprefs{suggestion}="OPAC";
283 $tabsysprefs{OpacTopissue}="OPAC";
284 $tabsysprefs{OpacBrowser}="OPAC";
285 $tabsysprefs{kohaspsuggest} = "OPAC";
286 $tabsysprefs{OpacRenewalAllowed} = "OPAC";
287 $tabsysprefs{OPACItemHolds} = "OPAC";
290 $tabsysprefs{CataloguingLog} = "Logs";
291 $tabsysprefs{BorrowersLog} = "Logs";
292 $tabsysprefs{SubscriptionLog} = "Logs";
293 $tabsysprefs{IssueLog} = "Logs";
294 $tabsysprefs{ReturnLog} = "Logs";
295 $tabsysprefs{LetterLog} = "Logs";
296 $tabsysprefs{FinesLog} = "Logs";
299 $tabsysprefs{'OAI-PMH'} = "OAI-PMH";
300 $tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
301 $tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
302 $tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
303 $tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
306 my ($searchstring,$type)=@_;
307 my $dbh = C4::Context->dbh;
308 $searchstring=~ s/\'/\\\'/g;
309 my @data=split(' ',$searchstring);
314 # used for doing a plain-old sys-pref search
315 if ($type eq 'all' ){
316 my $sth=$dbh->prepare("SELECT * FROM systempreferences
317 WHERE variable LIKE ? OR explanation LIKE ?
319 $sth->execute("%$searchstring%", "%$searchstring%");
320 while (my $data=$sth->fetchrow_hashref){
321 $data->{value} =~ s/</</g;
322 $data->{value} =~ s/>/>/g;
323 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
324 push(@results,$data);
330 foreach my $syspref (sort { lc $a cmp lc $b } keys %tabsysprefs){
331 if ($tabsysprefs{$syspref} eq $type){
332 my $sth=$dbh->prepare("Select variable,value,explanation,type,options from systempreferences where (variable like ?) order by variable");
333 $sth->execute($syspref);
334 while (my $data=$sth->fetchrow_hashref){
335 $data->{value} =~ s/</</g;
336 $data->{value} =~ s/>/>/g;
337 $data->{value}=substr($data->{value},0,100)."..." if length($data->{value}) >100;
338 push(@results,$data);
345 my $strsth ="Select variable,value,explanation,type,options from systempreferences where variable not in (";
346 foreach my $syspref (keys %tabsysprefs){
347 $strsth .= $dbh->quote($syspref).",";
350 $strsth .= " order by variable";
351 my $sth=$dbh->prepare($strsth);
353 while (my $data=$sth->fetchrow_hashref){
354 $data->{value}=substr($data->{value},0,100);
355 push(@results,$data);
360 return ($cnt,\@results);
364 my $searchfield = $input->param('searchfield');
365 my $Tvalue = $input->param('Tvalue');
366 my $offset = $input->param('offset');
367 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
369 my ($template, $borrowernumber, $cookie)
370 = get_template_and_user({template_name => "admin/systempreferences.tmpl",
373 authnotrequired => 0,
374 flagsrequired => {parameters => 1},
378 my $op = $input->param('op');
379 $searchfield=~ s/\,//g;
382 $template->param(script_name => $script_name,
383 $op => 1); # we show only the TMPL_VAR names $op
385 $template->param(script_name => $script_name,
386 else => 1); # we show only the TMPL_VAR names $op
389 if ($op eq 'update_and_reedit') {
390 foreach ($input->param) {
393 if (my $currentorder=$input->param('currentorder')) {
394 my @currentorder=split /\|/, $currentorder;
396 foreach my $param ($input->param) {
397 if ($param=~m#up-(\d+).x#) {
398 my $temp=$currentorder[$1];
399 $currentorder[$1]=$currentorder[$1-1];
400 $currentorder[$1-1]=$temp;
403 } elsif ($param=~m#down-(\d+).x#) {
404 my $temp=$currentorder[$1];
405 $currentorder[$1]=$currentorder[$1+1];
406 $currentorder[$1+1]=$temp;
411 $value=join ' ', @currentorder;
414 $template->param(script_name => $script_name,
415 $op => 1); # we show only the TMPL_VAR names $op
419 $template->param(script_name => $script_name,
420 else => 1); # we show only the TMPL_VAR names $op
423 my $dbh = C4::Context->dbh;
424 my $query="select * from systempreferences where variable=?";
425 my $sth=$dbh->prepare($query);
426 $sth->execute($input->param('variable'));
428 unless (C4::Context->config('demo') eq 1) {
429 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
430 $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
432 warn "logaction !! mod ";
433 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
436 unless (C4::Context->config('demo') eq 1) {
437 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
438 $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
440 warn "logaction !! add ";
441 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
448 ################## ADD_FORM ##################################
449 # called by default. Used to create form to add or modify a record
451 if ($op eq 'add_form') {
452 #---- if primkey exists, it's a modify action, so read values to modify...
455 my $dbh = C4::Context->dbh;
456 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
457 $sth->execute($searchfield);
458 $data=$sth->fetchrow_hashref;
460 $template->param(modify => 1);
461 # save tab to return to if user cancels edit
462 $template->param(return_tab => $tabsysprefs{$searchfield});
466 foreach my $option (split(/\|/, $data->{'options'})) {
468 $option eq $data->{'value'} and $selected=1;
469 push @options, { option => $option, selected => $selected };
471 if ($data->{'type'} eq 'Choice') {
472 $template->param('type-choice' => 1);
473 } elsif ($data->{'type'} eq 'YesNo') {
474 $template->param('type-yesno' => 1);
475 $data->{'value'}=C4::Context->boolean_preference($data->{'variable'});
476 ($data->{'value'} eq '1') ? ($template->param('value-yes'=>1)) : ($template->param('value-no'=>1));
477 } elsif ($data->{'type'} eq 'Integer') {
478 $template->param('type-free' => 1);
479 $template->param('fieldlength' => $data->{'options'});
480 } elsif ($data->{'type'} eq 'Textarea') {
481 $template->param('type-textarea' => 1);
482 $data->{options} =~ /(.*)\|(.*)/;
483 $template->param('cols' => $1, 'rows' => $2);;
484 } elsif ($data->{'type'} eq 'Float') {
485 $template->param('type-free' => 1);
486 $template->param('fieldlength' => $data->{'options'});
487 } elsif ($data->{'type'} eq 'Themes') {
488 $template->param('type-choice' => 1);
490 ($data->{'variable'}=~m#opac#i) ? ($type='opac') : ($type='intranet');
492 my $currently_selected_themes;
494 foreach my $theme (split /\s+/, $data->{'value'}) {
495 push @options, { option => $theme, counter => $counter };
496 $currently_selected_themes->{$theme}=1;
499 foreach my $theme (getallthemes($type)) {
501 next if $currently_selected_themes->{$theme};
502 push @options, { option => $theme, counter => $counter };
505 } elsif ($data->{'type'} eq 'ClassSources') {
506 $template->param('type-choice' => 1);
509 my $sources = GetClassSources();
511 foreach my $cn_source (sort keys %$sources) {
512 if ($cn_source eq $data->{'value'}) {
513 push @options, { option => $cn_source, counter => $counter, selected => 1 };
515 push @options, { option => $cn_source, counter => $counter };
519 } elsif ($data->{'type'} eq 'Languages') {
520 my $currently_selected_languages;
521 foreach my $language (split /\s+/, $data->{'value'}) {
522 $currently_selected_languages->{$language}=1;
525 my $lang = $template->param('lang');
528 if ($data->{'variable'} =~ /opac/) {
531 $theme = C4::Context->preference('opacthemes');
534 # this is the staff client
535 $interface = 'intranet';
536 $theme = C4::Context->preference('template');
538 my $languages_loop = getTranslatedLanguages($interface,$theme,$lang,$currently_selected_languages);
540 $template->param('languages_loop' => $languages_loop);
541 $template->param('type-langselector' => 1);
543 $template->param('type-free' => 1);
544 $template->param('fieldlength' => $data->{'options'}>0?$data->{'options'}:60);
546 $template->param(explanation => $data->{'explanation'},
547 value => $data->{'value'},
548 type => $data->{'type'},
549 options => \@options,
550 preftype => $data->{'type'},
551 prefoptions => $data->{'options'},
552 searchfield => $searchfield);
554 ################## ADD_VALIDATE ##################################
555 # called by add_form, used to insert/modify data in DB
556 } elsif ($op eq 'add_validate') {
557 my $dbh = C4::Context->dbh;
558 my $sth=$dbh->prepare("select * from systempreferences where variable=?");
559 $sth->execute($input->param('variable'));
560 # to handle multiple values
562 # handle multiple value strings (separated by ',')
563 my $params = $input->Vars;
564 my @values = split("\0",$params->{'value'}) if $params->{'value'};
565 for my $vl (@values) {
570 unless (C4::Context->config('demo') eq 1) {
571 my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
572 $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
574 logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
577 unless (C4::Context->config('demo') eq 1) {
578 my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
579 $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
581 logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
585 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=".$tabsysprefs{$input->param('variable')}."\"></html>";
587 ################## DELETE_CONFIRM ##################################
588 # called by default form, used to confirm deletion of data in DB
589 } elsif ($op eq 'delete_confirm') {
590 my $dbh = C4::Context->dbh;
591 my $sth=$dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?");
592 $sth->execute($searchfield);
593 my $data=$sth->fetchrow_hashref;
595 $template->param(searchfield => $searchfield,
596 Tvalue => $data->{'value'},
599 # END $OP eq DELETE_CONFIRM
600 ################## DELETE_CONFIRMED ##################################
601 # called by delete_confirm, used to effectively confirm deletion of data in DB
602 } elsif ($op eq 'delete_confirmed') {
603 my $dbh = C4::Context->dbh;
604 my $sth=$dbh->prepare("delete from systempreferences where variable=?");
605 $sth->execute($searchfield);
606 my $logstring = $searchfield . " | " . $Tvalue ;
607 logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
610 # END $OP eq DELETE_CONFIRMED
611 ################## DEFAULT ##################################
613 #Adding tab management for system preferences
614 my $tab=$input->param('tab');
615 $template->param($tab => 1);
616 my ($count,$results)=StringSearch($searchfield,$tab);
619 for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
625 my %row_data; # get a fresh hash for the row data
626 $row_data{variable} = $results->[$i]{'variable'};
627 $row_data{value} = $results->[$i]{'value'};
628 $row_data{yes} = 1 if ($results->[$i]{'value'} == 1);
629 $row_data{yesno} = 1 if ($results->[$i]{'type'} eq 'YesNo');
630 $row_data{explanation} = $results->[$i]{'explanation'};
631 $row_data{toggle} = $toggle;
632 $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'variable'};
633 $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'variable'};
634 push(@loop_data, \%row_data);
636 $tab=($tab?$tab:"Local Use");
637 $template->param(loop => \@loop_data, $tab => 1);
639 my $prevpage = $offset-$pagesize;
640 $template->param("<a href=$script_name?offset=".$prevpage.'<< Prev</a>');
642 if ($offset+$pagesize<$count) {
643 my $nextpage =$offset+$pagesize;
644 $template->param("a href=$script_name?offset=".$nextpage.'Next >></a>');
646 $template->param( tab => $tab,
648 } #---- END $OP eq DEFAULT
649 output_html_with_http_headers $input, $cookie, $template->output;