#
# 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 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 3 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.
+# 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.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
require Exporter;
use C4::Context;
-use C4::Koha;
use C4::ClassSortRoutine;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-# set the version for version checking
-$VERSION = 3.00;
=head1 NAME
my %class_sources = ();
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("SELECT * FROM `class_sources`");
+ my $sth = $dbh->prepare("SELECT * FROM `class_sources`");
$sth->execute();
while (my $source = $sth->fetchrow_hashref) {
$class_sources{ $source->{'cn_source'} } = $source;
}
- $sth->finish();
return \%class_sources;
sub AddClassSource {
my ($cn_source, $description, $used, $class_sort_rule) = @_;
+ my $exists = GetClassSource($cn_source);
+ if ($exists) {
+ return 0;
+ }
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("INSERT INTO `class_sources`
+ my $sth = $dbh->prepare("INSERT INTO `class_sources`
(`cn_source`, `description`, `used`, `class_sort_rule`)
VALUES (?, ?, ?, ?)");
$sth->execute($cn_source, $description, $used, $class_sort_rule);
- $sth->finish();
-
+ return 1;
}
=head2 GetClassSource
my ($cn_source) = (@_);
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("SELECT * FROM `class_sources` WHERE cn_source = ?");
+ my $sth = $dbh->prepare("SELECT * FROM `class_sources` WHERE cn_source = ?");
$sth->execute($cn_source);
my $row = $sth->fetchrow_hashref();
- $sth->finish();
return $row;
}
my ($cn_source, $description, $used, $class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("UPDATE `class_sources`
+ my $sth = $dbh->prepare("UPDATE `class_sources`
SET `description` = ?,
`used` = ?,
`class_sort_rule` = ?
WHERE `cn_source` = ?");
$sth->execute($description, $used, $class_sort_rule, $cn_source);
- $sth->finish();
}
my ($cn_source) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("DELETE FROM `class_sources` WHERE `cn_source` = ?");
+ my $sth = $dbh->prepare("DELETE FROM `class_sources` WHERE `cn_source` = ?");
$sth->execute($cn_source);
- $sth->finish();
}
my %class_sort_rules = ();
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("SELECT * FROM `class_sort_rules`");
+ my $sth = $dbh->prepare("SELECT * FROM `class_sort_rules`");
$sth->execute();
while (my $sort_rule = $sth->fetchrow_hashref) {
$class_sort_rules{ $sort_rule->{'class_sort_rule'} } = $sort_rule;
}
- $sth->finish();
return \%class_sort_rules;
sub AddClassSortRule {
my ($class_sort_rule, $description, $sort_routine) = @_;
+ my $exists = GetClassSortRule($class_sort_rule);
+ if ($exists) {
+ return 0;
+ }
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("INSERT INTO `class_sort_rules`
+ my $sth = $dbh->prepare("INSERT INTO `class_sort_rules`
(`class_sort_rule`, `description`, `sort_routine`)
VALUES (?, ?, ?)");
$sth->execute($class_sort_rule, $description, $sort_routine);
- $sth->finish();
-
+ return 1;
}
=head2 GetClassSortRule
my ($class_sort_rule) = (@_);
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("SELECT * FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
+ my $sth = $dbh->prepare("SELECT * FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
$sth->execute($class_sort_rule);
my $row = $sth->fetchrow_hashref();
- $sth->finish();
return $row;
}
my ($class_sort_rule, $description, $sort_routine) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("UPDATE `class_sort_rules`
+ my $sth = $dbh->prepare("UPDATE `class_sort_rules`
SET `description` = ?,
`sort_routine` = ?
WHERE `class_sort_rule` = ?");
$sth->execute($description, $sort_routine, $class_sort_rule);
- $sth->finish();
}
my ($class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("DELETE FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
+ my $sth = $dbh->prepare("DELETE FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
$sth->execute($class_sort_rule);
- $sth->finish();
}
my ($class_sort_rule) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare_cached("SELECT cn_source FROM class_sources WHERE class_sort_rule = ?");
+ my $sth = $dbh->prepare("SELECT cn_source FROM class_sources WHERE class_sort_rule = ?");
$sth->execute($class_sort_rule);
my @sources = ();
while (my ($source) = $sth->fetchrow_array()) {
push @sources, $source;
}
- $sth->finish();
return @sources;
}