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

(-)a/Koha/Schema/Result/AdditionalContentsLocalization.pm (+13 lines)
Lines 159-167 __PACKAGE__->belongs_to( Link Here
159
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 09:59:00
159
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 09:59:00
160
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7N/mHMqyPJJsYaA8V968wQ
160
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7N/mHMqyPJJsYaA8V968wQ
161
161
162
=head2 koha_object_class
163
164
  Koha Object class
165
166
=cut
167
162
sub koha_object_class {
168
sub koha_object_class {
163
    'Koha::AdditionalContentsLocalization';
169
    'Koha::AdditionalContentsLocalization';
164
}
170
}
171
172
=head2 koha_objects_class
173
174
  Koha Objects class
175
176
=cut
177
165
sub koha_objects_class {
178
sub koha_objects_class {
166
    'Koha::AdditionalContentsLocalizations';
179
    'Koha::AdditionalContentsLocalizations';
167
}
180
}
(-)a/installer/data/mysql/atomicupdate/bug_31383.pl (-30 / +57 lines)
Lines 1-19 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
return {
3
return {
4
    bug_number => "31383",
4
    bug_number  => "31383",
5
    description => "Split the additional_contents table",
5
    description => "Split the additional_contents table",
6
    up => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        unless ( TableExists('additional_contents_localizations') ) {
9
        unless ( TableExists('additional_contents_localizations') ) {
10
            $dbh->do(q{
10
            $dbh->do(
11
                q{
11
                ALTER TABLE additional_contents
12
                ALTER TABLE additional_contents
12
                CHANGE COLUMN idnew `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content category'
13
                CHANGE COLUMN idnew `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content category'
13
            });
14
            }
15
            );
14
            say $out "Renamed additional_contents.idnew with 'id'";
16
            say $out "Renamed additional_contents.idnew with 'id'";
15
17
16
            $dbh->do(q{
18
            $dbh->do(
19
                q{
17
                CREATE TABLE `additional_contents_localizations` (
20
                CREATE TABLE `additional_contents_localizations` (
18
                    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content',
21
                    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content',
19
                    `additional_content_id` int(10) unsigned NOT NULL COMMENT 'link to the additional content',
22
                    `additional_content_id` int(10) unsigned NOT NULL COMMENT 'link to the additional content',
Lines 25-48 return { Link Here
25
                    UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`),
28
                    UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`),
26
                    CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
29
                    CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
27
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
30
                  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
28
            });
31
            }
32
            );
29
            say $out "Added new table 'additional_contents_localizations'";
33
            say $out "Added new table 'additional_contents_localizations'";
30
34
31
            my $contents = $dbh->selectall_arrayref(q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode}, { Slice => {} });
35
            my $contents = $dbh->selectall_arrayref(
32
            my $sth_insert = $dbh->prepare(q{
36
                q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode},
37
                { Slice => {} }
38
            );
39
            my $sth_insert = $dbh->prepare(
40
                q{
33
                INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang, updated_on)
41
                INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang, updated_on)
34
                VALUES(?, ?, ?, ?, ?)
42
                VALUES(?, ?, ?, ?, ?)
35
            });
43
            }
36
            for my $content ( @$contents ) {
44
            );
45
            for my $content (@$contents) {
37
                my $q = q{
46
                my $q = q{
38
                    SELECT title, content, lang, branchcode, updated_on
47
                    SELECT title, content, lang, branchcode, updated_on
39
                    FROM additional_contents
48
                    FROM additional_contents
40
                    WHERE category=? AND code=? AND
49
                    WHERE category=? AND code=? AND
41
                };
50
                };
42
                $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
51
                $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
43
                my $translated_contents = $dbh->selectall_arrayref($q, { Slice => {} }, $content->{category}, $content->{code}, defined $content->{branchcode} ? $content->{branchcode} : ());
52
                my $translated_contents = $dbh->selectall_arrayref(
44
                for my $translated_content ( @$translated_contents ) {
53
                    $q, { Slice => {} }, $content->{category}, $content->{code},
45
                    $sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}, $translated_content->{updated_on});
54
                    defined $content->{branchcode} ? $content->{branchcode} : ()
55
                );
56
                for my $translated_content (@$translated_contents) {
57
                    $sth_insert->execute(
58
                        $content->{id}, $translated_content->{title}, $translated_content->{content},
59
                        $translated_content->{lang}, $translated_content->{updated_on}
60
                    );
46
                }
61
                }
47
62
48
                # Delete duplicates
63
                # Delete duplicates
Lines 51-105 return { Link Here
51
                    WHERE category=? AND code=? AND id<>? AND
66
                    WHERE category=? AND code=? AND id<>? AND
52
                };
67
                };
53
                $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
68
                $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
54
                $dbh->do($q, undef, $content->{category}, $content->{code}, $content->{id}, $content->{branchcode});
69
                $dbh->do( $q, undef, $content->{category}, $content->{code}, $content->{id}, $content->{branchcode} );
55
            }
70
            }
56
            $dbh->do(q{
71
            $dbh->do(
72
                q{
57
                ALTER TABLE additional_contents
73
                ALTER TABLE additional_contents
58
                DROP INDEX additional_contents_uniq
74
                DROP INDEX additional_contents_uniq
59
            });
75
            }
60
            $dbh->do(q{
76
            );
77
            $dbh->do(
78
                q{
61
                ALTER TABLE additional_contents
79
                ALTER TABLE additional_contents
62
                ADD UNIQUE KEY `additional_contents_uniq` (`category`,`code`,`branchcode`)
80
                ADD UNIQUE KEY `additional_contents_uniq` (`category`,`code`,`branchcode`)
63
            });
81
            }
64
            $dbh->do(q{
82
            );
83
            $dbh->do(
84
                q{
65
                ALTER TABLE additional_contents
85
                ALTER TABLE additional_contents
66
                DROP COLUMN title,
86
                DROP COLUMN title,
67
                DROP COLUMN content,
87
                DROP COLUMN content,
68
                DROP COLUMN lang
88
                DROP COLUMN lang
69
            });
89
            }
90
            );
70
            say $out "Removed 'title', 'content', 'lang' columns from additional_contents";
91
            say $out "Removed 'title', 'content', 'lang' columns from additional_contents";
71
        }
92
        }
72
93
73
        my $notice_templates = $dbh->selectall_arrayref(q{
94
        my $notice_templates = $dbh->selectall_arrayref(
95
            q{
74
            SELECT id, module, code, content
96
            SELECT id, module, code, content
75
            FROM letter
97
            FROM letter
76
            WHERE content LIKE "%<news>%"
98
            WHERE content LIKE "%<news>%"
77
        }, { Slice => {} });
99
        }, { Slice => {} }
78
        for my $template ( @$notice_templates ) {
100
        );
101
        for my $template (@$notice_templates) {
79
            my $new_content = $template->{content};
102
            my $new_content = $template->{content};
80
            $new_content =~ s|<news>|[% FOR content IN additional_contents %]|g;
103
            $new_content =~ s|<news>|[% FOR content IN additional_contents %]|g;
81
            $new_content =~ s|</news>|[% END %]|g;
104
            $new_content =~ s|</news>|[% END %]|g;
82
            $new_content =~ s{<<\s*additional_contents\.title\s*>>}{[% content.title | html %]}g;
105
            $new_content =~ s{<<\s*additional_contents\.title\s*>>}{[% content.title | html %]}g;
83
            $new_content =~ s{<<\s*additional_contents\.content\s*>>}{[% content.content | html %]}g;
106
            $new_content =~ s{<<\s*additional_contents\.content\s*>>}{[% content.content | html %]}g;
84
            $new_content =~ s{<<\s*additional_contents\.published_on\s*>>}{[% content.published_on | \$KohaDates %]}g;
107
            $new_content =~ s{<<\s*additional_contents\.published_on\s*>>}{[% content.published_on | \$KohaDates %]}g;
85
            $dbh->do(q{
108
            $dbh->do(
109
                q{
86
                UPDATE letter
110
                UPDATE letter
87
                SET content = ?
111
                SET content = ?
88
                WHERE id = ?
112
                WHERE id = ?
89
            }, undef, $new_content, $template->{id});
113
            }, undef, $new_content, $template->{id}
114
            );
90
115
91
            say $out "Adjusted notice template '" . $template->{code} . "'";
116
            say $out "Adjusted notice template '" . $template->{code} . "'";
92
        }
117
        }
93
118
94
        $notice_templates = $dbh->selectall_arrayref(q{
119
        $notice_templates = $dbh->selectall_arrayref(
120
            q{
95
            SELECT id, code
121
            SELECT id, code
96
            FROM letter
122
            FROM letter
97
            WHERE content LIKE "%<<additional_content%" OR content LIKE "%<< additional_content%"
123
            WHERE content LIKE "%<<additional_content%" OR content LIKE "%<< additional_content%"
98
        });
124
        }
125
        );
99
126
100
        if ( @$notice_templates ) {
127
        if (@$notice_templates) {
101
            say $out "WARNING - Some notice templates need manual adjustments!";
128
            say $out "WARNING - Some notice templates need manual adjustments!";
102
            for my $template ( @$notice_templates ) {
129
            for my $template (@$notice_templates) {
103
                say $out sprintf "\t %s (id=%s)", $template->{code}, $template->{id};
130
                say $out sprintf "\t %s (id=%s)", $template->{code}, $template->{id};
104
            }
131
            }
105
        }
132
        }
(-)a/t/db_dependent/Koha/AdditionalContents.t (-26 / +48 lines)
Lines 52-58 subtest 'Koha::AdditionalContents basic test' => sub { Link Here
52
        content => 'content for news 1',
52
        content => 'content for news 1',
53
        lang    => 'default',
53
        lang    => 'default',
54
    };
54
    };
55
    $new_news_item_1->translated_contents([$content_1]);
55
    $new_news_item_1->translated_contents( [$content_1] );
56
    my $new_news_item_2 = Koha::AdditionalContent->new(
56
    my $new_news_item_2 = Koha::AdditionalContent->new(
57
        {
57
        {
58
            category   => 'news',
58
            category   => 'news',
Lines 66-79 subtest 'Koha::AdditionalContents basic test' => sub { Link Here
66
        content => 'content for news 2',
66
        content => 'content for news 2',
67
        lang    => 'default',
67
        lang    => 'default',
68
    };
68
    };
69
    $new_news_item_2->translated_contents([$content_2]);
69
    $new_news_item_2->translated_contents( [$content_2] );
70
70
71
    like( $new_news_item_1->id, qr|^\d+$|, 'Adding a new news_item should have set the id');
71
    like( $new_news_item_1->id, qr|^\d+$|, 'Adding a new news_item should have set the id' );
72
    is( Koha::AdditionalContents->search->count, $nb_of_news + 2, 'The 2 news should have been added' );
72
    is( Koha::AdditionalContents->search->count, $nb_of_news + 2, 'The 2 news should have been added' );
73
73
74
    my $retrieved_news_item_1 = Koha::AdditionalContents->find( $new_news_item_1->id )->translated_contents->next;
74
    my $retrieved_news_item_1 = Koha::AdditionalContents->find( $new_news_item_1->id )->translated_contents->next;
75
    is( $retrieved_news_item_1->title, $content_1->{title}, 'Find a news_item by id should return the correct news_item' );
75
    is(
76
    is( $retrieved_news_item_1->content, $content_1->{content}, 'The content method return the content of the news');
76
        $retrieved_news_item_1->title, $content_1->{title},
77
        'Find a news_item by id should return the correct news_item'
78
    );
79
    is( $retrieved_news_item_1->content, $content_1->{content}, 'The content method return the content of the news' );
77
80
78
    my $default_content = $new_news_item_2->default_localization;
81
    my $default_content = $new_news_item_2->default_localization;
79
    is( $default_content->content, $content_2->{content}, 'default_localization return the default content' );
82
    is( $default_content->content, $content_2->{content}, 'default_localization return the default content' );
Lines 82-90 subtest 'Koha::AdditionalContents basic test' => sub { Link Here
82
    $default_content = $new_news_item_2->default_localization;
85
    $default_content = $new_news_item_2->default_localization;
83
    is( $default_content->content, $content_2->{content}, 'default_localization still return the default content' );
86
    is( $default_content->content, $content_2->{content}, 'default_localization still return the default content' );
84
    my $retrieved_translated_content = $new_news_item_2->translated_content('en');
87
    my $retrieved_translated_content = $new_news_item_2->translated_content('en');
85
    is( $retrieved_translated_content->content, $content_2->{content}, 'default content is returned for non-existing translated interface' );
88
    is(
89
        $retrieved_translated_content->content, $content_2->{content},
90
        'default content is returned for non-existing translated interface'
91
    );
86
    $retrieved_translated_content = $new_news_item_2->translated_content('nl-NL');
92
    $retrieved_translated_content = $new_news_item_2->translated_content('nl-NL');
87
    is( $retrieved_translated_content->content, $translated_content->{content}, 'translated content is returned if it existsOB' );
93
    is(
94
        $retrieved_translated_content->content, $translated_content->{content},
95
        'translated content is returned if it existsOB'
96
    );
88
97
89
    $new_news_item_1->delete;
98
    $new_news_item_1->delete;
90
    is( Koha::AdditionalContents->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
99
    is( Koha::AdditionalContents->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
Lines 167-173 subtest '->author' => sub { Link Here
167
176
168
    $author->delete;
177
    $author->delete;
169
178
170
    $news_item = Koha::AdditionalContents->find($news_item->id);
179
    $news_item = Koha::AdditionalContents->find( $news_item->id );
171
    is( ref($news_item), 'Koha::AdditionalContent', 'News are not deleted alongwith the author' );
180
    is( ref($news_item), 'Koha::AdditionalContent', 'News are not deleted alongwith the author' );
172
    is( $news_item->author, undef, '->author returns undef is the author has been deleted' );
181
    is( $news_item->author, undef, '->author returns undef is the author has been deleted' );
173
182
Lines 199-205 subtest '->search_for_display' => sub { Link Here
199
            number => 1,
208
            number => 1,
200
        }
209
        }
201
    });
210
    });
202
    $new_expired->translated_contents( [ { lang => 'default', content => ''} ] );
211
    $new_expired->translated_contents( [ { lang => 'default', content => '' } ] );
203
    my $new_not_expired = $builder->build_object({
212
    my $new_not_expired = $builder->build_object({
204
        class => 'Koha::AdditionalContents',
213
        class => 'Koha::AdditionalContents',
205
        value => {
214
        value => {
Lines 283-309 subtest 'find_best_match' => sub { Link Here
283
    plan tests => 3;
292
    plan tests => 3;
284
    $schema->storage->txn_begin;
293
    $schema->storage->txn_begin;
285
294
286
    my $library01 = $builder->build_object({ class => 'Koha::Libraries' });
295
    my $library01 = $builder->build_object( { class => 'Koha::Libraries' } );
287
    my $html01 = $builder->build_object({
296
    my $html01    = $builder->build_object(
288
        class => 'Koha::AdditionalContents',
297
        {
289
        value => { category => 'html_customizations', location => 'test_best_match', branchcode => undef },
298
            class => 'Koha::AdditionalContents',
290
    });
299
            value => { category => 'html_customizations', location => 'test_best_match', branchcode => undef },
291
    my ( $default_content ) = $html01->translated_contents( [ { lang => 'default', content => '' } ] )->as_list;
300
        }
301
    );
302
    my ($default_content) = $html01->translated_contents( [ { lang => 'default', content => '' } ] )->as_list;
292
    my $params = { category => 'html_customizations', location => 'test_best_match', lang => 'nl-NL' };
303
    my $params = { category => 'html_customizations', location => 'test_best_match', lang => 'nl-NL' };
293
    is( Koha::AdditionalContents->find_best_match($params)->id, $default_content->id, 'Found all branches, lang default' );
304
    is(
305
        Koha::AdditionalContents->find_best_match($params)->id, $default_content->id,
306
        'Found all branches, lang default'
307
    );
294
308
295
    my $html02 = $builder->build_object({
309
    my $html02 = $builder->build_object(
296
        class => 'Koha::AdditionalContents',
310
        {
297
        value => { category => 'html_customizations', location => 'test_best_match', branchcode => undef },
311
            class => 'Koha::AdditionalContents',
298
    });
312
            value => { category => 'html_customizations', location => 'test_best_match', branchcode => undef },
299
    my ( $translated_content ) = $html02->translated_contents( [ { lang => 'nl-NL', content => '' } ] )->as_list;
313
        }
300
    is( Koha::AdditionalContents->find_best_match($params)->id, $translated_content->id, 'Found all branches, lang nl-NL' );
314
    );
301
315
    my ($translated_content) = $html02->translated_contents( [ { lang => 'nl-NL', content => '' } ] )->as_list;
302
    $params->{ library_id } = $library01->id;
316
    is(
317
        Koha::AdditionalContents->find_best_match($params)->id, $translated_content->id,
318
        'Found all branches, lang nl-NL'
319
    );
320
321
    $params->{library_id} = $library01->id;
303
    $html02->branchcode( $library01->id )->store;
322
    $html02->branchcode( $library01->id )->store;
304
    is( Koha::AdditionalContents->find_best_match($params)->id, $translated_content->id, 'Found library01, lang nl-NL' );
323
    is(
324
        Koha::AdditionalContents->find_best_match($params)->id, $translated_content->id,
325
        'Found library01, lang nl-NL'
326
    );
305
327
306
    # Note: find_best_match is tested further via $libary->opac_info; see t/db_dependent/Koha/Library.t
328
    # Note: find_best_match is tested further via $libary->opac_info; see t/db_dependent/Koha/Library.t
307
329
308
    $schema->storage->txn_rollback;
330
    $schema->storage->txn_rollback;
309
}
331
    }
(-)a/tools/additional-contents.pl (-21 / +23 lines)
Lines 77-83 if ( $op eq 'add_form' ) { Link Here
77
    );
77
    );
78
}
78
}
79
elsif ( $op eq 'add_validate' ) {
79
elsif ( $op eq 'add_validate' ) {
80
    output_and_exit_if_error($cgi, $cookie, $template, { check => 'csrf_token' });
80
    output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } );
81
    my $location   = $cgi->param('location');
81
    my $location   = $cgi->param('location');
82
    my $code       = $cgi->param('code');
82
    my $code       = $cgi->param('code');
83
    my $branchcode = $cgi->param('branchcode') || undef;
83
    my $branchcode = $cgi->param('branchcode') || undef;
Lines 93-107 elsif ( $op eq 'add_validate' ) { Link Here
93
            sub {
93
            sub {
94
                my $additional_content;
94
                my $additional_content;
95
                my $params = {
95
                my $params = {
96
                        location       => $location,
96
                    location       => $location,
97
                        branchcode     => $branchcode,
97
                    branchcode     => $branchcode,
98
                        expirationdate => $expirationdate,
98
                    expirationdate => $expirationdate,
99
                        published_on   => $published_on,
99
                    published_on   => $published_on,
100
                        number         => $number,
100
                    number         => $number,
101
                        borrowernumber => $borrowernumber,
101
                    borrowernumber => $borrowernumber,
102
                    };
102
                };
103
103
104
                if ( $id ) {
104
                if ($id) {
105
                    $additional_content = Koha::AdditionalContents->find($id);
105
                    $additional_content = Koha::AdditionalContents->find($id);
106
                    $additional_content->set($params)->store;
106
                    $additional_content->set($params)->store;
107
                } else {
107
                } else {
Lines 117-125 elsif ( $op eq 'add_validate' ) { Link Here
117
                unless ($code) {
117
                unless ($code) {
118
                    $additional_content->discard_changes;
118
                    $additional_content->discard_changes;
119
                    $code =
119
                    $code =
120
                      $category eq 'news'
120
                        $category eq 'news'
121
                      ? 'News_' . $additional_content->id
121
                        ? 'News_' . $additional_content->id
122
                      : $location . '_' . $additional_content->id;
122
                        : $location . '_' . $additional_content->id;
123
                    $additional_content->code($code)->store;
123
                    $additional_content->code($code)->store;
124
                    $id = $additional_content->id;
124
                    $id = $additional_content->id;
125
                }
125
                }
Lines 142-157 elsif ( $op eq 'add_validate' ) { Link Here
142
                    };
142
                    };
143
143
144
                    my $existing_content = $existing_contents->find($id);
144
                    my $existing_content = $existing_contents->find($id);
145
                    if ( $existing_content ) {
145
                    if ($existing_content) {
146
                        if ( $existing_content->title ne $title || $existing_content->content ne $content ) {
146
                        if ( $existing_content->title ne $title || $existing_content->content ne $content ) {
147
                            if ( C4::Context->preference("NewsLog") ) {
147
                            if ( C4::Context->preference("NewsLog") ) {
148
                                logaction('NEWS', 'MODIFY' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content));
148
                                logaction(
149
                                    'NEWS', 'MODIFY', undef,
150
                                    sprintf( "%s|%s|%s|%s", $code, $title, $lang, $content )
151
                                );
149
                            }
152
                            }
150
                        } else {
153
                        } else {
151
                            $translated_content->{updated_on} = $existing_content->updated_on;
154
                            $translated_content->{updated_on} = $existing_content->updated_on;
152
                        }
155
                        }
153
                    } elsif( C4::Context->preference("NewsLog") ) {
156
                    } elsif ( C4::Context->preference("NewsLog") ) {
154
                        logaction('NEWS', 'ADD' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content))
157
                        logaction( 'NEWS', 'ADD', undef, sprintf( "%s|%s|%s|%s", $code, $title, $lang, $content ) );
155
                    }
158
                    }
156
159
157
                    push @translated_contents, $translated_content;
160
                    push @translated_contents, $translated_content;
Lines 159-168 elsif ( $op eq 'add_validate' ) { Link Here
159
162
160
                if ( C4::Context->preference("NewsLog") ) {
163
                if ( C4::Context->preference("NewsLog") ) {
161
                    my @existing_ids = $existing_contents->get_column('id');
164
                    my @existing_ids = $existing_contents->get_column('id');
162
                    my @deleted_ids = array_minus( @existing_ids, @seen_ids );
165
                    my @deleted_ids  = array_minus( @existing_ids, @seen_ids );
163
                    for my $id ( @deleted_ids ) {
166
                    for my $id (@deleted_ids) {
164
                        my $c = $existing_contents->find($id);
167
                        my $c = $existing_contents->find($id);
165
                        logaction('NEWS', 'DELETE' , undef, sprintf("%s|%s|%s", $code, $c->lang, $c->content));
168
                        logaction( 'NEWS', 'DELETE', undef, sprintf( "%s|%s|%s", $code, $c->lang, $c->content ) );
166
                    }
169
                    }
167
                }
170
                }
168
171
Lines 171-177 elsif ( $op eq 'add_validate' ) { Link Here
171
        );
174
        );
172
    } catch {
175
    } catch {
173
        warn $_;
176
        warn $_;
174
        if ( $id ) {
177
        if ($id) {
175
            push @messages, { type => 'error', code => 'error_on_update' };
178
            push @messages, { type => 'error', code => 'error_on_update' };
176
        } else {
179
        } else {
177
            push @messages, { type => 'error', code => 'error_on_insert' };
180
            push @messages, { type => 'error', code => 'error_on_insert' };
178
- 

Return to bug 31383