X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=admin%2Fauth_subfields_structure.pl;h=14408594f31e99f66aeda51c56400f484e9d1fb2;hb=0bd485947f7554657e61f050cd5204ebb40d04c0;hp=e26aa79196b73e0658ae09ce886568eb38432fa9;hpb=39597b86ae299a9b4c0c1e8221f51f9e8dd300ed;p=koha.git diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index e26aa79196..14408594f3 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -25,6 +25,7 @@ use C4::Context; use C4::Koha; use Koha::Authority::Types; +use Koha::AuthorisedValues; use List::MoreUtils qw( uniq ); @@ -51,7 +52,8 @@ my $input = new CGI; my $tagfield = $input->param('tagfield'); my $tagsubfield = $input->param('tagsubfield'); my $authtypecode = $input->param('authtypecode'); -my $offset = $input->param('offset') || 0; +my $offset = $input->param('offset'); +$offset = 0 if not defined $offset or $offset < 0; my $op = $input->param('op') || ''; my $script_name = "/cgi-bin/koha/admin/auth_subfields_structure.pl"; @@ -92,11 +94,11 @@ if ($op eq 'add_form') { push @kohafields, "auth_header.".$field; } - # build authorised value list - my $authorised_values = C4::Koha::GetAuthorisedValueCategories; - unshift @$authorised_values, ''; - push @$authorised_values, 'branches'; - push @$authorised_values, 'itemtypes'; + # build authorised value category list + my @authorised_value_categories = Koha::AuthorisedValues->new->categories; + unshift @authorised_value_categories, ''; + push @authorised_value_categories, 'branches'; + push @authorised_value_categories, 'itemtypes'; # build thesaurus categories list my @authtypes = uniq( "", map { $_->authtypecode } Koha::Authority::Types->search ); @@ -138,7 +140,7 @@ if ($op eq 'add_form') { $row_data{seealso} = $data->{'seealso'}; $row_data{kohafields} = \@kohafields; $row_data{kohafield} = $data->{'kohafield'}; - $row_data{authorised_values} = $authorised_values; + $row_data{authorised_values} = \@authorised_value_categories; $row_data{authorised_value} = $data->{'authorised_value'}; $row_data{frameworkcodes} = \@authtypes; $row_data{frameworkcode} = $data->{'frameworkcode'}; @@ -167,7 +169,7 @@ if ($op eq 'add_form') { $row_data{mandatory} = 0; $row_data{isurl} = 0; $row_data{kohafields} = \@kohafields, - $row_data{authorised_values} = $authorised_values; + $row_data{authorised_values} = \@authorised_value_categories; $row_data{frameworkcodes} = \@authtypes; $row_data{value_builders} = \@value_builder; $row_data{row} = $i; @@ -192,18 +194,18 @@ if ($op eq 'add_form') { values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?, defaultvalue=? where authtypecode=? and tagfield=? and tagsubfield=?"); - my @tagsubfield = $input->param('tagsubfield'); - my @liblibrarian = $input->param('liblibrarian'); - my @libopac = $input->param('libopac'); + my @tagsubfield = $input->multi_param('tagsubfield'); + my @liblibrarian = $input->multi_param('liblibrarian'); + my @libopac = $input->multi_param('libopac'); my @kohafield = ''.$input->param('kohafield'); - my @tab = $input->param('tab'); - my @seealso = $input->param('seealso'); - my @ohidden = $input->param('ohidden'); - my @authorised_values = $input->param('authorised_value'); + my @tab = $input->multi_param('tab'); + my @seealso = $input->multi_param('seealso'); + my @ohidden = $input->multi_param('ohidden'); + my @authorised_value_categories = $input->multi_param('authorised_value'); my $authtypecode = $input->param('authtypecode'); - my @frameworkcodes = $input->param('frameworkcode'); - my @value_builder =$input->param('value_builder'); - my @defaultvalue = $input->param('defaultvalue'); + my @frameworkcodes = $input->multi_param('frameworkcode'); + my @value_builder =$input->multi_param('value_builder'); + my @defaultvalue = $input->multi_param('defaultvalue'); for (my $i=0; $i<= $#tagsubfield ; $i++) { my $tagfield =$input->param('tagfield'); my $tagsubfield =$tagsubfield[$i]; @@ -215,14 +217,13 @@ if ($op eq 'add_form') { my $kohafield =$kohafield[$i]; my $tab =$tab[$i]; my $seealso =$seealso[$i]; - my $authorised_value =$authorised_values[$i]; + my $authorised_value = $authorised_value_categories[$i]; my $frameworkcode =$frameworkcodes[$i]; my $value_builder=$value_builder[$i]; my $defaultvalue = $defaultvalue[$i]; my $hidden = $ohidden[$i]; #collate from 3 hiddens; my $isurl = $input->param("isurl$i")?1:0; if ($liblibrarian) { - unless (C4::Context->config('demo') or C4::Context->config('demo') eq 1) { if (auth_subfield_structure_exists($authtypecode, $tagfield, $tagsubfield)) { $sth_update->execute( $authtypecode, @@ -267,7 +268,6 @@ if ($op eq 'add_form') { $defaultvalue, ); } - } } } print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode"); @@ -291,10 +291,8 @@ 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') or C4::Context->config('demo') eq 1) { - my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); - $sth->execute($tagfield,$tagsubfield,$authtypecode); - } + my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); + $sth->execute($tagfield,$tagsubfield,$authtypecode); print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode"); exit; # END $OP eq DELETE_CONFIRMED