Filename | /usr/share/koha/lib/C4/ClassSource.pm |
Statements | Executed 20 statements in 1.45ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.47ms | 63.2ms | BEGIN@25 | C4::ClassSource::
1 | 1 | 1 | 77µs | 220µs | BEGIN@27 | C4::ClassSource::
1 | 1 | 1 | 22µs | 29µs | BEGIN@20 | C4::ClassSource::
1 | 1 | 1 | 17µs | 21µs | BEGIN@24 | C4::ClassSource::
1 | 1 | 1 | 14µs | 37µs | BEGIN@21 | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | AddClassSortRule | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | AddClassSource | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | DelClassSortRule | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | DelClassSource | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | GetClassSort | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | GetClassSortRule | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | GetClassSortRules | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | GetClassSource | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | GetClassSources | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | GetSourcesForSortRule | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | ModClassSortRule | C4::ClassSource::
0 | 0 | 0 | 0s | 0s | ModClassSource | C4::ClassSource::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package C4::ClassSource; | ||||
2 | |||||
3 | # Copyright (C) 2007 LibLime | ||||
4 | # | ||||
5 | # This file is part of Koha. | ||||
6 | # | ||||
7 | # Koha is free software; you can redistribute it and/or modify it under the | ||||
8 | # terms of the GNU General Public License as published by the Free Software | ||||
9 | # Foundation; either version 2 of the License, or (at your option) any later | ||||
10 | # version. | ||||
11 | # | ||||
12 | # Koha is distributed in the hope that it will be useful, but WITHOUT ANY | ||||
13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||||
14 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||
15 | # | ||||
16 | # You should have received a copy of the GNU General Public License along | ||||
17 | # with Koha; if not, write to the Free Software Foundation, Inc., | ||||
18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
19 | |||||
20 | 3 | 31µs | 2 | 36µs | # spent 29µs (22+7) within C4::ClassSource::BEGIN@20 which was called:
# once (22µs+7µs) by C4::Biblio::BEGIN@36 at line 20 # spent 29µs making 1 call to C4::ClassSource::BEGIN@20
# spent 7µs making 1 call to strict::import |
21 | 3 | 38µs | 2 | 59µs | # spent 37µs (14+23) within C4::ClassSource::BEGIN@21 which was called:
# once (14µs+23µs) by C4::Biblio::BEGIN@36 at line 21 # spent 37µs making 1 call to C4::ClassSource::BEGIN@21
# spent 23µs making 1 call to warnings::import |
22 | |||||
23 | 1 | 4µs | require Exporter; | ||
24 | 3 | 31µs | 2 | 25µs | # spent 21µs (17+4) within C4::ClassSource::BEGIN@24 which was called:
# once (17µs+4µs) by C4::Biblio::BEGIN@36 at line 24 # spent 21µs making 1 call to C4::ClassSource::BEGIN@24
# spent 4µs making 1 call to C4::Context::import |
25 | 3 | 177µs | 2 | 63.4ms | # spent 63.2ms (2.47+60.7) within C4::ClassSource::BEGIN@25 which was called:
# once (2.47ms+60.7ms) by C4::Biblio::BEGIN@36 at line 25 # spent 63.2ms making 1 call to C4::ClassSource::BEGIN@25
# spent 282µs making 1 call to Exporter::import |
26 | |||||
27 | 3 | 1.09ms | 2 | 362µs | # spent 220µs (77+142) within C4::ClassSource::BEGIN@27 which was called:
# once (77µs+142µs) by C4::Biblio::BEGIN@36 at line 27 # spent 220µs making 1 call to C4::ClassSource::BEGIN@27
# spent 142µs making 1 call to vars::import |
28 | |||||
29 | # set the version for version checking | ||||
30 | 1 | 24µs | $VERSION = 3.07.00.049; | ||
31 | |||||
32 | =head1 NAME | ||||
33 | |||||
- - | |||||
50 | 1 | 28µs | @ISA = qw(Exporter); | ||
51 | 1 | 8µs | @EXPORT = qw( | ||
52 | &GetClassSources | ||||
53 | &AddClassSource | ||||
54 | &GetClassSource | ||||
55 | &ModClassSource | ||||
56 | &DelClassSource | ||||
57 | &GetClassSortRules | ||||
58 | &AddClassSortRule | ||||
59 | &GetClassSortRule | ||||
60 | &ModClassSortRule | ||||
61 | &DelClassSortRule | ||||
62 | |||||
63 | &GetSourcesForSortRule | ||||
64 | &GetClassSort | ||||
65 | |||||
66 | ); | ||||
67 | |||||
68 | =head2 GetClassSources | ||||
69 | |||||
- - | |||||
92 | sub GetClassSources { | ||||
93 | |||||
94 | my %class_sources = (); | ||||
95 | my $dbh = C4::Context->dbh; | ||||
96 | my $sth = $dbh->prepare_cached("SELECT * FROM `class_sources`"); | ||||
97 | $sth->execute(); | ||||
98 | while (my $source = $sth->fetchrow_hashref) { | ||||
99 | $class_sources{ $source->{'cn_source'} } = $source; | ||||
100 | } | ||||
101 | $sth->finish(); | ||||
102 | |||||
103 | return \%class_sources; | ||||
104 | |||||
105 | } | ||||
106 | |||||
107 | =head2 AddClassSource | ||||
108 | |||||
- - | |||||
115 | sub AddClassSource { | ||||
116 | |||||
117 | my ($cn_source, $description, $used, $class_sort_rule) = @_; | ||||
118 | my $dbh = C4::Context->dbh; | ||||
119 | my $sth = $dbh->prepare_cached("INSERT INTO `class_sources` | ||||
120 | (`cn_source`, `description`, `used`, `class_sort_rule`) | ||||
121 | VALUES (?, ?, ?, ?)"); | ||||
122 | $sth->execute($cn_source, $description, $used, $class_sort_rule); | ||||
123 | $sth->finish(); | ||||
124 | |||||
125 | } | ||||
126 | |||||
127 | =head2 GetClassSource | ||||
128 | |||||
- - | |||||
135 | sub GetClassSource { | ||||
136 | |||||
137 | my ($cn_source) = (@_); | ||||
138 | my $dbh = C4::Context->dbh; | ||||
139 | my $sth = $dbh->prepare_cached("SELECT * FROM `class_sources` WHERE cn_source = ?"); | ||||
140 | $sth->execute($cn_source); | ||||
141 | my $row = $sth->fetchrow_hashref(); | ||||
142 | $sth->finish(); | ||||
143 | return $row; | ||||
144 | } | ||||
145 | |||||
146 | =head2 ModClassSource | ||||
147 | |||||
- - | |||||
154 | sub ModClassSource { | ||||
155 | |||||
156 | my ($cn_source, $description, $used, $class_sort_rule) = @_; | ||||
157 | my $dbh = C4::Context->dbh; | ||||
158 | my $sth = $dbh->prepare_cached("UPDATE `class_sources` | ||||
159 | SET `description` = ?, | ||||
160 | `used` = ?, | ||||
161 | `class_sort_rule` = ? | ||||
162 | WHERE `cn_source` = ?"); | ||||
163 | $sth->execute($description, $used, $class_sort_rule, $cn_source); | ||||
164 | $sth->finish(); | ||||
165 | |||||
166 | } | ||||
167 | |||||
168 | =head2 DelClassSource | ||||
169 | |||||
- - | |||||
176 | sub DelClassSource { | ||||
177 | |||||
178 | my ($cn_source) = @_; | ||||
179 | my $dbh = C4::Context->dbh; | ||||
180 | my $sth = $dbh->prepare_cached("DELETE FROM `class_sources` WHERE `cn_source` = ?"); | ||||
181 | $sth->execute($cn_source); | ||||
182 | $sth->finish(); | ||||
183 | |||||
184 | } | ||||
185 | |||||
186 | =head2 GetClassSortRules | ||||
187 | |||||
- - | |||||
209 | sub GetClassSortRules { | ||||
210 | |||||
211 | my %class_sort_rules = (); | ||||
212 | my $dbh = C4::Context->dbh; | ||||
213 | my $sth = $dbh->prepare_cached("SELECT * FROM `class_sort_rules`"); | ||||
214 | $sth->execute(); | ||||
215 | while (my $sort_rule = $sth->fetchrow_hashref) { | ||||
216 | $class_sort_rules{ $sort_rule->{'class_sort_rule'} } = $sort_rule; | ||||
217 | } | ||||
218 | $sth->finish(); | ||||
219 | |||||
220 | return \%class_sort_rules; | ||||
221 | |||||
222 | } | ||||
223 | |||||
224 | =head2 AddClassSortRule | ||||
225 | |||||
- - | |||||
232 | sub AddClassSortRule { | ||||
233 | |||||
234 | my ($class_sort_rule, $description, $sort_routine) = @_; | ||||
235 | my $dbh = C4::Context->dbh; | ||||
236 | my $sth = $dbh->prepare_cached("INSERT INTO `class_sort_rules` | ||||
237 | (`class_sort_rule`, `description`, `sort_routine`) | ||||
238 | VALUES (?, ?, ?)"); | ||||
239 | $sth->execute($class_sort_rule, $description, $sort_routine); | ||||
240 | $sth->finish(); | ||||
241 | |||||
242 | } | ||||
243 | |||||
244 | =head2 GetClassSortRule | ||||
245 | |||||
- - | |||||
252 | sub GetClassSortRule { | ||||
253 | |||||
254 | my ($class_sort_rule) = (@_); | ||||
255 | my $dbh = C4::Context->dbh; | ||||
256 | my $sth = $dbh->prepare_cached("SELECT * FROM `class_sort_rules` WHERE `class_sort_rule` = ?"); | ||||
257 | $sth->execute($class_sort_rule); | ||||
258 | my $row = $sth->fetchrow_hashref(); | ||||
259 | $sth->finish(); | ||||
260 | return $row; | ||||
261 | } | ||||
262 | |||||
263 | =head2 ModClassSortRule | ||||
264 | |||||
- - | |||||
271 | sub ModClassSortRule { | ||||
272 | |||||
273 | my ($class_sort_rule, $description, $sort_routine) = @_; | ||||
274 | my $dbh = C4::Context->dbh; | ||||
275 | my $sth = $dbh->prepare_cached("UPDATE `class_sort_rules` | ||||
276 | SET `description` = ?, | ||||
277 | `sort_routine` = ? | ||||
278 | WHERE `class_sort_rule` = ?"); | ||||
279 | $sth->execute($description, $sort_routine, $class_sort_rule); | ||||
280 | $sth->finish(); | ||||
281 | |||||
282 | } | ||||
283 | |||||
284 | =head2 DelClassSortRule | ||||
285 | |||||
- - | |||||
292 | sub DelClassSortRule { | ||||
293 | |||||
294 | my ($class_sort_rule) = @_; | ||||
295 | my $dbh = C4::Context->dbh; | ||||
296 | my $sth = $dbh->prepare_cached("DELETE FROM `class_sort_rules` WHERE `class_sort_rule` = ?"); | ||||
297 | $sth->execute($class_sort_rule); | ||||
298 | $sth->finish(); | ||||
299 | |||||
300 | } | ||||
301 | |||||
302 | =head2 GetSourcesForSortRule | ||||
303 | |||||
- - | |||||
311 | sub GetSourcesForSortRule { | ||||
312 | |||||
313 | my ($class_sort_rule) = @_; | ||||
314 | |||||
315 | my $dbh = C4::Context->dbh; | ||||
316 | my $sth = $dbh->prepare_cached("SELECT cn_source FROM class_sources WHERE class_sort_rule = ?"); | ||||
317 | $sth->execute($class_sort_rule); | ||||
318 | my @sources = (); | ||||
319 | while (my ($source) = $sth->fetchrow_array()) { | ||||
320 | push @sources, $source; | ||||
321 | } | ||||
322 | $sth->finish(); | ||||
323 | return @sources; | ||||
324 | |||||
325 | } | ||||
326 | |||||
327 | =head2 GetClassSort | ||||
328 | |||||
- - | |||||
336 | sub GetClassSort { | ||||
337 | |||||
338 | my ($cn_source, $cn_class, $cn_item) = @_; | ||||
339 | |||||
340 | my $source_ref = GetClassSource($cn_source); | ||||
341 | unless (defined $source_ref) { | ||||
342 | $source_ref = GetClassSource(C4::Context->preference("DefaultClassificationSource")); | ||||
343 | } | ||||
344 | my $routine = ""; | ||||
345 | if (defined $source_ref) { | ||||
346 | my $rule_ref = GetClassSortRule($source_ref->{'class_sort_rule'}); | ||||
347 | if (defined $rule_ref) { | ||||
348 | $routine = $rule_ref->{'sort_routine'}; | ||||
349 | } | ||||
350 | } | ||||
351 | |||||
352 | return GetClassSortKey($routine, $cn_class, $cn_item); | ||||
353 | |||||
354 | } | ||||
355 | |||||
356 | 1 | 18µs | 1; | ||
357 | |||||
358 | =head1 AUTHOR | ||||
359 | |||||
- - |