Fixing link to toggle between full and limited display
[koha.git] / admin / thesaurus.pl
index 4ceb41f..c1aa218 100755 (executable)
@@ -20,7 +20,7 @@
 use strict;
 use CGI;
 use C4::Auth;
-use C4::Charset;
+use C4::Interface::CGI::Output;
 use C4::Context;
 use C4::Output;
 use C4::Search;
@@ -29,16 +29,16 @@ 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;
@@ -73,8 +73,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 {
@@ -103,7 +103,7 @@ if ($op eq 'add_form') {
                $template->param(category => "<input type=text name=\"category\" size=8 maxlength=8>");
        }
 ################## 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;
        my $freelib = $input->param('freelib');
@@ -111,12 +111,20 @@ if ($op eq 'add_form') {
        newauthority($dbh,$input->param('category'),$input->param('father')." ".$input->param('stdlib'), $freelib,'',1,'');
        print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=thesaurus.pl?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$offset\"></html>";
        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<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=thesaurus.pl?branch=$branch&search_category=$search_category&offset=$offset&searchstring=".CGI::escapeHTML($searchstring)."\"></html>";
+       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,
@@ -249,14 +257,11 @@ if ($op eq 'add_form') {
                                                        branch => $branch,
                                                        father => $father);
        if ($offset>0) {
-               $template->param(previous => "<a href=$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$prevpage>&lt;&lt; Prev</a>");
+               $template->param(previous => "$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$prevpage");
        }
        if ($pagesize<$count) {
-               $template->param(next => "<a href=$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$nextpage>Next &gt;&gt;</a>");
+               $template->param(next => "$script_name?branch=$branch&search_category=$search_category&searchstring=$searchstring&offset=$nextpage");
        }
 } #---- END $OP eq DEFAULT
 
-print $input->header(
-    -type => guesstype($template->output),
-    -cookie => $cookie
-), $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;