Merge branch 'master' of https://github.com/jgoodman/Freeside
[freeside.git] / rt / lib / RT / Template.pm
1 # BEGIN BPS TAGGED BLOCK {{{
2 #
3 # COPYRIGHT:
4 #
5 # This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
6 #                                          <sales@bestpractical.com>
7 #
8 # (Except where explicitly superseded by other copyright notices)
9 #
10 #
11 # LICENSE:
12 #
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
16 # from www.gnu.org.
17 #
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 # General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 #
29 #
30 # CONTRIBUTION SUBMISSION POLICY:
31 #
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
37 #
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
46 #
47 # END BPS TAGGED BLOCK }}}
48
49 # Portions Copyright 2000 Tobias Brox <tobix@cpan.org> 
50
51 =head1 NAME
52
53   RT::Template - RT's template object
54
55 =head1 SYNOPSIS
56
57   use RT::Template;
58
59 =head1 DESCRIPTION
60
61
62 =head1 METHODS
63
64
65 =cut
66
67
68 package RT::Template;
69
70 use strict;
71 use warnings;
72
73
74
75 use Text::Template;
76 use MIME::Entity;
77 use MIME::Parser;
78 use Scalar::Util 'blessed';
79
80 sub _Accessible {
81     my $self = shift;
82     my %Cols = (
83         id            => 'read',
84         Name          => 'read/write',
85         Description   => 'read/write',
86         Type          => 'read/write',    #Type is one of Perl or Simple
87         Content       => 'read/write',
88         Queue         => 'read/write',
89         Creator       => 'read/auto',
90         Created       => 'read/auto',
91         LastUpdatedBy => 'read/auto',
92         LastUpdated   => 'read/auto'
93     );
94     return $self->SUPER::_Accessible( @_, %Cols );
95 }
96
97 sub _Set {
98     my $self = shift;
99     my %args = (
100         Field => undef,
101         Value => undef,
102         @_,
103     );
104     
105     unless ( $self->CurrentUserHasQueueRight('ModifyTemplate') ) {
106         return ( 0, $self->loc('Permission Denied') );
107     }
108
109     if (exists $args{Value}) {
110         if ($args{Field} eq 'Queue') {
111             if ($args{Value}) {
112                 # moving to another queue
113                 my $queue = RT::Queue->new( $self->CurrentUser );
114                 $queue->Load($args{Value});
115                 unless ($queue->Id and $queue->CurrentUserHasRight('ModifyTemplate')) {
116                     return ( 0, $self->loc('Permission Denied') );
117                 }
118             } else {
119                 # moving to global
120                 unless ($self->CurrentUser->HasRight( Object => RT->System, Right => 'ModifyTemplate' )) {
121                     return ( 0, $self->loc('Permission Denied') );
122                 }
123             }
124         }
125     }
126
127     return $self->SUPER::_Set( @_ );
128 }
129
130 =head2 _Value
131
132 Takes the name of a table column. Returns its value as a string,
133 if the user passes an ACL check, otherwise returns undef.
134
135 =cut
136
137 sub _Value {
138     my $self  = shift;
139
140     unless ( $self->CurrentUserCanRead() ) {
141         return undef;
142     }
143     return $self->__Value( @_ );
144
145 }
146
147 =head2 Load <identifier>
148
149 Load a template, either by number or by name.
150
151 Note that loading templates by name using this method B<is
152 ambiguous>. Several queues may have template with the same name
153 and as well global template with the same name may exist.
154 Use L</LoadGlobalTemplate> and/or L<LoadQueueTemplate> to get
155 precise result.
156
157 =cut
158
159 sub Load {
160     my $self       = shift;
161     my $identifier = shift;
162     return undef unless $identifier;
163
164     if ( $identifier =~ /\D/ ) {
165         return $self->LoadByCol( 'Name', $identifier );
166     }
167     return $self->LoadById( $identifier );
168 }
169
170 =head2 LoadGlobalTemplate NAME
171
172 Load the global template with the name NAME
173
174 =cut
175
176 sub LoadGlobalTemplate {
177     my $self = shift;
178     my $name = shift;
179
180     return ( $self->LoadQueueTemplate( Queue => 0, Name => $name ) );
181 }
182
183 =head2 LoadQueueTemplate (Queue => QUEUEID, Name => NAME)
184
185 Loads the Queue template named NAME for Queue QUEUE.
186
187 Note that this method doesn't load a global template with the same name
188 if template in the queue doesn't exist. THe following code can be used:
189
190     $template->LoadQueueTemplate( Queue => $queue_id, Name => $template_name );
191     unless ( $template->id ) {
192         $template->LoadGlobalTemplate( $template_name );
193         unless ( $template->id ) {
194             # no template
195             ...
196         }
197     }
198     # ok, template either queue's or global
199     ...
200
201 =cut
202
203 sub LoadQueueTemplate {
204     my $self = shift;
205     my %args = (
206         Queue => undef,
207         Name  => undef,
208         @_
209     );
210
211     return ( $self->LoadByCols( Name => $args{'Name'}, Queue => $args{'Queue'} ) );
212
213 }
214
215 =head2 Create
216
217 Takes a paramhash of Content, Queue, Name and Description.
218 Name should be a unique string identifying this Template.
219 Description and Content should be the template's title and content.
220 Queue should be 0 for a global template and the queue # for a queue-specific 
221 template.
222
223 Returns the Template's id # if the create was successful. Returns undef for
224 unknown database failure.
225
226 =cut
227
228 sub Create {
229     my $self = shift;
230     my %args = (
231         Content     => undef,
232         Queue       => 0,
233         Description => '[no description]',
234         Type        => 'Perl',
235         Name        => undef,
236         @_
237     );
238
239     if ( $args{Type} eq 'Perl' && !$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System) ) {
240         return ( undef, $self->loc('Permission Denied') );
241     }
242
243     unless ( $args{'Queue'} ) {
244         unless ( $self->CurrentUser->HasRight(Right =>'ModifyTemplate', Object => $RT::System) ) {
245             return ( undef, $self->loc('Permission Denied') );
246         }
247         $args{'Queue'} = 0;
248     }
249     else {
250         my $QueueObj = RT::Queue->new( $self->CurrentUser );
251         $QueueObj->Load( $args{'Queue'} ) || return ( undef, $self->loc('Invalid queue') );
252     
253         unless ( $QueueObj->CurrentUserHasRight('ModifyTemplate') ) {
254             return ( undef, $self->loc('Permission Denied') );
255         }
256         $args{'Queue'} = $QueueObj->Id;
257     }
258
259     my ( $result, $msg ) = $self->SUPER::Create(
260         Content     => $args{'Content'},
261         Queue       => $args{'Queue'},
262         Description => $args{'Description'},
263         Name        => $args{'Name'},
264         Type        => $args{'Type'},
265     );
266
267     if ( wantarray ) {
268         return ( $result, $msg );
269     } else {
270         return ( $result );
271     }
272
273 }
274
275 =head2 Delete
276
277 Delete this template.
278
279 =cut
280
281 sub Delete {
282     my $self = shift;
283
284     unless ( $self->CurrentUserHasQueueRight('ModifyTemplate') ) {
285         return ( 0, $self->loc('Permission Denied') );
286     }
287
288     return ( $self->SUPER::Delete(@_) );
289 }
290
291 =head2 IsEmpty
292
293 Returns true value if content of the template is empty, otherwise
294 returns false.
295
296 =cut
297
298 sub IsEmpty {
299     my $self = shift;
300     my $content = $self->Content;
301     return 0 if defined $content && length $content;
302     return 1;
303 }
304
305 =head2 MIMEObj
306
307 Returns L<MIME::Entity> object parsed using L</Parse> method. Returns
308 undef if last call to L</Parse> failed or never be called.
309
310 Note that content of the template is UTF-8, but L<MIME::Parser> is not
311 good at handling it and all data of the entity should be treated as
312 octets and converted to perl strings using Encode::decode_utf8 or
313 something else.
314
315 =cut
316
317 sub MIMEObj {
318     my $self = shift;
319     return ( $self->{'MIMEObj'} );
320 }
321
322 =head2 Parse
323
324 This routine performs L<Text::Template> parsing on the template and then
325 imports the results into a L<MIME::Entity> so we can really use it. Use
326 L</MIMEObj> method to get the L<MIME::Entity> object.
327
328 Takes a hash containing Argument, TicketObj, and TransactionObj and other
329 arguments that will be available in the template's code. TicketObj and
330 TransactionObj are not mandatory, but highly recommended.
331
332 It returns a tuple of (val, message). If val is false, the message contains
333 an error message.
334
335 =cut
336
337 sub Parse {
338     my $self = shift;
339     my ($rv, $msg);
340
341
342     if (not $self->IsEmpty and $self->Content =~ m{^Content-Type:\s+text/html\b}im) {
343         local $RT::Transaction::PreferredContentType = 'text/html';
344         ($rv, $msg) = $self->_Parse(@_);
345     }
346     else {
347         ($rv, $msg) = $self->_Parse(@_);
348     }
349
350     return ($rv, $msg) unless $rv;
351
352     my $mime_type   = $self->MIMEObj->mime_type;
353     if (defined $mime_type and $mime_type eq 'text/html') {
354         $self->_DowngradeFromHTML(@_);
355     }
356
357     return ($rv, $msg);
358 }
359
360 sub _Parse {
361     my $self = shift;
362
363     # clear prev MIME object
364     $self->{'MIMEObj'} = undef;
365
366     #We're passing in whatever we were passed. it's destined for _ParseContent
367     my ($content, $msg) = $self->_ParseContent(@_);
368     return ( 0, $msg ) unless defined $content && length $content;
369
370     if ( $content =~ /^\S/s && $content !~ /^\S+:/ ) {
371         $RT::Logger->error(
372             "Template #". $self->id ." has leading line that doesn't"
373             ." look like header field, if you don't want to override"
374             ." any headers and don't want to see this error message"
375             ." then leave first line of the template empty"
376         );
377         $content = "\n".$content;
378     }
379
380     my $parser = MIME::Parser->new();
381     $parser->output_to_core(1);
382     $parser->tmp_to_core(1);
383     $parser->use_inner_files(1);
384
385     ### Should we forgive normally-fatal errors?
386     $parser->ignore_errors(1);
387     # MIME::Parser doesn't play well with perl strings
388     utf8::encode($content);
389     $self->{'MIMEObj'} = eval { $parser->parse_data( \$content ) };
390     if ( my $error = $@ || $parser->last_error ) {
391         $RT::Logger->error( "$error" );
392         return ( 0, $error );
393     }
394
395     # Unfold all headers
396     $self->{'MIMEObj'}->head->unfold;
397     $self->{'MIMEObj'}->head->modify(1);
398
399     return ( 1, $self->loc("Template parsed") );
400
401 }
402
403 # Perform Template substitutions on the template
404
405 sub _ParseContent {
406     my $self = shift;
407     my %args = (
408         Argument       => undef,
409         TicketObj      => undef,
410         TransactionObj => undef,
411         @_
412     );
413
414     unless ( $self->CurrentUserCanRead() ) {
415         return (undef, $self->loc("Permission Denied"));
416     }
417
418     if ( $self->IsEmpty ) {
419         return ( undef, $self->loc("Template is empty") );
420     }
421
422     my $content = $self->SUPER::_Value('Content');
423     # We need to untaint the content of the template, since we'll be working
424     # with it
425     $content =~ s/^(.*)$/$1/;
426
427     $args{'Ticket'} = delete $args{'TicketObj'} if $args{'TicketObj'};
428     $args{'Transaction'} = delete $args{'TransactionObj'} if $args{'TransactionObj'};
429     $args{'Requestor'} = eval { $args{'Ticket'}->Requestors->UserMembersObj->First->Name }
430         if $args{'Ticket'};
431     $args{'rtname'}    = RT->Config->Get('rtname');
432     if ( $args{'Ticket'} ) {
433         my $t = $args{'Ticket'}; # avoid memory leak
434         $args{'loc'} = sub { $t->loc(@_) };
435     } else {
436         $args{'loc'} = sub { $self->loc(@_) };
437     }
438
439     if ($self->Type eq 'Perl') {
440         return $self->_ParseContentPerl(
441             Content      => $content,
442             TemplateArgs => \%args,
443         );
444     }
445     else {
446         return $self->_ParseContentSimple(
447             Content      => $content,
448             TemplateArgs => \%args,
449         );
450     }
451 }
452
453 # uses Text::Template for Perl templates
454 sub _ParseContentPerl {
455     my $self = shift;
456     my %args = (
457         Content      => undef,
458         TemplateArgs => {},
459         @_,
460     );
461
462     foreach my $key ( keys %{ $args{TemplateArgs} } ) {
463         my $val = $args{TemplateArgs}{ $key };
464         next unless ref $val;
465         next if ref($val) =~ /^(ARRAY|HASH|SCALAR|CODE)$/;
466         $args{TemplateArgs}{ $key } = \$val;
467     }
468
469     my $template = Text::Template->new(
470         TYPE   => 'STRING',
471         SOURCE => $args{Content},
472     );
473     my $is_broken = 0;
474     my $retval = $template->fill_in(
475         HASH => $args{TemplateArgs},
476         BROKEN => sub {
477             my (%args) = @_;
478             $RT::Logger->error("Template parsing error: $args{error}")
479                 unless $args{error} =~ /^Died at /; # ignore intentional die()
480             $is_broken++;
481             return undef;
482         },
483     );
484     return ( undef, $self->loc('Template parsing error') ) if $is_broken;
485
486     return ($retval);
487 }
488
489 sub _ParseContentSimple {
490     my $self = shift;
491     my %args = (
492         Content      => undef,
493         TemplateArgs => {},
494         @_,
495     );
496
497     $self->_MassageSimpleTemplateArgs(%args);
498
499     my $template = Text::Template->new(
500         TYPE   => 'STRING',
501         SOURCE => $args{Content},
502     );
503     my ($ok) = $template->compile;
504     return ( undef, $self->loc('Template parsing error: [_1]', $Text::Template::ERROR) ) if !$ok;
505
506     # copied from Text::Template::fill_in and refactored to be simple variable
507     # interpolation
508     my $fi_r = '';
509     foreach my $fi_item (@{$template->{SOURCE}}) {
510         my ($fi_type, $fi_text, $fi_lineno) = @$fi_item;
511         if ($fi_type eq 'TEXT') {
512             $fi_r .= $fi_text;
513         } elsif ($fi_type eq 'PROG') {
514             my $fi_res;
515             my $original_fi_text = $fi_text;
516
517             # strip surrounding whitespace for simpler regexes
518             $fi_text =~ s/^\s+//;
519             $fi_text =~ s/\s+$//;
520
521             # if the codeblock is a simple $Variable lookup, use the value from
522             # the TemplateArgs hash...
523             if (my ($var) = $fi_text =~ /^\$(\w+)$/) {
524                 if (exists $args{TemplateArgs}{$var}) {
525                     $fi_res = $args{TemplateArgs}{$var};
526                 }
527             }
528
529             # if there was no substitution then just reinsert the codeblock
530             if (!defined $fi_res) {
531                 $fi_res = "{$original_fi_text}";
532             }
533
534             # If the value of the filled-in text really was undef,
535             # change it to an explicit empty string to avoid undefined
536             # value warnings later.
537             $fi_res = '' unless defined $fi_res;
538
539             $fi_r .= $fi_res;
540         }
541     }
542
543     return $fi_r;
544 }
545
546 sub _MassageSimpleTemplateArgs {
547     my $self = shift;
548     my %args = (
549         TemplateArgs => {},
550         @_,
551     );
552
553     my $template_args = $args{TemplateArgs};
554
555     if (my $ticket = $template_args->{Ticket}) {
556         for my $column (qw/Id Subject Type InitialPriority FinalPriority Priority TimeEstimated TimeWorked Status TimeLeft Told Starts Started Due Resolved RequestorAddresses AdminCcAddresses CcAddresses/) {
557             $template_args->{"Ticket".$column} = $ticket->$column;
558         }
559
560         $template_args->{"TicketQueueId"}   = $ticket->Queue;
561         $template_args->{"TicketQueueName"} = $ticket->QueueObj->Name;
562
563         $template_args->{"TicketOwnerId"}    = $ticket->Owner;
564         $template_args->{"TicketOwnerName"}  = $ticket->OwnerObj->Name;
565         $template_args->{"TicketOwnerEmailAddress"} = $ticket->OwnerObj->EmailAddress;
566
567         my $cfs = $ticket->CustomFields;
568         while (my $cf = $cfs->Next) {
569             $template_args->{"TicketCF" . $cf->Name} = $ticket->CustomFieldValuesAsString($cf->Name);
570         }
571     }
572
573     if (my $txn = $template_args->{Transaction}) {
574         for my $column (qw/Id TimeTaken Type Field OldValue NewValue Data Content Subject Description BriefDescription/) {
575             $template_args->{"Transaction".$column} = $txn->$column;
576         }
577
578         my $cfs = $txn->CustomFields;
579         while (my $cf = $cfs->Next) {
580             $template_args->{"TransactionCF" . $cf->Name} = $txn->CustomFieldValuesAsString($cf->Name);
581         }
582     }
583 }
584
585 sub _DowngradeFromHTML {
586     my $self = shift;
587     my $orig_entity = $self->MIMEObj;
588
589     my $new_entity = $orig_entity->dup; # this will fail badly if we go away from InCore parsing
590     $new_entity->head->mime_attr( "Content-Type" => 'text/plain' );
591     $new_entity->head->mime_attr( "Content-Type.charset" => 'utf-8' );
592
593     $orig_entity->head->mime_attr( "Content-Type" => 'text/html' );
594     $orig_entity->head->mime_attr( "Content-Type.charset" => 'utf-8' );
595     $orig_entity->make_multipart('alternative', Force => 1);
596
597     require HTML::FormatText;
598     require HTML::TreeBuilder;
599     require Encode;
600     # need to decode_utf8, see the doc of MIMEObj method
601     my $tree = HTML::TreeBuilder->new_from_content(
602         Encode::decode_utf8($new_entity->bodyhandle->as_string)
603     );
604     $new_entity->bodyhandle(MIME::Body::InCore->new(
605         \(scalar HTML::FormatText->new(
606             leftmargin  => 0,
607             rightmargin => 78,
608         )->format( $tree ))
609     ));
610     $tree->delete;
611
612     $orig_entity->add_part($new_entity, 0); # plain comes before html
613     $self->{MIMEObj} = $orig_entity;
614
615     return;
616 }
617
618 =head2 CurrentUserHasQueueRight
619
620 Helper function to call the template's queue's CurrentUserHasQueueRight with the passed in args.
621
622 =cut
623
624 sub CurrentUserHasQueueRight {
625     my $self = shift;
626     return ( $self->QueueObj->CurrentUserHasRight(@_) );
627 }
628
629 =head2 SetType
630
631 If setting Type to Perl, require the ExecuteCode right.
632
633 =cut
634
635 sub SetType {
636     my $self    = shift;
637     my $NewType = shift;
638
639     if ($NewType eq 'Perl' && !$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System)) {
640         return ( undef, $self->loc('Permission Denied') );
641     }
642
643     return $self->_Set( Field => 'Type', Value => $NewType );
644 }
645
646 =head2 SetContent
647
648 If changing content and the type is Perl, require the ExecuteCode right.
649
650 =cut
651
652 sub SetContent {
653     my $self       = shift;
654     my $NewContent = shift;
655
656     if ($self->Type eq 'Perl' && !$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System)) {
657         return ( undef, $self->loc('Permission Denied') );
658     }
659
660     return $self->_Set( Field => 'Content', Value => $NewContent );
661 }
662
663 sub _UpdateAttributes {
664     my $self = shift;
665     my %args = (
666         NewValues => {},
667         @_,
668     );
669
670     my $type = $args{NewValues}{Type} || $self->Type;
671
672     # forbid updating content when the (possibly new) value of Type is Perl
673     if ($type eq 'Perl' && exists $args{NewValues}{Content}) {
674         if (!$self->CurrentUser->HasRight(Right => 'ExecuteCode', Object => $RT::System)) {
675             return $self->loc('Permission Denied');
676         }
677     }
678
679     return $self->SUPER::_UpdateAttributes(%args);
680 }
681
682 =head2 CompileCheck
683
684 If the template's Type is Perl, then compile check all the codeblocks to see if
685 they are syntactically valid. We eval them in a codeblock to avoid actually
686 executing the code.
687
688 Returns an (ok, message) pair.
689
690 =cut
691
692 sub CompileCheck {
693     my $self = shift;
694
695     return (1, $self->loc("Template does not include Perl code"))
696         unless $self->Type eq 'Perl';
697
698     my $content = $self->Content;
699     $content = '' if !defined($content);
700
701     my $template = Text::Template->new(
702         TYPE   => 'STRING',
703         SOURCE => $content,
704     );
705     my ($ok) = $template->compile;
706     return ( undef, $self->loc('Template parsing error: [_1]', $Text::Template::ERROR) ) if !$ok;
707
708     # copied from Text::Template::fill_in and refactored to be compile checks
709     foreach my $fi_item (@{$template->{SOURCE}}) {
710         my ($fi_type, $fi_text, $fi_lineno) = @$fi_item;
711         next unless $fi_type eq 'PROG';
712
713         do {
714             no strict 'vars';
715             eval "sub { $fi_text }";
716         };
717         next if !$@;
718
719         my $error = $@;
720
721         # provide a (hopefully) useful line number for the error, but clean up
722         # all the other extraneous garbage
723         $error =~ s/\(eval \d+\) line (\d+).*/"template line " . ($1+$fi_lineno-1)/es;
724
725         return (0, $self->loc("Couldn't compile template codeblock '[_1]': [_2]", $fi_text, $error));
726     }
727
728     return (1, $self->loc("Template compiles"));
729 }
730
731 =head2 CurrentUserCanRead
732
733 =cut
734
735 sub CurrentUserCanRead {
736     my $self =shift;
737
738     return 1 if $self->CurrentUserHasQueueRight('ShowTemplate');
739
740     return $self->CurrentUser->HasRight( Right =>'ShowGlobalTemplates', Object => $RT::System )
741         if !$self->QueueObj->Id;
742
743     return;
744 }
745
746 1;
747
748 use RT::Queue;
749 use base 'RT::Record';
750
751 sub Table {'Templates'}
752
753
754
755
756
757
758 =head2 id
759
760 Returns the current value of id.
761 (In the database, id is stored as int(11).)
762
763
764 =cut
765
766
767 =head2 Queue
768
769 Returns the current value of Queue.
770 (In the database, Queue is stored as int(11).)
771
772
773
774 =head2 SetQueue VALUE
775
776
777 Set Queue to VALUE.
778 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
779 (In the database, Queue will be stored as a int(11).)
780
781
782 =cut
783
784
785 =head2 QueueObj
786
787 Returns the Queue Object which has the id returned by Queue
788
789
790 =cut
791
792 sub QueueObj {
793         my $self = shift;
794         my $Queue =  RT::Queue->new($self->CurrentUser);
795         $Queue->Load($self->__Value('Queue'));
796         return($Queue);
797 }
798
799 =head2 Name
800
801 Returns the current value of Name.
802 (In the database, Name is stored as varchar(200).)
803
804
805
806 =head2 SetName VALUE
807
808
809 Set Name to VALUE.
810 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
811 (In the database, Name will be stored as a varchar(200).)
812
813
814 =cut
815
816
817 =head2 Description
818
819 Returns the current value of Description.
820 (In the database, Description is stored as varchar(255).)
821
822
823
824 =head2 SetDescription VALUE
825
826
827 Set Description to VALUE.
828 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
829 (In the database, Description will be stored as a varchar(255).)
830
831
832 =cut
833
834
835 =head2 Type
836
837 Returns the current value of Type.
838 (In the database, Type is stored as varchar(16).)
839
840
841
842 =head2 SetType VALUE
843
844
845 Set Type to VALUE.
846 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
847 (In the database, Type will be stored as a varchar(16).)
848
849
850 =cut
851
852
853 =head2 Language
854
855 Returns the current value of Language.
856 (In the database, Language is stored as varchar(16).)
857
858
859
860 =head2 SetLanguage VALUE
861
862
863 Set Language to VALUE.
864 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
865 (In the database, Language will be stored as a varchar(16).)
866
867
868 =cut
869
870
871 =head2 TranslationOf
872
873 Returns the current value of TranslationOf.
874 (In the database, TranslationOf is stored as int(11).)
875
876
877
878 =head2 SetTranslationOf VALUE
879
880
881 Set TranslationOf to VALUE.
882 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
883 (In the database, TranslationOf will be stored as a int(11).)
884
885
886 =cut
887
888
889 =head2 Content
890
891 Returns the current value of Content.
892 (In the database, Content is stored as text.)
893
894
895
896 =head2 SetContent VALUE
897
898
899 Set Content to VALUE.
900 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
901 (In the database, Content will be stored as a text.)
902
903
904 =cut
905
906
907 =head2 LastUpdated
908
909 Returns the current value of LastUpdated.
910 (In the database, LastUpdated is stored as datetime.)
911
912
913 =cut
914
915
916 =head2 LastUpdatedBy
917
918 Returns the current value of LastUpdatedBy.
919 (In the database, LastUpdatedBy is stored as int(11).)
920
921
922 =cut
923
924
925 =head2 Creator
926
927 Returns the current value of Creator.
928 (In the database, Creator is stored as int(11).)
929
930
931 =cut
932
933
934 =head2 Created
935
936 Returns the current value of Created.
937 (In the database, Created is stored as datetime.)
938
939
940 =cut
941
942
943
944 sub _CoreAccessible {
945     {
946
947         id =>
948                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
949         Queue =>
950                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
951         Name =>
952                 {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
953         Description =>
954                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
955         Type =>
956                 {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
957         Language =>
958                 {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
959         TranslationOf =>
960                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
961         Content =>
962                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
963         LastUpdated =>
964                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
965         LastUpdatedBy =>
966                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
967         Creator =>
968                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
969         Created =>
970                 {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
971
972  }
973 };
974
975 RT::Base->_ImportOverlays();
976
977 1;