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

(-)a/Koha/AdditionalContentsLocalization.pm (-13 lines)
Lines 150-168 sub published_on { Link Here
150
    return $self->additional_content->published_on(@params);
150
    return $self->additional_content->published_on(@params);
151
}
151
}
152
152
153
=head3 updated_on
154
155
    $c->updated_on;
156
157
Return the date of the last update of the content
158
159
=cut
160
161
sub updated_on {
162
    my ( $self, @params ) = @_;
163
    return $self->additional_content->updated_on(@params);
164
}
165
166
=head3 expirationdate
153
=head3 expirationdate
167
154
168
    $c->expirationdate;
155
    $c->expirationdate;
(-)a/Koha/Schema/Result/AdditionalContentsLocalization.pm (-2 / +18 lines)
Lines 66-71 the body of your additional content Link Here
66
66
67
lang
67
lang
68
68
69
=head2 updated_on
70
71
  data_type: 'timestamp'
72
  datetime_undef_if_invalid: 1
73
  default_value: current_timestamp
74
  is_nullable: 0
75
76
last modification
77
69
=cut
78
=cut
70
79
71
__PACKAGE__->add_columns(
80
__PACKAGE__->add_columns(
Lines 89-94 __PACKAGE__->add_columns( Link Here
89
  { data_type => "mediumtext", is_nullable => 0 },
98
  { data_type => "mediumtext", is_nullable => 0 },
90
  "lang",
99
  "lang",
91
  { data_type => "varchar", default_value => "", is_nullable => 0, size => 50 },
100
  { data_type => "varchar", default_value => "", is_nullable => 0, size => 50 },
101
  "updated_on",
102
  {
103
    data_type => "timestamp",
104
    datetime_undef_if_invalid => 1,
105
    default_value => \"current_timestamp",
106
    is_nullable => 0,
107
  },
92
);
108
);
93
109
94
=head1 PRIMARY KEY
110
=head1 PRIMARY KEY
Lines 140-147 __PACKAGE__->belongs_to( Link Here
140
);
156
);
141
157
142
158
143
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 08:09:35
159
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-03-08 09:59:00
144
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KRaaWslsavWVmDbZF/NwcQ
160
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7N/mHMqyPJJsYaA8V968wQ
145
161
146
sub koha_object_class {
162
sub koha_object_class {
147
    'Koha::AdditionalContentsLocalization';
163
    'Koha::AdditionalContentsLocalization';
(-)a/installer/data/mysql/atomicupdate/bug_31383.pl (-4 / +5 lines)
Lines 20-25 return { Link Here
20
                    `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content',
20
                    `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content',
21
                    `content` mediumtext NOT NULL COMMENT 'the body of your additional content',
21
                    `content` mediumtext NOT NULL COMMENT 'the body of your additional content',
22
                    `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang',
22
                    `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang',
23
                    `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
23
                    PRIMARY KEY (`id`),
24
                    PRIMARY KEY (`id`),
24
                    UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`),
25
                    UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`),
25
                    CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
26
                    CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
Lines 29-47 return { Link Here
29
30
30
            my $contents = $dbh->selectall_arrayref(q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode}, { Slice => {} });
31
            my $contents = $dbh->selectall_arrayref(q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode}, { Slice => {} });
31
            my $sth_insert = $dbh->prepare(q{
32
            my $sth_insert = $dbh->prepare(q{
32
                INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang)
33
                INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang, updated_on)
33
                VALUES(?, ?, ?, ?)
34
                VALUES(?, ?, ?, ?, ?)
34
            });
35
            });
35
            for my $content ( @$contents ) {
36
            for my $content ( @$contents ) {
36
                my $q = q{
37
                my $q = q{
37
                    SELECT title, content, lang, branchcode
38
                    SELECT title, content, lang, branchcode, updated_on
38
                    FROM additional_contents
39
                    FROM additional_contents
39
                    WHERE category=? AND code=? AND
40
                    WHERE category=? AND code=? AND
40
                };
41
                };
41
                $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
42
                $q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL";
42
                my $translated_contents = $dbh->selectall_arrayref($q, { Slice => {} }, $content->{category}, $content->{code}, defined $content->{branchcode} ? $content->{branchcode} : ());
43
                my $translated_contents = $dbh->selectall_arrayref($q, { Slice => {} }, $content->{category}, $content->{code}, defined $content->{branchcode} ? $content->{branchcode} : ());
43
                for my $translated_content ( @$translated_contents ) {
44
                for my $translated_content ( @$translated_contents ) {
44
                    $sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang});
45
                    $sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}, $translated_content->{updated_on});
45
                }
46
                }
46
            }
47
            }
47
            $dbh->do(q{
48
            $dbh->do(q{
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 216-221 CREATE TABLE `additional_contents_localizations` ( Link Here
216
  `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content',
216
  `title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content',
217
  `content` mediumtext NOT NULL COMMENT 'the body of your additional content',
217
  `content` mediumtext NOT NULL COMMENT 'the body of your additional content',
218
  `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang',
218
  `lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang',
219
  `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification',
219
  PRIMARY KEY (`id`),
220
  PRIMARY KEY (`id`),
220
  UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`),
221
  UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`),
221
  CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
222
  CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/tools/additional-contents.pl (-9 / +11 lines)
Lines 134-156 elsif ( $op eq 'add_validate' ) { Link Here
134
                    next unless $title || $content;
134
                    next unless $title || $content;
135
135
136
                    push @seen_ids, $id;
136
                    push @seen_ids, $id;
137
                    push @translated_contents,
137
                    my $translated_content = {
138
                      {
139
                        title   => $title,
138
                        title   => $title,
140
                        content => $content,
139
                        content => $content,
141
                        lang    => $lang,
140
                        lang    => $lang,
142
                      };
141
                    };
143
142
144
                    if ( C4::Context->preference("NewsLog") ) {
143
                    my $existing_content = $existing_contents->find($id);
145
                        my $existing_content = $existing_contents->find($id);
144
                    if ( $existing_content ) {
146
                        if ( $existing_content ) {
145
                        if ( $existing_content->title ne $title || $existing_content->content ne $content ) {
147
                            if ( $existing_content->title ne $title || $existing_content->content ne $content ) {
146
                            if ( C4::Context->preference("NewsLog") ) {
148
                                logaction('NEWS', 'MODIFY' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content));
147
                                logaction('NEWS', 'MODIFY' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content));
149
                            }
148
                            }
150
                        } else {
149
                        } else {
151
                            logaction('NEWS', 'ADD' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content))
150
                            $translated_content->{updated_on} = $existing_content->updated_on;
152
                        }
151
                        }
152
                    } elsif( C4::Context->preference("NewsLog") ) {
153
                        logaction('NEWS', 'ADD' , undef, sprintf("%s|%s|%s|%s", $code, $title, $lang, $content))
153
                    }
154
                    }
155
156
                    push @translated_contents, $translated_content;
154
                }
157
                }
155
158
156
                if ( C4::Context->preference("NewsLog") ) {
159
                if ( C4::Context->preference("NewsLog") ) {
157
- 

Return to bug 31383