[Rt-commit] rt branch 5.0/allow-rich-text-signatures created. rt-5.0.2-62-ge2cad8f6cf

BPS Git Server git at git.bestpractical.com
Tue Feb 15 15:06:56 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-rich-text-signatures has been created
        at  e2cad8f6cfb032c0e6e923dabb2a0505f300ed4c (commit)

- Log -----------------------------------------------------------------
commit e2cad8f6cfb032c0e6e923dabb2a0505f300ed4c
Author: Brian Conry <bconry at bestpractical.com>
Date:   Thu Feb 10 17:40:53 2022 -0600

    Allow rich text 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 a
    rich text signature.
    
    Signatures are automatically upconverted from plain text to rich text
    either when the preferences are updated or each time corresponding on a
    ticket.
    
    Rich text 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..164687b6d3 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 a rich text 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..1003287284 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 a rich text 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