1 package C4
::ClassSource
;
3 # Copyright (C) 2007 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25 use C4
::ClassSortRoutine
;
27 use vars
qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32 C4::ClassSources - handle classification sources in Koha
40 This module deals with manipulating classification
41 sources and sorting rules.
58 =head2 GetClassSources
60 my $sources = GetClassSources();
62 Returns reference to hash of references to
63 the class sources, keyed on cn_source.
67 my $sources = GetClassSources();
69 foreach my $cn_source (sort keys %$sources) {
70 my $source = $sources->{$cn_source};
73 code => $source->{'cn_source'},
74 description => $source->{'description'},
75 used => $source->{'used'},
76 sortrule => $source->{'class_sort_rule'}
84 my %class_sources = ();
85 my $dbh = C4
::Context
->dbh;
86 my $sth = $dbh->prepare("SELECT * FROM `class_sources`");
88 while (my $source = $sth->fetchrow_hashref) {
89 $class_sources{ $source->{'cn_source'} } = $source;
92 return \
%class_sources;
98 my $hashref = GetClassSource($cn_source);
100 Retrieves a class_sources row by cn_source.
106 my ($cn_source) = (@_);
107 my $dbh = C4
::Context
->dbh;
108 my $sth = $dbh->prepare("SELECT * FROM `class_sources` WHERE cn_source = ?");
109 $sth->execute($cn_source);
110 my $row = $sth->fetchrow_hashref();
114 =head2 GetClassSortRule
116 my $hashref = GetClassSortRule($class_sort_rule);
118 Retrieves a class_sort_rules row by class_sort_rule.
122 sub GetClassSortRule
{
124 my ($class_sort_rule) = (@_);
125 my $dbh = C4
::Context
->dbh;
126 my $sth = $dbh->prepare("SELECT * FROM `class_sort_rules` WHERE `class_sort_rule` = ?");
127 $sth->execute($class_sort_rule);
128 my $row = $sth->fetchrow_hashref();
134 my $cn_sort = GetClassSort($cn_source, $cn_class, $cn_item);
136 Get the sort key corresponding to the classification part and item part
137 and the defined call number source.
143 my ($cn_source, $cn_class, $cn_item) = @_;
145 my $source_ref = GetClassSource
($cn_source);
146 unless (defined $source_ref) {
147 $source_ref = GetClassSource
(C4
::Context
->preference("DefaultClassificationSource"));
150 if (defined $source_ref) {
151 my $rule_ref = GetClassSortRule
($source_ref->{'class_sort_rule'});
152 if (defined $rule_ref) {
153 $routine = $rule_ref->{'sort_routine'};
157 return GetClassSortKey
($routine, $cn_class, $cn_item);
165 Koha Development Team <http://koha-community.org/>