Commit d203cda7 authored by Jesse Vincent's avatar Jesse Vincent
Browse files

Merge commit

 r23030@truegrounds:  jesse | 2006-01-31 18:51:02 -0500
 * Added the ability to make custom fields link to and include content from other systems.
 r23031@truegrounds:  jesse | 2006-01-31 18:52:13 -0500
 * Added a note about the AHAH support
 r23050@truegrounds:  jesse | 2006-02-03 13:34:17 -0500
 * Added a bunch more callbacks for great justice.
 r23555@truegrounds:  jesse | 2006-02-09 14:19:23 -0500
 * missing _ in regex 
 r23569@truegrounds:  jesse | 2006-02-09 14:48:54 -0500
 * open links in new windows
 r23587@truegrounds:  jesse | 2006-02-09 23:13:22 -0500
 * Reminder editing updates
 
 r23593@truegrounds:  jesse | 2006-02-10 14:47:08 -0500
 * Force the content type inside a js comment
 r23594@truegrounds:  jesse | 2006-02-10 14:49:27 -0500
 * wrap the mason directive for setting the content type in a js comment
 
 r23812@truegrounds:  jesse | 2006-02-16 14:42:23 -0500
 * Chaldea release engineering
 r23814@truegrounds:  jesse | 2006-02-16 16:33:40 -0500
 * try to make rt.js do the right thing with headers
 r23826@truegrounds:  jesse | 2006-02-16 21:25:05 -0500
 * Backport tickets_overlay from 3.5. Fix a bug that stopped search on global custom fields
 r23835@truegrounds:  jesse | 2006-02-17 13:02:28 -0500
 * Chaldea r7
 r24473@truegrounds:  jesse | 2006-02-21 14:05:29 -0500
  r24470@truegrounds:  jesse | 2006-02-21 13:50:15 -0500
   r23039@truegrounds (orig r4459):  alexmv | 2006-01-31 21:33:58 -0500
    r8863@zoq-fot-pik:  chmrr | 2006-01-31 21:33:12 -0500
     * Collapse ForceOwner and Owner
     * Fix updating of (Admin)Ccs
     * Default UpdateType to 'correspond'
     * Default content-type to 'text/plain'
   
   r23040@truegrounds (orig r4460):  alexmv | 2006-01-31 23:42:36 -0500
    r8868@zoq-fot-pik:  chmrr | 2006-01-31 22:24:18 -0500
     * Untabify and adjust indenting in one or two places
   
   r23041@truegrounds (orig r4461):  alexmv | 2006-01-31 23:42:41 -0500
    r8869@zoq-fot-pik:  chmrr | 2006-01-31 23:41:57 -0500
     * Custom field updating during processing
     * Better error handling when ticket id doesn't exist during update
   
   r23082@truegrounds (orig r4473):  alexmv | 2006-02-03 14:32:54 -0500
    r8895@zoq-fot-pik:  chmrr | 2006-02-03 14:32:05 -0500
     * 'id' is not longer required to be the first column.  In fact, it's
    not required at all.  Blank or non-existant 'id' columns will cause it
    to assume the ticket is new, and come up with an automatic template id
    for the row.
   
   r23515@truegrounds (orig r4504):  alexmv | 2006-02-08 15:01:17 -0500
    r8969@zoq-fot-pik:  chmrr | 2006-02-08 15:00:00 -0500
     * Whitespace fixes in Results.tsv
     * Spit out custom fields as CF-...
     * During offline upload parsing, try to treat date as ISO first,
       falling back to unknown
     * Keep offline upload form from tacking on an extra newline each
       submit
     * Minimize yo-yo-ing of status if possible
     * Allow false values as possible values, as long as they're defined
     * Cc, AdminCc, and Requestor may be either email addresses or users
   
   r23628@truegrounds (orig r4527):  alexmv | 2006-02-10 19:10:22 -0500
    r9038@zoq-fot-pik:  chmrr | 2006-02-10 19:09:21 -0500
     * Accept either singular or plural forms of requestor, cc, admincc
   
  
  r24472@truegrounds:  jesse | 2006-02-21 13:57:01 -0500
   r22894@truegrounds:  jesse | 2006-01-24 07:44:05 -0500
   * Note that our SQLite dependency is 1.0
   r22958@truegrounds:  jesse | 2006-01-25 07:08:34 -0500
   From: Joop van de Wege <JoopvandeWege@mococo.nl>
   Message-Id: <20060125125248.1A97.JOOPVANDEWEGE@mococo.nl>
   
   > There is atleast one problem that I have spotted and that is that
   > schema.Oracle contains two empty lines in CREATE TABLE
   > ObjectCustomFieldValues which don't belong there.
   > That is the second set of errors you get. The first is an indication
   > that an sequence with that name already exists in the schema of that
   > Oracle users you're RT installing in.
   
   r22960@truegrounds:  jesse | 2006-01-25 07:47:07 -0500
   * a couple added lines of docs to the cli
   r22962@truegrounds:  jesse | 2006-01-25 08:18:09 -0500
   * Updated mandatory fields for ticket creation forms
   r24471@truegrounds:  jesse | 2006-02-21 13:51:18 -0500
    r23026@truegrounds (orig r4448):  kevinr | 2006-01-30 19:25:47 -0500
     r10537@SAD-GIRL-IN-SNOW:  kevinr | 2006-01-30 19:20:52 -0500
     RT-Ticket: 7289
     RT-Status: resolved
     RT-Update: correspond
     
     Updated German translation (thanks to Thorsten Brumm)
    
    r23132@truegrounds (orig r4497):  alexmv | 2006-02-04 18:34:45 -0500
     r8936@zoq-fot-pik:  chmrr | 2006-02-04 18:24:38 -0500
      * Only rmtree if we have something to rm; keeps rmtree from
     complaining about 'Not root path(s) specified'
    
    r23133@truegrounds (orig r4498):  alexmv | 2006-02-04 18:34:51 -0500
     r8937@zoq-fot-pik:  chmrr | 2006-02-04 18:33:57 -0500
     RT-Ticket: 7329
     RT-Status: resolved
     RT-Update: correspond
     
      * Use SelectNewTicketQueue instead of SelectQueue

git-svn-id: svn+ssh://svn.bestpractical.com/svn/bps-public/rt/branches/3.5-TESTING@4562 e417ac7c-1bcc-0310-8ffa-8f5827389a85
parents 23df0f34 9dc85b67
......@@ -1687,13 +1687,15 @@ Text:
-t type Specifies object type.
-f a,b,c Restrict the display to the specified fields.
-S var=val Submits the specified variable with the request.
-v Verbose display
Examples:
rt show -t ticket -f id,subject,status 1-3
rt show ticket/3/attachments/29
rt show ticket/3/attachments/29/content
rt show ticket/1-3/links
rt show ticket/3/history
rt show -v ticket/3/history
rt show -t user 2
--
......
......@@ -95,7 +95,8 @@ if ($ENV{'MOD_PERL'} && !$RT::DevelMode) {
use File::Path qw( rmtree );
use File::Glob qw( bsd_glob );
rmtree([ bsd_glob("$RT::MasonDataDir/obj/*") ], 0, 1);
my @files = bsd_glob("$RT::MasonDataDir/obj/*");
rmtree([ @files ], 0, 1) if @files;
}
sub handler {
......
......@@ -320,12 +320,10 @@ CREATE TABLE ObjectCustomFieldValues (
ObjectType VARCHAR2(25) NOT NULL,
ObjectId NUMBER(11,0) DEFAULT 0 NOT NULL,
SortOrder NUMBER(11,0) DEFAULT 0 NOT NULL,
Content VARCHAR2(255),
LargeContent CLOB,
ContentType VARCHAR2(80),
ContentEncoding VARCHAR2(80),
Creator NUMBER(11,0) DEFAULT 0 NOT NULL,
Created DATE,
LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
......
......@@ -98,6 +98,32 @@
<input type="checkbox" class="checkbox" name="Enabled" value="1" <%$EnabledChecked%> /> <&|/l&>Enabled (Unchecking this box disables this custom field)</&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Link values to</&></td>
</td>
<td><input size="60" name="LinkValueTo" value="<%$CustomFieldObj->LinkValueTo%>" />
<div class="hints">
<&|/l&>RT can make this custom field's values into hyperlinks to another service.</&>
<&|/l&>Fill in this field with a URL.</&>
<&|/l&>RT will replace <tt>__id__</tt> and <tt>__CustomField__</tt> with the record id and custom field value, respectively</&>
</div>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Include page</&></td>
</td>
<td><input size="60" name="IncludeContentForValue" value="<%$CustomFieldObj->IncludeContentForValue%>" />
<div class="hints">
<&|/l&>RT can include content from another web service when showing this custom field.</&>
<&|/l&>Fill in this field with a URL.</&>
<&|/l&>RT will replace <tt>__id__</tt> and <tt>__CustomField__</tt> with the record id and custom field value, respectively</&>
<i><&|/l&>Some browsers may only load content from the same domain as your RT server.</&></i>
</div>
</td>
</tr>
</table>
<br />
% if ($CustomFieldObj->Id && $CustomFieldObj->IsSelectionType) {
......@@ -140,7 +166,7 @@ else {
$CustomFieldObj->Load($id) || $m->comp("/Elements/Error", Why => loc('No CustomField') );
$title = loc( 'Editing CustomField [_1]', $CustomFieldObj->Name() );
my @attribs = qw( Pattern Name TypeComposite LookupType Description);
my @attribs = qw( Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue);
my @aresults = UpdateRecordObject( AttributesRef => \@attribs,
Object => $CustomFieldObj,
ARGSRef => \%ARGS );
......
......@@ -51,7 +51,7 @@
<tr><td>
<&|/l&>Subject</&>:<br /><input size="15" name="Subject" />
</td><td>
<&|/l&>Queue</&>:<br /><& /Elements/SelectQueue, Name => 'Queue', ShowNullOption => 0 &>
<&|/l&>Queue</&>:<br /><& /Elements/SelectNewTicketQueue, Name => 'Queue', ShowNullOption => 0 &>
</td><td>
<&|/l&>Owner</&>:<br />
<select type="select" name="Owner">
......
......@@ -53,12 +53,33 @@
<ul>
% while (my $Value = $Values->Next()) {
<li>
% if ($CustomField->LinkValueTo) {
<a href="<%$Value->LinkValueTo|n%>" target="_new">
% }
% my $comp = "ShowCustomField".$CustomField->Type;
% if ($m->comp_exists($comp)) {
<& $comp, Object => $Value &>
% } else {
<%$Value->Content%>
% }
% if ($CustomField->LinkValueTo) {
</a>
% }
%# This section automatically populates a div with the "IncludeContentForValue" for this custom
%# field if it's been defined
% if ($CustomField->IncludeContentForValue) {
<div
class="object_cf_value_include"
id="object_cf_value_<%$Value->id%>"
>
<&|/l, '<a href="'.$Value->IncludeContentForValue.'">' . $Value->IncludeContentForValue."</a>"&>See also: [_1]</&>
</div>
<script><!--
ahah('<%$Value->IncludeContentForValue%>', 'object_cf_value_<%$Value->id%>');
--></script>
% }
</li>
% }
% unless ($Values->Count()) {
......
/*
% $r->content_type('application/x-javascript');
*/
// Fetched from http://www.opendarwin.org/~drernie/src/ahah.js
function ahah(url, target, delay) {
document.getElementById(target).innerHTML = 'Loading <a href="'+url+'">'+url +'</a>...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {ahahDone(url, target, delay);};
req.open("GET", url, true);
req.send("");
}
}
function ahahDone(url, target, delay) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
document.getElementById(target).innerHTML = req.responseText;
} else {
document.getElementById(target).innerHTML="Error loading '"+url+"':\n"+req.statusText;
}
if (delay != undefined) {
setTimeout("ahah(url,target,delay)", delay); // resubmit after delay
//server should ALSO delay before responding
}
}
}
% $m->abort();
......@@ -95,7 +95,7 @@ else {
$starts->SetToNow;
return [
"# Required: Queue, Requestor, Subject",
"# Required: id, Queue",
[ qw(id Queue Requestor Subject Cc AdminCc Owner Status Priority
InitialPriority FinalPriority TimeEstimated Starts Due Text) ],
{
......
......@@ -55,33 +55,36 @@ my @attrs = qw( id QueueObj->Name Subject Status TimeEstimated TimeWorked TimeLe
Requestors->MemberEmailAddressesAsString DueObj->ISO ToldObj->ISO
CreatedObj->ISO ResolvedObj->ISO );
$r->content_type('application/vnd.ms-excel');
while ( my $Ticket = $Tickets->Next()) {
my $row;
foreach my $attr (@attrs) {
my $method = '$Ticket->'.$attr.'()';
$row->{$attr} = eval $method;
$r->content_type('application/vnd.ms-excel');
while ( my $Ticket = $Tickets->Next()) {
my $row;
foreach my $attr (@attrs) {
if ($attr =~ /(.*)->ISO$/ and $Ticket->$1->Unix <= 0) {
$row->{$attr} = "";
} else {
my $method = '$Ticket->'.$attr.'()';
$row->{$attr} = eval $method;
if ($@) {die "Failed to find $attr - ". $@};
}
my $cfs = $Ticket->QueueObj->TicketCustomFields();
while (my $cf = $cfs->Next) {
my @content;
my $values = $Ticket->CustomFieldValues($cf->Id);
while (my $value = $values->Next) {
push @content, $value->Content;
}
$row->{'CustomField-'.$cf->Id} = join(', ',@content);
if ($row->{'CustomField-'.$cf->Id}) {
$known_cfs{$cf->Id} = $cf->Name;
}
}
push @rows, $row;
}
my $cfs = $Ticket->QueueObj->TicketCustomFields();
while (my $cf = $cfs->Next) {
my @content;
my $values = $Ticket->CustomFieldValues($cf->Id);
while (my $value = $values->Next) {
push @content, $value->Content;
}
$row->{'CustomField-'.$cf->Id} = join(', ',@content);
if ($row->{'CustomField-'.$cf->Id}) {
$known_cfs{$cf->Id} = $cf->Name;
}
}
push @rows, $row;
}
{
my @header;
my @header;
foreach my $attr (@attrs) {
my $label = $attr;
$label =~ s'Obj-.(?:AsString|Name|ISO)''g;
......@@ -89,27 +92,25 @@ my @header;
push @header, $label;
}
foreach my $id (sort keys %known_cfs) {
push @header, $known_cfs{$id};
push @header, "CF-".$known_cfs{$id};
}
$m->out(join("\t", @header));
$m->out("\n");
$m->out(join("\t", @header));
$m->out("\n");
}
foreach my $row (@rows) {
my @row;
foreach my $attr(@attrs) {
push @row, $row->{"$attr"};
}
foreach my $id (sort keys %known_cfs) {
my $val = $row->{'CustomField-'.$id};
$val =~ s/(\n|\r)//g;
push @row, $val;
}
$m->out(join("\t",@row));
$m->out("\n");
my @row;
foreach my $attr(@attrs) {
push @row, $row->{"$attr"};
}
foreach my $id (sort keys %known_cfs) {
my $val = $row->{'CustomField-'.$id};
$val =~ s/(\n|\r)//g;
push @row, $val;
}
$m->out(join("\t",@row));
$m->out("\n");
}
$m->abort();
</%INIT>
......@@ -52,6 +52,7 @@
actions => $actions &>
<form action="<%$RT::WebPath%>/Ticket/Create.html" method="post" enctype="multipart/form-data" name="TicketCreate">
<input type="hidden" class="hidden" name="id" value="new" />
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<div id="Ticket-Create-basics">
<a name="basics"></a>
......
......@@ -50,8 +50,8 @@
<& /Elements/ListActions, actions => \@results &>
<form method="post" action="Modify.html" enctype="multipart/form-data">
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" />
<&| /Widgets/TitleBox, title => loc('Modify ticket #[_1]',$TicketObj->Id) &>
<& Elements/EditBasics, TicketObj => $TicketObj &>
<& Elements/EditCustomFields, TicketObj => $TicketObj &>
......@@ -65,7 +65,7 @@ my $TicketObj = LoadTicket($id);
my $CustomFields = $TicketObj->QueueObj->TicketCustomFields();
# Now let callbacks have a chance at editing %ARGS
$m->comp('/Elements/Callback', TicketObj => $TicketObj, CustomFields => $CustomFields, %ARGS);
$m->comp('/Elements/Callback', TicketObj => $TicketObj, CustomFields => $CustomFields, ARGSRef => \%ARGS);
my @results = ProcessTicketBasics(TicketObj => $TicketObj, ARGSRef => \%ARGS);
my @cf_results = ProcessObjectCustomFieldUpdates(Object => $TicketObj, ARGSRef => \%ARGS);
......
......@@ -52,9 +52,9 @@
<& /Elements/ListActions, actions => \@results &>
<form method="post" action="ModifyAll.html" enctype="multipart/form-data">
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
<&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id) &>
<& Elements/EditBasics, TicketObj => $Ticket &>
<& Elements/EditCustomFields, TicketObj => $Ticket &>
......@@ -145,6 +145,7 @@ $CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
$Ticket->CurrentUserHasRight('ModifyTicket') );
$m->comp('/Elements/Callback', TicketObj => $Ticket, ARGSRef => \%ARGS);
my (@wresults, @results, @dresults, @lresults, @cf_results);
unless ($OnlySearchForPeople) {
......
......@@ -52,9 +52,9 @@
<& /Elements/ListActions, actions => \@results &>
<form method="post" action="ModifyDates.html">
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<input type="hidden" class="hidden" name="id" value="<%$TicketObj->Id%>" />
<&| /Widgets/TitleBox,title => loc('Modify dates for ticket # [_1]', $TicketObj->Id) &>
<& Elements/EditDates, TicketObj => $TicketObj &>
</&>
<& /Elements/Submit, Label => loc('Save Changes') &>
</form>
......@@ -63,6 +63,7 @@
<%INIT>
my $TicketObj = LoadTicket($id);
$m->comp('/Elements/Callback', TicketObj => $TicketObj, ARGSRef => \%ARGS);
my @results = ProcessTicketDates( TicketObj => $TicketObj, ARGSRef => \%ARGS);
</%INIT>
......
......@@ -53,8 +53,9 @@
<form action="ModifyLinks.html" method="post">
<input type="hidden" class="hidden" name="id" value="<%$Ticket->id%>" />
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<&| /Widgets/TitleBox, title => loc('Edit Links') &>
<& /Elements/EditLinks, Object => $Ticket, Merge => 1 &>
</&>
<& /Elements/Submit, Label => loc('Save Changes') &>
......@@ -66,6 +67,7 @@
<%INIT>
my $Ticket = LoadTicket($id);
$m->comp('/Elements/Callback', TicketObj => $Ticket, ARGSRef => \%ARGS);
my @results = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
</%INIT>
......
......@@ -53,8 +53,8 @@
<form method="post" action="ModifyPeople.html">
<input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<&| /Widgets/TitleBox, title => loc('Modify people related to ticket #[_1]', $Ticket->Id), width => "100%", color=> "#333399" &>
<& Elements/EditPeople, Ticket => $Ticket, UserField => $UserField, UserString => $UserString, UserOp => $UserOp, GroupString => $GroupString, GroupOp => $GroupOp, GroupField => $GroupField &>
</&>
<& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), color => "#333399" &>
</form>
......@@ -64,6 +64,7 @@
my (@results, @wresults);
my $Ticket = LoadTicket($id);
$m->comp('/Elements/Callback', TicketObj => $Ticket, ARGSRef => \%ARGS);
# if we're trying to search for watchers and nothing else
unless ($OnlySearchForPeople or $OnlySearchForGroup) {
......
......@@ -50,10 +50,10 @@
<form action="Update.html" name="TicketUpdate"
method="post" enctype="multipart/form-data">
<& /Elements/Callback, _CallbackName => 'FormStart',ARGSRef =>\%ARGS &>
<input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction} %>" />
<input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus %>" />
<input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action} %>" />
<table border="0">
<tr><td align="right"><&|/l&>Status</&>:</td>
......
......@@ -78,9 +78,7 @@
<&|/l&>Template</&>:
</td>
<td colspan="2">
<textarea name="string" cols="80" rows="30">
<%$string%>
</textarea>
<textarea name="string" cols="80" rows="30"><%$string%></textarea>
</td>
</tr>
<tr><td class="label">
......
......@@ -188,9 +188,7 @@ A complete list of acceptable fields for this beastie:
Started =>
Resolved =>
Owner => Username or id of an RT user who can and should own
this ticket
ForceOwner => Same as Owner, but sets the owner even if the owner
is already set
this ticket; forces the owner if necessary
+ Requestor => Email address
+ Cc => Email address
+ AdminCc => Email address
......@@ -210,9 +208,11 @@ A complete list of acceptable fields for this beastie:
within a template after a Content: header is treated
as content until we hit a line containing only
ENDOFCONTENT
ContentType => the content-type of the Content field
ContentType => the content-type of the Content field. Defaults to
'text/plain'
UpdateType => 'correspond' or 'comment'; used in conjunction with
'content' if this is an update.
'content' if this is an update. Defaults to
'correspond'
CustomField-<id#> => custom field value
CF-name => custom field value
......@@ -673,13 +673,11 @@ sub UpdateByTemplate {
my $id = $template_id;
$id =~ s/update-(\d+).*/$1/;
$T::Tickets{$template_id}->Load($id);
my ($loaded, $msg) = $T::Tickets{$template_id}->LoadById($id);
my $msg;
if ( !$T::Tickets{$template_id}->Id ) {
$msg = "Couldn't update ticket $template_id " . $msg;
$RT::Logger->error($msg);
unless ( $loaded ) {
$RT::Logger->error("Couldn't update ticket $template_id: " . $msg);
push @results, $self->loc( "Couldn't load ticket '[_1]'", $id );
next;
}
......@@ -707,19 +705,21 @@ sub UpdateByTemplate {
ARGSRef => $ticketargs
);
if ( $ticketargs->{'ForceOwner'} ) {
($id, $msg) = $T::Tickets{$template_id}->SetOwner($ticketargs->{'ForceOwner'}, "Force");
push @results, $msg;
if ( $ticketargs->{'Owner'} ) {
($id, $msg) = $T::Tickets{$template_id}->SetOwner($ticketargs->{'Owner'}, "Force");
push @results, $msg unless $msg eq $self->loc("That user already owns that ticket");
}
push @results,
$self->UpdateWatchers( $T::Tickets{$template_id}, $ticketargs );
push @results,
$self->UpdateCustomFields( $T::Tickets{$template_id}, $ticketargs );
next unless $ticketargs->{'MIMEObj'};
if ( $ticketargs->{'UpdateType'} =~ /^(private|comment)$/i ) {
my ( $Transaction, $Description, $Object )
= $T::Tickets{$template_id}->Comment(
CcMessageTo => $ticketargs->{'Cc'},
BccMessageTo => $ticketargs->{'Bcc'},
MIMEObj => $ticketargs->{'MIMEObj'},
TimeTaken => $ticketargs->{'TimeWorked'}
......@@ -732,7 +732,6 @@ sub UpdateByTemplate {
} elsif ( $ticketargs->{'UpdateType'} =~ /^(public|response|correspond)$/i ) {
my ( $Transaction, $Description, $Object )
= $T::Tickets{$template_id}->Correspond(
CcMessageTo => $ticketargs->{'Cc'},
BccMessageTo => $ticketargs->{'Bcc'},
MIMEObj => $ticketargs->{'MIMEObj'},
TimeTaken => $ticketargs->{'TimeWorked'}
......@@ -849,7 +848,7 @@ sub _ParseMultilineTemplate {
$line = "Queue: $value";
}
}
if ( $line =~ /^Requestor:(.*)/i ) {
if ( $line =~ /^Requestors?:(.*)/i ) {
$requestor = 1;
my $value = $1;
$value =~ s/^\s//;
......@@ -917,6 +916,7 @@ sub ParseLines {
my $original_tag = $1;
my $tag = lc($original_tag);
$tag =~ s/-//g;
$tag =~ s/^(requestor|cc|admincc)s?$/$1/i;
$original_tags{$tag} = $original_tag;
......@@ -938,7 +938,6 @@ sub ParseLines {
push @{ $args{'content'} }, $l . "\n";
}
} else {
# if it's not content, strip leading and trailing spaces
if ( $args{$tag} ) {
$args{$tag} =~ s/^\s+//g;
......@@ -957,7 +956,12 @@ sub ParseLines {
if ( $args{$date} =~ /^\d+$/ ) {
$dateobj->Set( Format => 'unix', Value => $args{$date} );
} else {
$dateobj->Set( Format => 'unknown', Value => $args{$date} );
eval {
$dateobj->Set( Format => 'iso', Value => $args{$date} );
};
if ($@ or $dateobj->Unix <= 0) {
$dateobj->Set( Format => 'unknown', Value => $args{$date} );
}
}
$args{$date} = $dateobj->ISO;
}
......@@ -970,13 +974,12 @@ sub ParseLines {
my %ticketargs = (
Queue => $args{'queue'},
Subject => $args{'subject'},
Status => 'new',
Status => $args{'status'} || 'new',
Due => $args{'due'},
Starts => $args{'starts'},
Started => $args{'started'},
Resolved => $args{'resolved'},
Owner => $args{'forceowner'} || $args{'owner'},
ForceOwner => $args{'forceowner'},
Owner => $args{'owner'},
Requestor => $args{'requestor'},
Cc => $args{'cc'},
AdminCc => $args{'admincc'},
......@@ -991,11 +994,11 @@ sub ParseLines {
if ( $args{content} ) {
my $mimeobj = MIME::Entity->new();
$mimeobj->build(
Type => $args{'contenttype'},
Type => $args{'contenttype'} || 'text/plain',
Data => $args{'content'}
);
$ticketargs{MIMEObj} = $mimeobj;
$ticketargs{UpdateType} = $args{'updatetype'} if $args{'updatetype'};
$ticketargs{UpdateType} = $args{'updatetype'} || 'correspond';
}
foreach my $tag ( keys(%args) ) {
......@@ -1033,9 +1036,7 @@ sub _ParseXSVTemplate {
my %args = (@_);
use Regexp::Common qw(delimited);
my $first
= substr( $args{'Content'}, 0, index( $args{'Content'}, "\n" ) );
$first =~ s/\r$//;
my($first, $content) = split(/\r?\n/, $args{'Content'}, 2);
my $delimiter;
if ( $first =~ /\t/ ) {
......@@ -1048,85 +1049,109 @@ sub _ParseXSVTemplate {
my $delimiter_re = qr[$delimiter];
my $justquoted = qr[$RE{quoted}];
$args{'Content'}
= substr( $args{'Content'}, index( $args{'Content'}, "\n" ) + 1 );
# Used to generate automatic template ids
my $autoid = 1;
LINE:
while ($args{'Content'}) {
$args{'Content'} =~ s/^(\s*\r?\n)+//;
while ($content) {
$content =~ s/^(\s*\r?\n)+//;
# Keep track of Queue and Requestor, so we can provide defaults
my $queue;
my $requestor;
# first item is $template_id
# The template for this line
my $template;
# What column we're on
my $i = 0;
my $template_id;
# If the last iteration was the end of the line
my $EOL = 0;
# The template id
my $template_id;
COLUMN:
while (not $EOL and length $args{'Content'} and $args{'Content'} =~ s/^($justquoted|.*?)($delimiter_re|$)//smix) {
while (not $EOL and length $content and $content =~ s/^($justquoted|.*?)($delimiter_re|$)//smix) {
$EOL = not $2;
# If it's the first field, it must be a ticket id.
if ( $i == 0 ) {
$queue = 0;
$requestor = 0;
my $tid = $1;
$tid =~ s/^\s*(.*?)\s*$/$1/;
next COLUMN unless $tid;
if ( $tid =~ /^\d+$/ ) {
$template_id = 'update-' . $tid;
# Strip off quotes, if they exist
my $value = $1;
if ( $value =~ /^$RE{delimited}{-delim=>qq{\'\"}}$/ ) {
substr( $value, 0, 1 ) = "";
substr( $value, -1, 1 ) = "";
}