Lines 50-56
use C4::Context;
Link Here
|
50 |
use C4::Koha; |
50 |
use C4::Koha; |
51 |
use C4::Languages qw(getTranslatedLanguages); |
51 |
use C4::Languages qw(getTranslatedLanguages); |
52 |
use C4::ClassSource; |
52 |
use C4::ClassSource; |
53 |
use C4::Log; |
|
|
54 |
use C4::Output; |
53 |
use C4::Output; |
55 |
use YAML::Syck qw( Dump LoadFile ); |
54 |
use YAML::Syck qw( Dump LoadFile ); |
56 |
|
55 |
|
Lines 269-292
if ( $op eq 'update_and_reedit' ) {
Link Here
|
269 |
); # we show only the TMPL_VAR names $op |
268 |
); # we show only the TMPL_VAR names $op |
270 |
} |
269 |
} |
271 |
} |
270 |
} |
272 |
my $dbh = C4::Context->dbh; |
271 |
my $variable = $input->param('variable'); |
273 |
my $query = "select * from systempreferences where variable=?"; |
272 |
C4::Context->set_preference($variable, $value) unless C4::Context->config('demo'); |
274 |
my $sth = $dbh->prepare($query); |
|
|
275 |
$sth->execute( $input->param('variable') ); |
276 |
if ( $sth->rows ) { |
277 |
unless ( C4::Context->config('demo') ) { |
278 |
my $sth = $dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?"); |
279 |
$sth->execute( $value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions') ); |
280 |
logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $input->param('variable') . " | " . $value ); |
281 |
} |
282 |
} else { |
283 |
unless ( C4::Context->config('demo') ) { |
284 |
my $sth = $dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)"); |
285 |
$sth->execute( $input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions') ); |
286 |
logaction( 'SYSTEMPREFERENCE', 'ADD', undef, $input->param('variable') . " | " . $input->param('value') ); |
287 |
} |
288 |
} |
289 |
|
290 |
} |
273 |
} |
291 |
|
274 |
|
292 |
################## ADD_FORM ################################## |
275 |
################## ADD_FORM ################################## |
Lines 315-327
if ( $op eq 'add_form' ) {
Link Here
|
315 |
################## ADD_VALIDATE ################################## |
298 |
################## ADD_VALIDATE ################################## |
316 |
# called by add_form, used to insert/modify data in DB |
299 |
# called by add_form, used to insert/modify data in DB |
317 |
} elsif ( $op eq 'add_validate' ) { |
300 |
} elsif ( $op eq 'add_validate' ) { |
318 |
my $dbh = C4::Context->dbh; |
|
|
319 |
my $sth = $dbh->prepare("select * from systempreferences where variable=?"); |
320 |
$sth->execute( $input->param('variable') ); |
321 |
|
322 |
# to handle multiple values |
301 |
# to handle multiple values |
323 |
my $value; |
302 |
my $value; |
324 |
|
303 |
|
|
|
304 |
my $variable = $input->param('variable'); |
305 |
my $expl = $input->param('explanation'); |
306 |
my $type = $input->param('preftype'); |
307 |
my $options = $input->param('prefoptions'); |
308 |
|
325 |
# handle multiple value strings (separated by ',') |
309 |
# handle multiple value strings (separated by ',') |
326 |
my $params = $input->Vars; |
310 |
my $params = $input->Vars; |
327 |
if ( defined $params->{'value'} ) { |
311 |
if ( defined $params->{'value'} ) { |
Lines 338-386
if ( $op eq 'add_form' ) {
Link Here
|
338 |
} |
322 |
} |
339 |
} |
323 |
} |
340 |
|
324 |
|
341 |
if ( $input->param('preftype') eq 'Upload' ) { |
325 |
if ( $type eq 'Upload' ) { |
342 |
my $lgtfh = $input->upload('value'); |
326 |
my $lgtfh = $input->upload('value'); |
343 |
$value = join '', <$lgtfh>; |
327 |
$value = join '', <$lgtfh>; |
344 |
$value = encode_base64($value); |
328 |
$value = encode_base64($value); |
345 |
} |
329 |
} |
346 |
|
330 |
|
347 |
if ( $sth->rows ) { |
331 |
C4::Context->set_preference( $variable, $value, $expl, $type, $options ) |
348 |
unless ( C4::Context->config('demo') ) { |
332 |
unless C4::Context->config('demo'); |
349 |
my $sth = $dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?"); |
|
|
350 |
$sth->execute( $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable') ); |
351 |
logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $input->param('variable') . " | " . $value ); |
352 |
} |
353 |
} else { |
354 |
unless ( C4::Context->config('demo') ) { |
355 |
my $sth = $dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)"); |
356 |
$sth->execute( $input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions') ); |
357 |
logaction( 'SYSTEMPREFERENCE', 'ADD', undef, $input->param('variable') . " | " . $value ); |
358 |
} |
359 |
} |
360 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=\"></html>"; |
333 |
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=systempreferences.pl?tab=\"></html>"; |
361 |
exit; |
334 |
exit; |
362 |
################## DELETE_CONFIRM ################################## |
335 |
################## DELETE_CONFIRM ################################## |
363 |
# called by default form, used to confirm deletion of data in DB |
336 |
# called by default form, used to confirm deletion of data in DB |
364 |
} elsif ( $op eq 'delete_confirm' ) { |
337 |
} elsif ( $op eq 'delete_confirm' ) { |
365 |
my $dbh = C4::Context->dbh; |
338 |
my $value = C4::Context->preference($searchfield); |
366 |
my $sth = $dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?"); |
|
|
367 |
$sth->execute($searchfield); |
368 |
my $data = $sth->fetchrow_hashref; |
369 |
$template->param( |
339 |
$template->param( |
370 |
searchfield => $searchfield, |
340 |
searchfield => $searchfield, |
371 |
Tvalue => $data->{'value'}, |
341 |
Tvalue => $value, |
372 |
); |
342 |
); |
373 |
|
343 |
|
374 |
# END $OP eq DELETE_CONFIRM |
344 |
# END $OP eq DELETE_CONFIRM |
375 |
################## DELETE_CONFIRMED ################################## |
345 |
################## DELETE_CONFIRMED ################################## |
376 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
346 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
377 |
} elsif ( $op eq 'delete_confirmed' ) { |
347 |
} elsif ( $op eq 'delete_confirmed' ) { |
378 |
my $dbh = C4::Context->dbh; |
348 |
C4::Context->delete_preference($searchfield); |
379 |
my $sth = $dbh->prepare("delete from systempreferences where variable=?"); |
|
|
380 |
$sth->execute($searchfield); |
381 |
my $logstring = $searchfield . " | " . $Tvalue; |
382 |
logaction( 'SYSTEMPREFERENCE', 'DELETE', undef, $logstring ); |
383 |
|
384 |
# END $OP eq DELETE_CONFIRMED |
349 |
# END $OP eq DELETE_CONFIRMED |
385 |
################## DEFAULT ################################## |
350 |
################## DEFAULT ################################## |
386 |
} else { # DEFAULT |
351 |
} else { # DEFAULT |
387 |
- |
|
|