diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index 1f1dd80ca2..fe717d097d 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -220,10 +220,13 @@ sub _get_columns { $tablehash{'__first__'} = $first; push @columns, \%tablehash; while ( my $data = $sth->fetchrow_arrayref() ) { - my %temphash; - $temphash{'name'} = "$tablename.$data->[0]"; - $temphash{'description'} = $columns->{$tablename}->{$data->[0]}; - push @columns, \%temphash; + my $forbidden = Koha::Report->new->check_columns( undef, [$data->[0]] ); + unless ( $forbidden ) { + my %temphash; + $temphash{'name'} = "$tablename.$data->[0]"; + $temphash{'description'} = $columns->{$tablename}->{$data->[0]}; + push @columns, \%temphash; + } } $sth->finish(); return (@columns); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt index facf3987be..568c0f817d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt @@ -140,6 +140,16 @@

Add new definition

[% INCLUDE 'csrf-token.inc' %] + + [% IF ( passworderr ) %] +
+ The following error was encountered:
+ The previous column selection included a password field.
+ The column cannot be used due to security risks.
+ Please make a new selection and ensure no password columns have been selected. +
+ [% END %] +
Step 1 of 5: Name the new definition
  1. diff --git a/reports/dictionary.pl b/reports/dictionary.pl index 123dab5340..fdab74a94c 100755 --- a/reports/dictionary.pl +++ b/reports/dictionary.pl @@ -80,39 +80,53 @@ elsif ( $op eq 'cud-add_form_3' ) { elsif ( $op eq 'cud-add_form_4' ) { # Choosing the values - my @columns = $input->multi_param('columns'); - my $columnstring = join( ',', @columns ); + my @columns = $input->multi_param('columns'); + my $columnstring = join( ',', @columns ); + my $forbidden = Koha::Report->new->check_columns( undef, \@columns ); my @column_loop; foreach my $column (@columns) { - my %tmp_hash; - $tmp_hash{'name'} = $column; - my $type = get_column_type($column); - if ( $type eq 'distinct' ) { - my $values = get_distinct_values($column); - $tmp_hash{'values'} = $values; - $tmp_hash{'distinct'} = 1; + unless ($forbidden) { + my %tmp_hash; + $tmp_hash{'name'} = $column; + my $type = get_column_type($column); + if ( $type eq 'distinct' ) { + my $values = get_distinct_values($column); + $tmp_hash{'values'} = $values; + $tmp_hash{'distinct'} = 1; + } + if ( $type eq 'DATE' || $type eq 'DATETIME' ) { + $tmp_hash{'date'} = 1; + } + if ( $type eq 'TEXT' || $type eq 'MEDIUMTEXT' ) { + $tmp_hash{'text'} = 1; + } + push @column_loop, \%tmp_hash; } - if ( $type eq 'DATE' || $type eq 'DATETIME' ) { - $tmp_hash{'date'} = 1; - } - if ($type eq 'TEXT' || $type eq 'MEDIUMTEXT'){ - $tmp_hash{'text'} = 1; - } - - # else { - # warn $type;# - # } - push @column_loop, \%tmp_hash; } - $template->param( 'step_4' => 1, - 'area' => $area, - 'definition_name' => $definition_name, - 'definition_description' => $definition_description, - 'columns' => \@column_loop, - 'columnstring' => $columnstring, - ); + if (@column_loop) { + $template->param( + 'step_4' => 1, + 'area' => $area, + 'definition_name' => $definition_name, + 'definition_description' => $definition_description, + 'columns' => \@column_loop, + 'columnstring' => $columnstring, + ); + } else { + my $columns = get_columns( $area, $input ); + $template->param( + 'step_3' => 1, + 'area' => $area, + 'definition_name' => $definition_name, + 'definition_description' => $definition_description, + 'columns' => \@column_loop, + 'columnstring' => $columnstring, + 'passworderr' => 1, + ); + } + } elsif ( $op eq 'cud-add_form_5' ) {