demo mode added
authortipaul <tipaul>
Fri, 1 Aug 2003 14:23:52 +0000 (14:23 +0000)
committertipaul <tipaul>
Fri, 1 Aug 2003 14:23:52 +0000 (14:23 +0000)
admin/marc_subfields_structure.pl
admin/marctagstructure.pl
admin/systempreferences.pl

index 566d76f..2d8d233 100755 (executable)
@@ -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<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marc_subfields_structure.pl?tagfield=$tagfield\"></html>";
        exit;
        $template->param(tagfield => $tagfield);
index 4a2315b..0af03e8 100755 (executable)
@@ -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<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl?tagfield=$tagfield\"></html>";
        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
index 32b5c13..87e046b 100755 (executable)
@@ -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 ##################################