Bug 8435: DBRev 3.13.00.038
[koha.git] / admin / marctagstructure.pl
index 07b0a30..0326b93 100755 (executable)
@@ -52,7 +52,7 @@ my ($template, $loggedinuser, $cookie)
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
-                            flagsrequired => {parameters => 1},
+                 flagsrequired => {parameters => 'parameters_remaining_permissions'},
                             debug => 1,
                             });
 
@@ -118,12 +118,12 @@ if ($op eq 'add_form') {
        if ($searchfield) {
         $template->param(searchfield => $searchfield);
                $template->param(action => "Modify tag");
-               $template->param('heading-modify-tag-p' => 1);
+               $template->param('heading_modify_tag_p' => 1);
        } else {
                $template->param(action => "Add tag");
-               $template->param('heading-add-tag-p' => 1);
+               $template->param('heading_add_tag_p' => 1);
        }
-       $template->param('use-heading-flags-p' => 1);
+       $template->param('use_heading_flags_p' => 1);
        $template->param(liblibrarian => $data->{'liblibrarian'},
                        libopac => $data->{'libopac'},
                        repeatable => CGI::checkbox(-name=>'repeatable',
@@ -149,7 +149,7 @@ if ($op eq 'add_form') {
        my $repeatable       = $input->param('repeatable') ? 1 : 0;
        my $mandatory        = $input->param('mandatory')  ? 1 : 0;
        my $authorised_value = $input->param('authorised_value');
-    unless (C4::Context->config('demo') == 1) {
+    unless (C4::Context->config('demo')) {
         if ($input->param('modif')) {
             $sth = $dbh->prepare(
             "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
@@ -194,7 +194,7 @@ if ($op eq 'add_form') {
 ################## DELETE_CONFIRMED ##################################
 # called by delete_confirm, used to effectively confirm deletion of data in DB
 } elsif ($op eq 'delete_confirmed') {
-       unless (C4::Context->config('demo') == 1) {
+       unless (C4::Context->config('demo')) {
         my $sth1 = $dbh->prepare("DELETE FROM marc_tag_structure      WHERE tagfield=? AND frameworkcode=?");
         my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?");
         $sth1->execute($searchfield, $frameworkcode);
@@ -255,7 +255,7 @@ if ($op eq 'add_form') {
                my @loop_data = ();
                my $j=1;
                my $i=$offset;
-               while ($i < ($offset+$pagesize<$cnt?$offset+$pagesize:$cnt)) {
+        while ( $i < $cnt ) {
                        my %row_data;  # get a fresh hash for the row data
                        $row_data{tagfield}         = $results[$i]->{'mts_tagfield'};
                        $row_data{liblibrarian}     = $results[$i]->{'mts_liblibrarian'};
@@ -267,7 +267,7 @@ if ($op eq 'add_form') {
                        $row_data{delete}        = "$script_name?op=delete_confirm&amp;searchfield="      .$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
                        $j=$i;
                        my @internal_loop = ();
-                       while (($results[$i]->{'tagfield'}==$results[$j]->{'tagfield'}) and ($j< ($offset+$pagesize<$cnt?$offset+$pagesize:$cnt))) {
+                       while ( ( $j < $cnt ) and ( $results[$i]->{'tagfield'} == $results[$j]->{'tagfield'} ) ) {
                                my %subfield_data;
                                $subfield_data{tagsubfield}      = $results[$j]->{'tagsubfield'};
                                $subfield_data{liblibrarian}     = $results[$j]->{'liblibrarian'};
@@ -294,7 +294,7 @@ if ($op eq 'add_form') {
                my ($count,$results)=StringSearch($searchfield,$frameworkcode);
                $cnt = $count;
                my @loop_data = ();
-               for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
+        for ( my $i = $offset ; $i < $count ; $i++ ) {
                        my %row_data;  # get a fresh hash for the row data
                        $row_data{tagfield}         = $results->[$i]{'tagfield'};
                        $row_data{liblibrarian}     = $results->[$i]{'liblibrarian'};
@@ -348,6 +348,7 @@ sub StringSearch  {
 #
 sub duplicate_framework {
        my ($newframeworkcode,$oldframeworkcode) = @_;
+       my $dbh = C4::Context->dbh;
        my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where frameworkcode=?");
        $sth->execute($oldframeworkcode);
        my $sth_insert = $dbh->prepare("insert into marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)");