our ($template, $borrowernumber, $cookie)= get_template_and_user({
template_name => "admin/authorised_values.tt",
authnotrequired => 0,
- flagsrequired => {parameters => 'parameters_remaining_permissions'},
+ flagsrequired => {parameters => 'manage_auth_values'},
query => $input,
type => "intranet",
debug => 1,
elsif ( $id ) { # Update
my $av = Koha::AuthorisedValues->new->find( $id );
- $av->lib( $input->param('lib') || undef );
- $av->lib_opac( $input->param('lib_opac') || undef );
+ $av->lib( scalar $input->param('lib') || undef );
+ $av->lib_opac( scalar $input->param('lib_opac') || undef );
$av->category( $new_category );
$av->authorised_value( $new_authorised_value );
$av->imageurl( $imageurl );
);
if ( $already_exists ) {
- push @messages, {type => 'error', code => 'cat_already_exists' };
+ if ( $new_category eq 'branches' or $new_category eq 'itemtypes' or $new_category eq 'cn_source' ) {
+ push @messages, {type => 'error', code => 'invalid_category_name' };
+ } else {
+ push @messages, {type => 'error', code => 'cat_already_exists' };
+ }
}
else { # Insert
my $av = Koha::AuthorisedValueCategory->new( {
push @messages, {type => 'error', code => 'error_on_insert_cat' };
} else {
push @messages, { type => 'message', code => 'success_on_insert_cat' };
+ $searchfield = $new_category;
}
}
$op = 'list';
- $searchfield = $new_category;
} elsif ($op eq 'delete') {
- my $av = Koha::AuthorisedValues->new->find( $input->param('id') );
+ my $av = Koha::AuthorisedValues->new->find( $id );
my $deleted = eval {$av->delete};
if ( $@ or not $deleted ) {
push @messages, {type => 'error', code => 'error_on_delete' };
if ( $op eq 'list' ) {
# build categories list
- my @categories = Koha::AuthorisedValueCategories->search({}, { order_by => ['category_name'] } );
+ my @categories = Koha::AuthorisedValueCategories->search({ category_name => { -not_in => ['', 'branches', 'itemtypes', 'cn_source']}}, { order_by => ['category_name'] } );
my @category_list;
for my $category ( @categories ) {
push( @category_list, $category->category_name );