View | Details | Raw Unified | Return to bug 20447
Collapse All | Expand All

(-)a/Koha/Item.pm (-3 / +18 lines)
Lines 1189-1194 sub orders { Link Here
1189
    return Koha::Acquisition::Orders->_new_from_dbic($orders);
1189
    return Koha::Acquisition::Orders->_new_from_dbic($orders);
1190
}
1190
}
1191
1191
1192
=head3 tracked_links
1193
1194
  my $tracked_links = $item->tracked_links();
1195
1196
Returns a Koha::TrackedLinks object
1197
1198
=cut
1199
1200
sub tracked_links {
1201
    my ( $self ) = @_;
1202
1203
    my $tracked_links = $self->_result->linktrackers;
1204
    return Koha::TrackedLinks->_new_from_dbic($tracked_links);
1205
}
1206
1192
=head3 move_to_biblio
1207
=head3 move_to_biblio
1193
1208
1194
  $item->move_to_biblio($to_biblio[, $params]);
1209
  $item->move_to_biblio($to_biblio[, $params]);
Lines 1255-1263 sub move_to_biblio { Link Here
1255
        }
1270
        }
1256
    );
1271
    );
1257
1272
1258
    # linktrackers (there's no Koha object set available yet)
1273
    # tracked_links
1259
    my $linktrackers = $self->_result->linktrackers;
1274
    my $tracked_links = $self->tracked_links;
1260
    $linktrackers->update_all({ biblionumber => $to_biblionumber });
1275
    $tracked_links->update({ biblionumber => $to_biblionumber });
1261
1276
1262
    return $to_biblionumber;
1277
    return $to_biblionumber;
1263
}
1278
}
(-)a/Koha/TrackedLink.pm (+43 lines)
Line 0 Link Here
1
package Koha::TrackedLink;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
21
use Koha::Database;
22
23
use base qw(Koha::Object);
24
25
=head1 NAME
26
27
Koha::TrackedLink - Koha TrackedLink Object class
28
29
=head1 API
30
31
=head2 Class Methods
32
33
=cut
34
35
=head3 type
36
37
=cut
38
39
sub _type {
40
    return 'LinkTracker';
41
}
42
43
1;
(-)a/Koha/TrackedLinks.pm (+49 lines)
Line 0 Link Here
1
package Koha::TrackedLinks;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
21
use Koha::Database;
22
23
use Koha::TrackedLink;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::TrackedLinks - Koha TrackedLink Object set class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=cut
36
37
=head3 type
38
39
=cut
40
41
sub _type {
42
    return 'LinkTracker';
43
}
44
45
sub object_class {
46
    return 'Koha::TrackedLink';
47
}
48
49
1;
(-)a/t/db_dependent/Koha/Item.t (-2 / +17 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 12;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use C4::Biblio qw( GetMarcSubfieldStructure );
25
use C4::Biblio qw( GetMarcSubfieldStructure );
Lines 38-43 use t::lib::Mocks; Link Here
38
my $schema  = Koha::Database->new->schema;
38
my $schema  = Koha::Database->new->schema;
39
my $builder = t::lib::TestBuilder->new;
39
my $builder = t::lib::TestBuilder->new;
40
40
41
subtest 'tracked_links relationship' => sub {
42
    plan tests => 3;
43
44
    my $biblio = $builder->build_sample_biblio();
45
    my $item   = $builder->build_sample_item({
46
        biblionumber => $biblio->biblionumber,
47
    });
48
    my $tracked_links = $item->tracked_links;
49
    is( ref($tracked_links), 'Koha::TrackedLinks', 'tracked_links returns a Koha::TrackedLinks object set' );
50
    is($item->tracked_links->count, 0, "Empty Koha::TrackedLinks set returned if no tracked_links");
51
    my $link1 = $builder->build({ source => 'LinkTracker', value => { itemnumber => $item->itemnumber }});
52
    my $link2 = $builder->build({ source => 'LinkTracker', value => { itemnumber => $item->itemnumber }});
53
54
    is($item->tracked_links()->count,2,"Two tracked links found");
55
};
56
41
subtest 'hidden_in_opac() tests' => sub {
57
subtest 'hidden_in_opac() tests' => sub {
42
58
43
    plan tests => 4;
59
    plan tests => 4;
44
- 

Return to bug 20447