From 48c2fefd1c637ad711c60ca399c61371c8e9154f Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 1 Aug 2003 14:23:52 +0000 Subject: [PATCH] demo mode added --- admin/marc_subfields_structure.pl | 32 ++++---- admin/marctagstructure.pl | 22 +++--- admin/systempreferences.pl | 117 ++++++++++++++++-------------- 3 files changed, 93 insertions(+), 78 deletions(-) diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 566d76fd94..2d8d233af7 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -271,17 +271,19 @@ if ($op eq 'add_form') { my $thesaurus_category =$thesaurus_category[$i]; my $value_builder=$value_builder[$i]; if ($liblibrarian) { - $sth->execute ($tagfield, - $tagsubfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $kohafield, - $tab, - $authorised_value, - $thesaurus_category, - $value_builder); + unless (C4::Context->config('demo') eq 1) { + $sth->execute ($tagfield, + $tagsubfield, + $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $kohafield, + $tab, + $authorised_value, + $thesaurus_category, + $value_builder); + } } } $sth->finish; @@ -308,9 +310,11 @@ if ($op eq 'add_form') { # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare($reqdel); - $sth->execute; - $sth->finish; + unless (C4::Context->config('demo') eq 1) { + my $sth=$dbh->prepare($reqdel); + $sth->execute; + $sth->finish; + } print "Content-Type: text/html\n\n"; exit; $template->param(tagfield => $tagfield); diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 4a2315b9d4..0af03e801e 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -128,13 +128,15 @@ if ($op eq 'add_form') { my $repeatable =$input->param('repeatable'); my $mandatory =$input->param('mandatory'); my $authorised_value =$input->param('authorised_value'); - $sth->execute($tagfield, - $liblibrarian, - $libopac, - $repeatable?1:0, - $mandatory?1:0, - $authorised_value - ); + unless (C4::Context->config('demo') eq 1) { + $sth->execute($tagfield, + $liblibrarian, + $libopac, + $repeatable?1:0, + $mandatory?1:0, + $authorised_value + ); + } $sth->finish; print "Content-Type: text/html\n\n"; exit; @@ -155,8 +157,10 @@ if ($op eq 'add_form') { # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { my $dbh = C4::Context->dbh; - $dbh->do("delete from marc_tag_structure where $pkfield='$searchfield'"); - $dbh->do("delete from marc_subfield_structure where tagfield='$searchfield'"); + unless (C4::Context->config('demo') eq 1) { + $dbh->do("delete from marc_tag_structure where $pkfield='$searchfield'"); + $dbh->do("delete from marc_subfield_structure where tagfield='$searchfield'"); + } # END $OP eq DELETE_CONFIRMED ################## DEFAULT ################################## } else { # DEFAULT diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 32b5c13c62..87e046b763 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -96,56 +96,59 @@ $template->param(script_name => $script_name, } if ($op eq 'update_and_reedit') { - foreach ($input->param) { - warn "$_: ".$input->param($_)."\n"; - } - my $value=''; - if (my $currentorder=$input->param('currentorder')) { - my @currentorder=split /\|/, $currentorder; - my $orderchanged=0; - foreach my $param ($input->param) { - if ($param=~m#up-(\d+).x#) { - my $temp=$currentorder[$1]; - $currentorder[$1]=$currentorder[$1-1]; - $currentorder[$1-1]=$temp; - $orderchanged=1; - last; - } elsif ($param=~m#down-(\d+).x#) { - my $temp=$currentorder[$1]; - $currentorder[$1]=$currentorder[$1+1]; - $currentorder[$1+1]=$temp; - $orderchanged=1; - last; - } + foreach ($input->param) { } - $value=join ' ', @currentorder; - if ($orderchanged) { - $op='add_form'; - $template->param(script_name => $script_name, - $op => 1); # we show only the TMPL_VAR names $op - } else { - $op=''; - $searchfield=''; - $template->param(script_name => $script_name, - else => 1); # we show only the TMPL_VAR names $op + my $value=''; + if (my $currentorder=$input->param('currentorder')) { + my @currentorder=split /\|/, $currentorder; + my $orderchanged=0; + foreach my $param ($input->param) { + if ($param=~m#up-(\d+).x#) { + my $temp=$currentorder[$1]; + $currentorder[$1]=$currentorder[$1-1]; + $currentorder[$1-1]=$temp; + $orderchanged=1; + last; + } elsif ($param=~m#down-(\d+).x#) { + my $temp=$currentorder[$1]; + $currentorder[$1]=$currentorder[$1+1]; + $currentorder[$1+1]=$temp; + $orderchanged=1; + last; + } + } + $value=join ' ', @currentorder; + if ($orderchanged) { + $op='add_form'; + $template->param(script_name => $script_name, + $op => 1); # we show only the TMPL_VAR names $op + } else { + $op=''; + $searchfield=''; + $template->param(script_name => $script_name, + else => 1); # we show only the TMPL_VAR names $op + } } - } - my $dbh = C4::Context->dbh; - my $query="select * from systempreferences where variable=?"; - my $sth=$dbh->prepare($query); - $sth->execute($input->param('variable')); - if ($sth->rows) { - my $query = "update systempreferences set value=?,explanation=? where variable=?"; - my $sth=$dbh->prepare($query); - $sth->execute($value, $input->param('explanation'), $input->param('variable')); - $sth->finish; + my $dbh = C4::Context->dbh; + my $query="select * from systempreferences where variable=?"; + my $sth=$dbh->prepare($query); + $sth->execute($input->param('variable')); + if ($sth->rows) { + unless (C4::Context->config('demo') eq 1) { + my $query = "update systempreferences set value=?,explanation=? where variable=?"; + my $sth=$dbh->prepare($query); + $sth->execute($value, $input->param('explanation'), $input->param('variable')); + $sth->finish; + } } else { - my $query = "insert into systempreferences (variable,value,explanation) values (?,?,?)"; - my $sth=$dbh->prepare($query); - $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation')); - $sth->finish; - } - $sth->finish; + unless (C4::Context->config('demo') eq 1) { + my $query = "insert into systempreferences (variable,value,explanation) values (?,?,?)"; + my $sth=$dbh->prepare($query); + $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation')); + $sth->finish; + } + } + $sth->finish; } @@ -237,15 +240,19 @@ if ($op eq 'add_form') { my $sth=$dbh->prepare($query); $sth->execute($input->param('variable')); if ($sth->rows) { - my $query = "update systempreferences set value=?,explanation=? where variable=?"; - my $sth=$dbh->prepare($query); - $sth->execute($input->param('value'), $input->param('explanation'), $input->param('variable')); - $sth->finish; + unless (C4::Context->config('demo') eq 1) { + my $query = "update systempreferences set value=?,explanation=? where variable=?"; + my $sth=$dbh->prepare($query); + $sth->execute($input->param('value'), $input->param('explanation'), $input->param('variable')); + $sth->finish; + } } else { - my $query = "insert into systempreferences (variable,value,explanation) values (?,?,?)"; - my $sth=$dbh->prepare($query); - $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation')); - $sth->finish; + unless (C4::Context->config('demo') eq 1) { + my $query = "insert into systempreferences (variable,value,explanation) values (?,?,?)"; + my $sth=$dbh->prepare($query); + $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation')); + $sth->finish; + } } $sth->finish; ################## DELETE_CONFIRM ################################## -- 2.39.5