From 74e6ac10824bba9b7bbca974f1e24caf6dc64cd8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 29 Apr 2015 16:40:13 +0200 Subject: [PATCH] =?utf8?q?=C2=BBnotes=C2=AB=20in=20Kreditoren-/Debitorenbu?= =?utf8?q?chungen=20darf=20nicht=20HTML-formatiert=20sein?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Das Upgrade oe_ar_ap_delivery_orders_edit_notes_as_html hat versehentlich auch die Bemerkungsfelder in Debitoren- und Kreditorenbuchungen umformatiert, obwohl dort in den Masken kein HTML-Editor verwendet wird und auch nicht werden soll. Daher für alle rückgängig machen, die erzeugt wurden, bevor besagtes Update eingespielt wurde. --- ...r_ap_fix_notes_as_html_for_non_invoices.pl | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sql/Pg-upgrade2/ar_ap_fix_notes_as_html_for_non_invoices.pl diff --git a/sql/Pg-upgrade2/ar_ap_fix_notes_as_html_for_non_invoices.pl b/sql/Pg-upgrade2/ar_ap_fix_notes_as_html_for_non_invoices.pl new file mode 100644 index 000000000..4f40139e3 --- /dev/null +++ b/sql/Pg-upgrade2/ar_ap_fix_notes_as_html_for_non_invoices.pl @@ -0,0 +1,52 @@ +# @tag: ar_ap_fix_notes_as_html_for_non_invoices +# @description: Kreditoren-/Debitorenbuchungen: Bemerkungsfeld darf kein HTML sein +# @depends: oe_ar_ap_delivery_orders_edit_notes_as_html +package SL::DBUpgrade2::ar_ap_fix_notes_as_html_for_non_invoices; + +use strict; +use utf8; + +use SL::DBUtils; + +use parent qw(SL::DBUpgrade2::Base); + +sub fix_column { + my ($self, $table) = @_; + + my $sth = $self->dbh->prepare(qq|UPDATE $table SET notes = ? WHERE id = ?|) || $self->dberror; + + my $query = <dbh, $query)) { + next if !$row->{notes} || (($row->{notes} !~ m{^<[a-z]+>}) && ($row->{notes} !~ m{$})); + + my $new_content = $row->{notes}; + $new_content =~ s{^

|

$}{}gi; + $new_content =~ s{
}{\n}gi; + $new_content =~ s{

}{\n\n}gi; + $new_content = $::locale->unquote_special_chars('html', $new_content); + + $sth->execute($new_content, $row->{id}) if $new_content ne $row->{notes}; + } + + $sth->finish; +} + +sub run { + my ($self) = @_; + + $self->fix_column($_) for qw(ar ap); + + return 1; +} + +1; -- 2.20.1