bugfixes and improvments
[koha.git] / admin / stopwords.pl
index 22d41c7..ee5f1ff 100755 (executable)
 # if $op=delete_confirm
 #      - we delete the record having primkey=$primkey
 
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use strict;
-use C4::Output;
 use CGI;
+use C4::Context;
+use C4::Output;
 use C4::Search;
-use C4::Database;
 
 sub StringSearch  {
        my ($env,$searchstring,$type)=@_;
-       my $dbh = &C4Connect;
+       my $dbh = C4::Context->dbh;
        $searchstring=~ s/\'/\\\'/g;
        my @data=split(' ',$searchstring);
        my $count=@data;
@@ -42,7 +60,6 @@ sub StringSearch  {
        }
        #  $sth->execute;
        $sth->finish;
-       $dbh->disconnect;
        return ($cnt,\@results);
 }
 
@@ -69,7 +86,7 @@ if ($op eq 'add_form') {
        #---- if primkey exists, it's a modify action, so read values to modify...
        my $data;
        if ($searchfield) {
-               my $dbh = &C4Connect;
+               my $dbh = C4::Context->dbh;
                my $sth=$dbh->prepare("select word from stopwords where word='$searchfield'");
                $sth->execute;
                $data=$sth->fetchrow_hashref;
@@ -149,7 +166,7 @@ printend
 ################## ADD_VALIDATE ##################################
 # called by add_form, used to insert/modify data in DB
 } elsif ($op eq 'add_validate') {
-       my $dbh=C4Connect;
+       my $dbh = C4::Context->dbh;
        my $query = "replace stopwords (word) values (";
        $query.= $dbh->quote($input->param('word')).")";
        my $sth=$dbh->prepare($query);
@@ -163,7 +180,7 @@ printend
 ################## DELETE_CONFIRM ##################################
 # called by default form, used to confirm deletion of data in DB
 } elsif ($op eq 'delete_confirm') {
-       my $dbh = &C4Connect;
+       my $dbh = C4::Context->dbh;
        my $sth=$dbh->prepare($reqsel);
        $sth->execute;
        my $data=$sth->fetchrow_hashref;
@@ -177,7 +194,7 @@ printend
 ################## DELETE_CONFIRMED ##################################
 # called by delete_confirm, used to effectively confirm deletion of data in DB
 } elsif ($op eq 'delete_confirmed') {
-       my $dbh=C4Connect;
+       my $dbh = C4::Context->dbh;
 #      my $searchfield=$input->param('branchcode');
        my $sth=$dbh->prepare($reqdel);
        $sth->execute;
@@ -191,7 +208,7 @@ printend
 } else { # DEFAULT
        my @inputs=(["text","searchfield",$searchfield],
                ["reset","reset","clr"]);
-       print mkheadr(2,'Currencies admin');
+       print mkheadr(2,'Stopwords admin');
        print mkformnotable("$script_name",@inputs);
        print <<printend
 
@@ -213,7 +230,7 @@ printend
                        $toggle="white";
                }
                print mktablerow(2,$toggle,$results->[$i]{'word'},
-               mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'word'},'Delete',''));
+               mklink("$script_name?op=delete_confirm&searchfield=".$results->[$i]{'word'},'Delete'));
        }
        print mktableft;
        print "<form action='$script_name' method=post>";