[rt-devel] Using plain text in RT Articles for insertion on tickets

William J. Horka whorka at hmdc.harvard.edu
Thu Feb 14 16:06:29 EST 2013


Hello,

I'm not quite sure of the right place to send this, but I hope this 
might be of use to someone...

We have been using RTFM and RT Articles for a while to manage common 
responses that can be included in tickets (ala canned responses, stock 
answers, etc.). This saves our helpdesk staff time by allowing them to 
select the appropriate Article to include on a ticket reply/creation and 
having it inserted inline.

For this use of Articles we set up an "article body" custom field as 
type "Fill in one textarea" (so that the Article contents are all 
plaintext), configured the Articles' classes to insert only the custom 
field Value, and set the configuration value $ArticleOnTicketCreate=1.

But we ran into a couple problems using a plaintext custom field for the 
article body. Any time there were angle brackets in the text (like 
<this>), they would not be included in the text inserted into tickets, 
and the formatting of the article's text by Display.html was not right 
either.

I tracked this down to two files, and am submitting the attached patches 
(against RT 4.0.6) for consideration. If it is possible to conditionally 
enable/disable this code via a global configuration setting, it could be 
possible for RT users to select whether they prefer to use plain text or 
HTML in included article text.

Regards,
  -Bill
-------------- next part --------------
--- share/html/Articles/Article/Elements/Preformatted   2012-08-24 17:33:45.000000000 -0400
+++ local/html/Articles/Article/Elements/Preformatted   2012-08-17 17:45:40.000000000 -0400
@@ -115,9 +115,10 @@
         content => \$content,
     );
 
-    if ( $content =~ /<.{1,5}>/ ) {
-        $content = $de_htmlify->( $content );
-    }
+    # HMDC - do not try to parse anglebrackets as HTML
+    #if ( $content =~ /<.{1,5}>/ ) {
+    #    $content = $de_htmlify->( $content );
+    #}
     return $content;
 };
 
-------------- next part --------------
--- share/html/Elements/ShowCustomFields        2012-08-24 17:35:55.000000000 -0400
+++ local/html/Elements/ShowCustomFields        2012-08-21 16:20:47.000000000 -0400
@@ -102,7 +102,14 @@
         Object       => $Object,
     );
     if ( $m->comp_exists( $comp ) ) {
-        $m->comp( $comp, Object => $value );
+        # HMDC: display Articles ("article body" custom field) as plaintext
+        if ( $Object->{ '_class' } eq 'RT::Article' ) {
+            use HTML::Entities;
+            $m->out( '<pre>' . encode_entities($value->Content) . '</pre>' );
+        }
+        else {
+            $m->comp( $comp, Object => $value );
+        }
     } else {
         $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
     }


More information about the rt-devel mailing list