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 276-299
if ( $op eq 'update_and_reedit' ) {
Link Here
|
276 |
); # we show only the TMPL_VAR names $op |
275 |
); # we show only the TMPL_VAR names $op |
277 |
} |
276 |
} |
278 |
} |
277 |
} |
279 |
my $dbh = C4::Context->dbh; |
278 |
my $variable = $input->param('variable'); |
280 |
my $query = "select * from systempreferences where variable=?"; |
279 |
C4::Context->set_preference($variable, $value) unless C4::Context->config('demo'); |
281 |
my $sth = $dbh->prepare($query); |
|
|
282 |
$sth->execute( $input->param('variable') ); |
283 |
if ( $sth->rows ) { |
284 |
unless ( C4::Context->config('demo') ) { |
285 |
my $sth = $dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?"); |
286 |
$sth->execute( $value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions') ); |
287 |
logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $input->param('variable') . " | " . $value ); |
288 |
} |
289 |
} else { |
290 |
unless ( C4::Context->config('demo') ) { |
291 |
my $sth = $dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)"); |
292 |
$sth->execute( $input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions') ); |
293 |
logaction( 'SYSTEMPREFERENCE', 'ADD', undef, $input->param('variable') . " | " . $input->param('value') ); |
294 |
} |
295 |
} |
296 |
|
297 |
} |
280 |
} |
298 |
|
281 |
|
299 |
################## ADD_FORM ################################## |
282 |
################## ADD_FORM ################################## |
Lines 322-334
if ( $op eq 'add_form' ) {
Link Here
|
322 |
################## ADD_VALIDATE ################################## |
305 |
################## ADD_VALIDATE ################################## |
323 |
# called by add_form, used to insert/modify data in DB |
306 |
# called by add_form, used to insert/modify data in DB |
324 |
} elsif ( $op eq 'add_validate' ) { |
307 |
} elsif ( $op eq 'add_validate' ) { |
325 |
my $dbh = C4::Context->dbh; |
|
|
326 |
my $sth = $dbh->prepare("select * from systempreferences where variable=?"); |
327 |
$sth->execute( $input->param('variable') ); |
328 |
|
329 |
# to handle multiple values |
308 |
# to handle multiple values |
330 |
my $value; |
309 |
my $value; |
331 |
|
310 |
|
|
|
311 |
my $variable = $input->param('variable'); |
312 |
my $expl = $input->param('explanation'); |
313 |
my $type = $input->param('preftype'); |
314 |
my $options = $input->param('prefoptions'); |
315 |
|
332 |
# handle multiple value strings (separated by ',') |
316 |
# handle multiple value strings (separated by ',') |
333 |
my $params = $input->Vars; |
317 |
my $params = $input->Vars; |
334 |
if ( defined $params->{'value'} ) { |
318 |
if ( defined $params->{'value'} ) { |
Lines 345-393
if ( $op eq 'add_form' ) {
Link Here
|
345 |
} |
329 |
} |
346 |
} |
330 |
} |
347 |
|
331 |
|
348 |
if ( $input->param('preftype') eq 'Upload' ) { |
332 |
if ( $type eq 'Upload' ) { |
349 |
my $lgtfh = $input->upload('value'); |
333 |
my $lgtfh = $input->upload('value'); |
350 |
$value = join '', <$lgtfh>; |
334 |
$value = join '', <$lgtfh>; |
351 |
$value = encode_base64($value); |
335 |
$value = encode_base64($value); |
352 |
} |
336 |
} |
353 |
|
337 |
|
354 |
if ( $sth->rows ) { |
338 |
C4::Context->set_preference( $variable, $value, $expl, $type, $options ) |
355 |
unless ( C4::Context->config('demo') ) { |
339 |
unless C4::Context->config('demo'); |
356 |
my $sth = $dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?"); |
|
|
357 |
$sth->execute( $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable') ); |
358 |
logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $input->param('variable') . " | " . $value ); |
359 |
} |
360 |
} else { |
361 |
unless ( C4::Context->config('demo') ) { |
362 |
my $sth = $dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)"); |
363 |
$sth->execute( $input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions') ); |
364 |
logaction( 'SYSTEMPREFERENCE', 'ADD', undef, $input->param('variable') . " | " . $value ); |
365 |
} |
366 |
} |
367 |
print $input->redirect("/cgi-bin/koha/admin/systempreferences.pl?tab="); |
340 |
print $input->redirect("/cgi-bin/koha/admin/systempreferences.pl?tab="); |
368 |
exit; |
341 |
exit; |
369 |
################## DELETE_CONFIRM ################################## |
342 |
################## DELETE_CONFIRM ################################## |
370 |
# called by default form, used to confirm deletion of data in DB |
343 |
# called by default form, used to confirm deletion of data in DB |
371 |
} elsif ( $op eq 'delete_confirm' ) { |
344 |
} elsif ( $op eq 'delete_confirm' ) { |
372 |
my $dbh = C4::Context->dbh; |
345 |
my $value = C4::Context->preference($searchfield); |
373 |
my $sth = $dbh->prepare("select variable,value,explanation,type,options from systempreferences where variable=?"); |
|
|
374 |
$sth->execute($searchfield); |
375 |
my $data = $sth->fetchrow_hashref; |
376 |
$template->param( |
346 |
$template->param( |
377 |
searchfield => $searchfield, |
347 |
searchfield => $searchfield, |
378 |
Tvalue => $data->{'value'}, |
348 |
Tvalue => $value, |
379 |
); |
349 |
); |
380 |
|
350 |
|
381 |
# END $OP eq DELETE_CONFIRM |
351 |
# END $OP eq DELETE_CONFIRM |
382 |
################## DELETE_CONFIRMED ################################## |
352 |
################## DELETE_CONFIRMED ################################## |
383 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
353 |
# called by delete_confirm, used to effectively confirm deletion of data in DB |
384 |
} elsif ( $op eq 'delete_confirmed' ) { |
354 |
} elsif ( $op eq 'delete_confirmed' ) { |
385 |
my $dbh = C4::Context->dbh; |
355 |
C4::Context->delete_preference($searchfield); |
386 |
my $sth = $dbh->prepare("delete from systempreferences where variable=?"); |
|
|
387 |
$sth->execute($searchfield); |
388 |
my $logstring = $searchfield . " | " . $Tvalue; |
389 |
logaction( 'SYSTEMPREFERENCE', 'DELETE', undef, $logstring ); |
390 |
|
391 |
# END $OP eq DELETE_CONFIRMED |
356 |
# END $OP eq DELETE_CONFIRMED |
392 |
################## DEFAULT ################################## |
357 |
################## DEFAULT ################################## |
393 |
} else { # DEFAULT |
358 |
} else { # DEFAULT |