X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=admin%2Fthesaurus.pl;h=f7b1f11a00a920c3f1ed7c5e91bd240f186549e3;hb=fe59c6c516d456e7455947b195033b3f2380180e;hp=0bfbef923512e0c7534e24dc52db4fc0b16f842b;hpb=6d929790ff56962d620e61bde8dcc8ec54642177;p=koha-ffzg.git diff --git a/admin/thesaurus.pl b/admin/thesaurus.pl index 0bfbef9235..f7b1f11a00 100755 --- a/admin/thesaurus.pl +++ b/admin/thesaurus.pl @@ -19,31 +19,39 @@ use strict; use CGI; +use C4::Auth; +use C4::Interface::CGI::Output; use C4::Context; use C4::Output; use C4::Search; -use HTML::Template; -use C4::Context; use C4::Authorities; my $input = new CGI; my $search_category=$input->param('search_category'); -$search_category=$input->param('category') unless $search_category; +# $search_category=$input->param('category') unless $search_category; #my $toponly = $input->param('toponly'); my $branch = $input->param('branch'); my $searchstring = $input->param('searchstring'); -$searchstring=~ s/\,//g; +# $searchstring=~ s/\,//g; my $id = $input->param('id'); my $offset=$input->param('offset'); my $father=$input->param('father'); -my $reqsel="select category,stdlib,freelib from bibliothesaurus where id='$id'"; +my $reqsel=""; my $reqdel="delete from bibliothesaurus where id='$id'"; my $script_name="/cgi-bin/koha/admin/thesaurus.pl"; my $dbh = C4::Context->dbh; my $authoritysep = C4::Context->preference("authoritysep"); -my $template = gettemplate("parameters/thesaurus.tmpl",0); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "admin/thesaurus.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + debug => 1, + }); + my $pagesize=20; my $prevpage = $offset-$pagesize; @@ -64,8 +72,8 @@ if ($op eq 'add_form') { my $data; if ($id) { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select id,category,freelib,stdlib from bibliothesaurus where id='$id'"); - $sth->execute; + my $sth=$dbh->prepare("select id,category,freelib,stdlib from bibliothesaurus where id=?"); + $sth->execute($id); $data=$sth->fetchrow_hashref; $sth->finish; } else { @@ -73,9 +81,9 @@ if ($op eq 'add_form') { $data->{'stdlib'} = $input->param('stdlib'); } if ($search_category) { - $template->param(action => "Modify authorised value"); + $template->param(action => "Modify thesaurus"); } else { - $template->param(action => "Add authorised value"); + $template->param(action => "Add thesaurus"); } $template->param(category => $data->{'category'}, stdlib => $data->{'stdlib'}, @@ -94,18 +102,28 @@ if ($op eq 'add_form') { $template->param(category => ""); } ################## ADD_VALIDATE ################################## -# called by add_form, used to insert/modify data in DB +# called by add_form, used to insert data in DB } elsif ($op eq 'add_validate') { my $dbh = C4::Context->dbh; - newauthority($dbh,$input->param('category'),$input->param('stdlib'), $input->param('freelib'),'',1,''); + my $freelib = $input->param('freelib'); + $freelib = $input->param('stdlib') unless ($input->param('freelib')); + newauthority($dbh,$input->param('category'),$input->param('father')." ".$input->param('stdlib'), $freelib,'',1,''); print "Content-Type: text/html\n\n"; exit; +################## MOD_VALIDATE ################################## +# called by add_form, used to modify data in DB +} elsif ($op eq 'mod_validate') { + my $dbh = C4::Context->dbh; + my $freelib = $input->param('freelib'); + modauthority($dbh,$id,$freelib); + print "Content-Type: text/html\n\n"; + exit; ################## DELETE_CONFIRM ################################## # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare($reqsel); - $sth->execute; + my $sth=$dbh->prepare("select category,stdlib,freelib from bibliothesaurus where id=?"); + $sth->execute($id); my $data=$sth->fetchrow_hashref; $sth->finish; $template->param(search_category => $search_category, @@ -117,10 +135,6 @@ 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') { -# my $dbh = C4::Context->dbh; -# my $sth=$dbh->prepare($reqdel); -# $sth->execute; -# $sth->finish; &delauthority($id); print "Content-Type: text/html\n\n"; exit; @@ -242,11 +256,11 @@ if ($op eq 'add_form') { branch => $branch, father => $father); if ($offset>0) { - $template->param(previous => "<< Prev"); + $template->param(previous => "$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$prevpage"); } if ($pagesize<$count) { - $template->param(next => "Next >>"); + $template->param(next => "$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$nextpage"); } } #---- END $OP eq DEFAULT -print "Content-Type: text/html\n\n", $template->output; +output_html_with_http_headers $input, $cookie, $template->output;