[Rt-commit] rt branch 5.0/allow-html-signatures created. rt-5.0.2-73-gf80550c011
BPS Git Server
git at git.bestpractical.com
Fri Feb 18 14:29:46 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/allow-html-signatures has been created
at f80550c01137949d0ffb25bbee52d110f50aaa0f (commit)
- Log -----------------------------------------------------------------
commit f80550c01137949d0ffb25bbee52d110f50aaa0f
Author: Brian Conry <bconry at bestpractical.com>
Date: Thu Feb 10 17:40:53 2022 -0600
Allow HTML signatures
If the user has their preferences set so that they use the WYSIWYG
editor for ticket updates then the signature textarea in their
Preferences will also be a WYSIWYG editor, allowing them to create an
HTML signature.
Signatures are automatically upconverted from plain text to HTML either
when the preferences are updated or each time corresponding on a ticket.
HTML signatures are automatically downconverted when they are added to a
plain text message.
diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 64662e98a2..b322f839c0 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -296,10 +296,17 @@
</&>
%if (!$Create && $UserObj->Privileged) {
+% my $sig = $UserObj->Signature//$ARGS{Signature}//'';
+% my $richtext = '';
<&| /Widgets/TitleBox, title => loc('Signature'), class => 'user-info-signature' &>
<div class="form-row">
<div class="col-12">
- <textarea class="signature form-control" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature//$ARGS{Signature}//''%></textarea>
+% if (RT->Config->Get('MessageBoxRichText', $UserObj )) {
+% # allow for a smooth transition from a plain text signature, with or without HTML content, to an HTML signature
+ <input type="text" style="display:none" name="SignatureType" id="SignatureType" value="<%$sig =~ /<.{1,5}>/ ? "text/html" : 'text/plain'%>"/>
+% $richtext = ' richtext';
+% }
+ <textarea class="signature form-control<%$richtext%>" rows="5" name="Signature" wrap="hard"><%$sig%></textarea>
</div>
</div>
</&>
diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index ce985aa51b..fca9dc41ec 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -79,14 +79,24 @@ if ( $IncludeSignature and $signature =~ /\S/ ) {
$signature =~ s/\n*$//;
if ($Type eq 'text/html') {
- $signature =~ s/&/&/g;
- $signature =~ s/</</g;
- $signature =~ s/>/>/g;
- $signature =~ s/"/"/g; # "//;
- $signature =~ s/'/'/g; # '//;
- $signature =~ s{\n}{<br />}g;
- $signature = "<p> </p><p>-- <br />$signature</p>";
+ # only transform the signature if it doesn't look like HTML
+ if ($signature !~ /<.{1,5}>/) {
+ $signature =~ s/&/&/g;
+ $signature =~ s/</</g;
+ $signature =~ s/>/>/g;
+ $signature =~ s/"/"/g; # "//;
+ $signature =~ s/'/'/g; # '//;
+ $signature =~ s{\n}{<br />}g;
+ $signature = "<p> </p><p>-- <br />$signature</p>";
+ }
+ else {
+ $signature = "<p> </p><p>-- </p>$signature";
+ }
} else {
+ # only transform the signature if it *does* look like HTML
+ if ($signature =~ /<.{1,5}>/) {
+ $signature = RT::Interface::Email::ConvertHTMLToText($signature);
+ }
$signature = "\n\n-- \n". $signature . "\n";
}
diff --git a/share/html/Prefs/Elements/EditAboutMe b/share/html/Prefs/Elements/EditAboutMe
index cf66ad656a..d13f161a26 100644
--- a/share/html/Prefs/Elements/EditAboutMe
+++ b/share/html/Prefs/Elements/EditAboutMe
@@ -248,10 +248,17 @@
</div>
%if ($UserObj->Privileged) {
+% my $sig = $UserObj->Signature || '';
+% my $richtext = '';
<div class="form-row">
<div class="col-6">
<&| /Widgets/TitleBox, title => loc('Signature'), id => "user-prefs-signature" &>
- <textarea class="form-control signature" cols="80" rows="5" name="Signature" wrap="hard"><%$UserObj->Signature || ''%></textarea>
+% if (RT->Config->Get('MessageBoxRichText', $session{'CurrentUser'})) {
+% # allow for a smooth transition from a plain text signature, with or without HTML content, to an HTML signature
+ <input type="text" style="display:none" name="SignatureType" id="SignatureType" value="<%$sig =~ /<.{1,5}>/ ? "text/html" : 'text/plain'%>"/>
+% $richtext = ' richtext';
+% }
+ <textarea class="form-control signature<%$richtext%>" cols="80" rows="5" name="Signature" wrap="hard"><%$sig%></textarea>
</&>
</div>
</div>
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list