[Rt-commit] r7851 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: lib/RT
t/api
clsung at bestpractical.com
clsung at bestpractical.com
Mon May 14 05:49:36 EDT 2007
Author: clsung
Date: Mon May 14 05:49:35 2007
New Revision: 7851
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/ (props changed)
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Ticket_Overlay.pm
rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t
Log:
r1062 at going04: clsung | 2007-05-14 13:48:13 +0800
- sub UpdateFrom822 is stub code, after addressed in IRC
kill it and relative tests.
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Ticket_Overlay.pm Mon May 14 05:49:35 2007
@@ -675,161 +675,6 @@
# }}}
-
-# {{{ UpdateFrom822
-
-=head2 UpdateFrom822 $MESSAGE
-
-Takes an RFC822 format message as a string and uses it to make a bunch of changes to a ticket.
-Returns an um. ask me again when the code exists
-
-
-
-
-=cut
-
-sub UpdateFrom822 {
- my $self = shift;
- my $content = shift;
- my %args = $self->_Parse822HeadersForAttributes($content);
-
-
- my %ticketargs = (
- Queue => $args{'queue'},
- Subject => $args{'subject'},
- Status => $args{'status'},
- Due => $args{'due'},
- Starts => $args{'starts'},
- Started => $args{'started'},
- Resolved => $args{'resolved'},
- Owner => $args{'owner'},
- Requestor => $args{'requestor'},
- Cc => $args{'cc'},
- AdminCc => $args{'admincc'},
- TimeWorked => $args{'timeworked'},
- TimeEstimated => $args{'timeestimated'},
- TimeLeft => $args{'timeleft'},
- InitialPriority => $args{'initialpriority'},
- Priority => $args{'priority'},
- FinalPriority => $args{'finalpriority'},
- Type => $args{'type'},
- DependsOn => $args{'dependson'},
- DependedOnBy => $args{'dependedonby'},
- RefersTo => $args{'refersto'},
- ReferredToBy => $args{'referredtoby'},
- Members => $args{'members'},
- MemberOf => $args{'memberof'},
- MIMEObj => $args{'mimeobj'}
- );
-
- foreach my $type qw(Requestor Cc Admincc) {
-
- foreach my $action ( 'Add', 'Del', '' ) {
-
- my $lctag = lc($action) . lc($type);
- foreach my $list ( $args{$lctag}, $args{ $lctag . 's' } ) {
-
- foreach my $entry ( ref($list) ? @{$list} : ($list) ) {
- push @{$ticketargs{ $action . $type }} , split ( /\s*,\s*/, $entry );
- }
-
- }
-
- # Todo: if we're given an explicit list, transmute it into a list of adds/deletes
-
- }
- }
-
- # Add custom field entries to %ticketargs.
- # TODO: allow named custom fields
- map {
- /^customfield-(\d+)$/
- && ( $ticketargs{ "CustomField-" . $1 } = $args{$_} );
- } keys(%args);
-
-# for each ticket we've been told to update, iterate through the set of
-# rfc822 headers and perform that update to the ticket.
-
-
- # {{{ Set basic fields
- my @attribs = qw(
- Subject
- FinalPriority
- Priority
- TimeEstimated
- TimeWorked
- TimeLeft
- Status
- Queue
- Type
- );
-
-
- # Resolve the queue from a name to a numeric id.
- if ( $ticketargs{'Queue'} and ( $ticketargs{'Queue'} !~ /^(\d+)$/ ) ) {
- my $tempqueue = RT::Queue->new($RT::SystemUser);
- $tempqueue->Load( $ticketargs{'Queue'} );
- $ticketargs{'Queue'} = $tempqueue->Id() if ( $tempqueue->id );
- }
-
- my @results;
-
- foreach my $attribute (@attribs) {
- my $value = $ticketargs{$attribute};
-
- if ( $value ne $self->$attribute() ) {
-
- my $method = "Set$attribute";
- my ( $code, $msg ) = $self->$method($value);
-
- push @results, $self->loc($attribute) . ': ' . $msg;
-
- }
- }
-
- # We special case owner changing, so we can use ForceOwnerChange
- if ( $ticketargs{'Owner'} && ( $self->Owner != $ticketargs{'Owner'} ) ) {
- my $ChownType = "Give";
- $ChownType = "Force" if ( $ticketargs{'ForceOwnerChange'} );
-
- my ( $val, $msg ) = $self->SetOwner( $ticketargs{'Owner'}, $ChownType );
- push ( @results, $msg );
- }
-
- # }}}
-# Deal with setting watchers
-
-
-# Acceptable arguments:
-# Requestor
-# Requestors
-# AddRequestor
-# AddRequestors
-# DelRequestor
-
- foreach my $type qw(Requestor Cc AdminCc) {
-
- # If we've been given a number of delresses to del, do it.
- foreach my $address (@{$ticketargs{'Del'.$type}}) {
- my ($id, $msg) = $self->DeleteWatcher( Type => $type, Email => $address);
- push (@results, $msg) ;
- }
-
- # If we've been given a number of addresses to add, do it.
- foreach my $address (@{$ticketargs{'Add'.$type}}) {
- $RT::Logger->debug("Adding $address as a $type");
- my ($id, $msg) = $self->AddWatcher( Type => $type, Email => $address);
- push (@results, $msg) ;
-
- }
-
-
-}
-
-
-}
-# }}}
-
# {{{ _Parse822HeadersForAttributes Content
=head2 _Parse822HeadersForAttributes Content
@@ -874,7 +719,7 @@
foreach my $date qw(due starts started resolved) {
my $dateobj = RT::Date->new($RT::SystemUser);
- if ( $args{$date} =~ /^\d+$/ ) {
+ if ( defined ($args{$date}) and $args{$date} =~ /^\d+$/ ) {
$dateobj->Set( Format => 'unix', Value => $args{$date} );
}
else {
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/api/ticket.t Mon May 14 05:49:35 2007
@@ -123,30 +123,6 @@
undef $main::_STDOUT_;
undef $main::_STDERR_;
-my $simple_update = <<EOF;
-Subject: target
-AddRequestor: jesse\@example.com
-EOF
-
-my $ticket = RT::Ticket->new($RT::SystemUser);
-my ($id,$msg) =$ticket->Create(Subject => 'first', Queue => 'general');
-ok($ticket->Id, "Created the test ticket - ".$id ." - ".$msg);
-$ticket->UpdateFrom822($simple_update);
-is($ticket->Subject, 'target', "changed the subject");
-my $jesse = RT::User->new($RT::SystemUser);
-$jesse->LoadByEmail('jesse at example.com');
-ok ($jesse->Id, "There's a user for jesse");
-ok($ticket->Requestors->HasMember( $jesse->PrincipalObj), "It has the jesse principal object as a requestor ");
-
-
- undef $main::_STDOUT_;
- undef $main::_STDERR_;
-}
-
-{
- undef $main::_STDOUT_;
- undef $main::_STDERR_;
-
my $ticket = RT::Ticket->new($RT::SystemUser);
my ($id, $msg) = $ticket->Create(Subject => "Foo",
Owner => $RT::SystemUser->Id,
More information about the Rt-commit
mailing list