Lines 28-34
use Module::Load::Conditional qw( check_install );
Link Here
|
28 |
use Koha::Tags; |
28 |
use Koha::Tags; |
29 |
use Koha::Tags::Approvals; |
29 |
use Koha::Tags::Approvals; |
30 |
use Koha::Tags::Indexes; |
30 |
use Koha::Tags::Indexes; |
31 |
#use Data::Dumper; |
|
|
32 |
use constant TAG_FIELDS => qw(tag_id borrowernumber biblionumber term language date_created); |
31 |
use constant TAG_FIELDS => qw(tag_id borrowernumber biblionumber term language date_created); |
33 |
use constant TAG_SELECT => "SELECT " . join(',', TAG_FIELDS) . "\n FROM tags_all\n"; |
32 |
use constant TAG_SELECT => "SELECT " . join(',', TAG_FIELDS) . "\n FROM tags_all\n"; |
34 |
|
33 |
|
Lines 115-142
sub get_count_by_tag_status {
Link Here
|
115 |
} |
114 |
} |
116 |
|
115 |
|
117 |
sub remove_tag { |
116 |
sub remove_tag { |
118 |
my $tag_id = shift or return; |
117 |
my $tag_id = shift or return; |
119 |
my $user_id = (@_) ? shift : undef; |
118 |
my $user_id = (@_) ? shift : undef; |
120 |
my $rows = (defined $user_id) ? |
119 |
my $rows = (defined $user_id) ? |
121 |
get_tag_rows({tag_id=>$tag_id, borrowernumber=>$user_id}) : |
120 |
get_tag_rows({tag_id=>$tag_id, borrowernumber=>$user_id}) : |
122 |
get_tag_rows({tag_id=>$tag_id}) ; |
121 |
get_tag_rows({tag_id=>$tag_id}) ; |
123 |
$rows or return 0; |
122 |
$rows or return 0; |
124 |
(scalar(@$rows) == 1) or return; # should never happen (duplicate ids) |
123 |
(scalar(@$rows) == 1) or return; # should never happen (duplicate ids) |
125 |
my $row = shift(@$rows); |
124 |
my $row = shift(@$rows); |
126 |
($tag_id == $row->{tag_id}) or return 0; |
125 |
($tag_id == $row->{tag_id}) or return 0; |
127 |
my $tags = get_tags({term=>$row->{term}, biblionumber=>$row->{biblionumber}}); |
126 |
my $tags = get_tags({term=>$row->{term}, biblionumber=>$row->{biblionumber}}); |
128 |
my $index = shift(@$tags); |
127 |
my $index = shift(@$tags); |
129 |
if ($index->{weight} <= 1) { |
128 |
if ($index->{weight} <= 1) { |
130 |
Koha::Tags::Indexes->search({ term => $row->{term}, biblionumber => $row->{biblionumber} })->delete; |
129 |
Koha::Tags::Indexes->search({ term => $row->{term}, biblionumber => $row->{biblionumber} })->delete; |
131 |
} else { |
130 |
} else { |
132 |
decrement_weight($row->{term},$row->{biblionumber}); |
131 |
decrement_weight($row->{term},$row->{biblionumber}); |
133 |
} |
132 |
} |
134 |
if ($index->{weight_total} <= 1) { |
133 |
if ($index->{weight_total} <= 1) { |
135 |
Koha::Tags::Approvals->search({ term => $row->{term} })->delete; |
134 |
Koha::Tags::Approvals->search({ term => $row->{term} })->delete; |
136 |
} else { |
135 |
} else { |
137 |
decrement_weight_total($row->{term}); |
136 |
decrement_weight_total($row->{term}); |
138 |
} |
137 |
} |
139 |
Koha::Tags->search({ tag_id => $tag_id })->delete; |
138 |
Koha::Tags->search({ tag_id => $tag_id })->delete; |
140 |
} |
139 |
} |
141 |
|
140 |
|
142 |
sub get_tag_rows { |
141 |
sub get_tag_rows { |
143 |
- |
|
|