| Filename | /usr/share/koha/lib/C4/ClassSource.pm |
| Statements | Executed 20 statements in 1.29ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.88ms | 50.0ms | C4::ClassSource::BEGIN@25 |
| 1 | 1 | 1 | 19µs | 24µs | C4::ClassSource::BEGIN@20 |
| 1 | 1 | 1 | 19µs | 23µs | C4::ClassSource::BEGIN@24 |
| 1 | 1 | 1 | 17µs | 35µs | C4::ClassSource::BEGIN@21 |
| 1 | 1 | 1 | 15µs | 97µs | C4::ClassSource::BEGIN@27 |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::AddClassSortRule |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::AddClassSource |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::DelClassSortRule |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::DelClassSource |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::GetClassSort |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::GetClassSortRule |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::GetClassSortRules |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::GetClassSource |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::GetClassSources |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::GetSourcesForSortRule |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::ModClassSortRule |
| 0 | 0 | 0 | 0s | 0s | C4::ClassSource::ModClassSource |
| 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 | 28µs | 2 | 28µs | # spent 24µs (19+4) within C4::ClassSource::BEGIN@20 which was called:
# once (19µs+4µs) by C4::Biblio::BEGIN@36 at line 20 # spent 24µs making 1 call to C4::ClassSource::BEGIN@20
# spent 4µs making 1 call to strict::import |
| 21 | 3 | 39µs | 2 | 54µs | # spent 35µs (17+19) within C4::ClassSource::BEGIN@21 which was called:
# once (17µs+19µs) by C4::Biblio::BEGIN@36 at line 21 # spent 35µs making 1 call to C4::ClassSource::BEGIN@21
# spent 19µs making 1 call to warnings::import |
| 22 | |||||
| 23 | 1 | 2µs | require Exporter; | ||
| 24 | 3 | 38µs | 2 | 27µs | # spent 23µs (19+4) within C4::ClassSource::BEGIN@24 which was called:
# once (19µs+4µs) by C4::Biblio::BEGIN@36 at line 24 # spent 23µs making 1 call to C4::ClassSource::BEGIN@24
# spent 4µs making 1 call to C4::Context::import |
| 25 | 3 | 165µs | 2 | 50.2ms | # spent 50.0ms (1.88+48.1) within C4::ClassSource::BEGIN@25 which was called:
# once (1.88ms+48.1ms) by C4::Biblio::BEGIN@36 at line 25 # spent 50.0ms making 1 call to C4::ClassSource::BEGIN@25
# spent 172µs making 1 call to Exporter::import |
| 26 | |||||
| 27 | 3 | 982µs | 2 | 179µs | # spent 97µs (15+82) within C4::ClassSource::BEGIN@27 which was called:
# once (15µs+82µs) by C4::Biblio::BEGIN@36 at line 27 # spent 97µs making 1 call to C4::ClassSource::BEGIN@27
# spent 82µs making 1 call to vars::import |
| 28 | |||||
| 29 | # set the version for version checking | ||||
| 30 | 1 | 3µs | $VERSION = 3.07.00.049; | ||
| 31 | |||||
| 32 | =head1 NAME | ||||
| 33 | |||||
| - - | |||||
| 50 | 1 | 16µs | @ISA = qw(Exporter); | ||
| 51 | 1 | 5µ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 | 8µs | 1; | ||
| 357 | |||||
| 358 | =head1 AUTHOR | ||||
| 359 | |||||
| - - |