'
},
+ { Queue => '0',
+ Name => 'AutoreplyOrCorrespondence', # loc
+ Description => 'Plaintext AutoreplyOrCorrespondence template', # loc
+ Content => q[{
+ use RT::Template;
+ my $creator_name = $Ticket->CreatorObj->Name;
+ my $requestors = $Ticket->Requestors->UserMembersObj;
+ my ( $c_requestor, $r_count ) = ( 0, 0 );
+ while ( my $r = $requestors->Next() ) {
+ if ( $r->Name eq $creator_name ) {
+ $c_requestor++;
+ }
+ else {
+ $r_count++;
+ }
+ }
+ my $template = new RT::Template($RT::SystemUser);
+ my $template_name;
+
+ #if the creator is not a requestor or
+ #there is more than one requestor ( who's not the creator )
+ #use the Correspondence template
+ if ( ! $c_requestor || $r_count ) {
+ $template_name = 'Correspondence';
+ }
+ else {
+ #otherwise use the Autoreply template
+ $template_name = 'Autoreply';
+ }
+
+ #Load the Queue Template
+ $template->LoadQueueTemplate(
+ Queue => $Ticket->Queue,
+ Name => $template_name,
+ );
+ #if there's no Queue Template attempt to find a Global one.
+ unless ( $template->id ) {
+ $template->LoadGlobalTemplate( $template_name );
+ unless ( $template->id ) {
+ $RT::Logger->error("Could not load template : $template_name")
+ }
+ }
+ #Process embedded fields & expressions of true templates;
+ #note that we can only meaningfully use the body
+ my($ret, $msg) = $template->Parse(
+ TicketObj => $Ticket,
+ TransactionObj => $Transaction,
+ );
+ $ret ? $template->MIMEObj->stringify : $msg;
+ }
+],
+ },
+ { Queue => '0',
+ Name => 'AutoreplyOrCorrespondence in HTML', # loc
+ Description => 'HTML AutoreplyOrCorrespondence template', # loc
+ Content => q[{
+ use RT::Template;
+ my $creator_name = $Ticket->CreatorObj->Name;
+ my $requestors = $Ticket->Requestors->UserMembersObj;
+ my ( $c_requestor, $r_count ) = ( 0, 0 );
+ while ( my $r = $requestors->Next() ) {
+ if ( $r->Name eq $creator_name ) {
+ $c_requestor++;
+ }
+ else {
+ $r_count++;
+ }
+ }
+ my $template = new RT::Template($RT::SystemUser);
+ my $template_name;
+
+ #if the creator is not a requestor or
+ #there is more than one requestor ( who's not the creator )
+ #use the Correspondence template
+ if ( ! $c_requestor || $r_count ) {
+ $template_name = 'Correspondence in HTML';
+ }
+ else {
+ #otherwise use the Autoreply in HTML template
+ $template_name = 'Autoreply in HTML';
+ }
+
+ #Load the Queue Template
+ $template->LoadQueueTemplate(
+ Queue => $Ticket->Queue,
+ Name => $template_name,
+ );
+ #if there's no Queue Template attempt to find a Global one.
+ unless ( $template->id ) {
+ $template->LoadGlobalTemplate( $template_name );
+ unless ( $template->id ) {
+ $RT::Logger->error("Could not load template : $template_name")
+ }
+ }
+ #Process embedded fields & expressions of true templates;
+ #note that we can only meaningfully use the body
+ my($ret, $msg) = $template->Parse(
+ TicketObj => $Ticket,
+ TransactionObj => $Transaction,
+ );
+ $ret ? $template->MIMEObj->stringify : $msg;
+ }
+],
+ },
{ Queue => '0',
Name => 'Transaction', # loc
Description => 'Default transaction template', # loc
OrderBy => 'LastUpdated',
Order => 'DESC' },
},
- { Name => 'HomepageSettings',
- Description => 'HomepageSettings',
- Content =>
- { 'body' => # loc
- [ { type => 'system', name => 'My Tickets' },
- { type => 'system', name => 'Unowned Tickets' },
- { type => 'system', name => 'Bookmarked Tickets' },
- { type => 'component', name => 'QuickCreate' },
- ],
- 'summary' => # loc
- [
- { type => 'component', name => 'MyReminders' },
- { type => 'component', name => 'Quicksearch' },
- { type => 'component', name => 'Dashboards' },
- { type => 'component', name => 'RefreshHomepage' },
- ],
- },
+ {
+ Name => 'HomepageSettings',
+ Description => 'HomepageSettings',
+ Content => {
+ 'body' => # loc
+ [
+ {
+ type => 'system',
+ name => 'My Tickets', # loc
+ },
+ {
+ type => 'system',
+ name => 'Unowned Tickets' # loc
+ },
+ {
+ type => 'system',
+ name => 'Bookmarked Tickets' # loc
+ },
+ {
+ type => 'component',
+ name => 'QuickCreate' # loc
+ },
+ ],
+ 'summary' => # loc
+ [
+ {
+ type => 'component',
+ name => 'MyReminders' # loc
+ },
+ {
+ type => 'component',
+ name => 'Quicksearch' # loc
+ },
+ {
+ type => 'component',
+ name => 'Dashboards' # loc
+ },
+ {
+ type => 'component',
+ name => 'RefreshHomepage' # loc
+ },
+ ],
+ },
},
);
}
);
+# -*- perl -*-
+
+push @ScripActions, (
+
+ { Name => 'Extract Custom Field Values', # loc
+ Description => 'extract cf-values out of a message', # loc
+ ExecModule => 'ExtractCustomFieldValues' },
+
+ { Name => 'Extract Custom Field Values With Code in Template', # loc
+ Description => 'extract cf-values out of a message with a Text::Template template', # loc
+ ExecModule => 'ExtractCustomFieldValuesWithCodeInTemplate' }
+
+);
+
+push @Templates, (
+ { Queue => '0',
+ Name => 'CustomFieldScannerExample', # loc
+ Description => 'Example Template for ExtractCustomFieldValues', # loc
+ Content => <<'EOTEXT'
+#### Syntax:
+# CF Name | Header name or "Body" | MatchString(re) | Postcmd | Options
+
+#### Allowed Options:
+
+# q - (quiet) Don't record a transaction for adding the custom field
+# value
+# * - (wildcard) The MatchString regex should contain _two_
+# capturing groups, the first of which is the CF name,
+# the second of which is the value. If this option is
+# given, the <cf-name> field is ignored.
+
+#### Examples:
+
+# 1. Put the content of the "X-MI-Test" header into the "testcf"
+# custom field:
+# testcf|X-MI-Test|.*
+
+# 2. Scan the body for Host:name and put name into the "bodycf" custom
+# field:
+# bodycf|Body|Host:\s*(\w+)
+
+# 3. Scan the "X-MI-IP" header for an IP-Adresse and get the hostname
+# by reverse-resolving it:
+# Hostname|X-MI-IP|\d+\.\d+\.\d+\.\d+|use Socket; ($value) = gethostbyaddr(inet_aton($value),AF_INET);
+
+# 4. scan the "CC" header for an many email addresses, and add them to
+# a custom field named "parsedCCs". If "parsedCCs" is a multivalue
+# CF, then this should yield separate values for all email adress
+# found.
+# parsedCCs|CC|.*|$value =~ s/^\s+//; $value =~ s/\s+$//;
+
+# 5. Looks for an "Email:" field in the body of the email, then loads
+# up that user and makes them privileged The blank first field
+# means the automatic CustomField setting is not invoked.
+# |Body|Email:\s*(.+)$|my $u = RT::User->new($RT::SystemUser); $u->LoadByEmail($value); $u->SetPrivileged(1)|
+
+# 6. Looks for any text of the form "Set CF Name: Value" in the body,
+# and sets the CF named "CF Name" to the given value, which may be
+# multi-line. The '*' option controls the wildcard nature of this
+# example.
+# Separator=!
+# !Body!^Set ([^\n:]*?):\s*((?s).*?)(?:\Z|\n\Z|\n\n)!!*
+
+# 7. Looks for the regex anywhere in the headers and stores the match
+# in the AllHeaderSearch CF
+# AllHeaderSearch|Headers|Site:\s*(\w+)
+
+# 8. If you need to dynamically build your matching, and want to trigger on headers and body
+# and invode some arbitrary code like example 5
+# Separator=~~
+# {
+# my $action = 'use My::Site; My::Site::SetSiteID( Ticket => $self->TicketObj, Site => $_ );';
+#
+# for my $regex (My::Site::ValidRegexps) {
+# for my $from ('headers', 'body') {
+# $OUT .= join '~~',
+# '', # CF name
+# $from,
+# $regex,
+# $action;
+# $OUT .= "\n";
+# }
+# }
+# }
+
+EOTEXT
+ }
+);
+
+1;