Priority -- an integer from 0 to 99
InitialPriority -- an integer from 0 to 99
FinalPriority -- an integer from 0 to 99
- Status -- any valid status (Defined in RT::Queue)
+ Status -- any valid status for Queue's Lifecycle, otherwises uses on_create from Lifecycle default
TimeEstimated -- an integer. estimated time for this task in minutes
TimeWorked -- an integer. time worked so far in minutes
TimeLeft -- an integer. time remaining in minutes
AdminCc => sub {
my $principal = shift;
return 1 if $self->CurrentUserHasRight('ModifyTicket');
- return $principal->id == $self->CurrentUser->PrincipalId
- and $self->CurrentUserHasRight("WatchAsAdminCc");
+ return unless $self->CurrentUserHasRight("WatchAsAdminCc");
+ return unless $principal->id == $self->CurrentUser->PrincipalId;
+ return 1;
},
Owner => sub {
my $principal = shift;
foreach my $arg ( keys %args ) {
next unless $arg =~ /^CustomField-(\d+)$/i;
my $cfid = $1;
+ my $cf = $self->LoadCustomFieldByIdentifier($cfid);
+ next unless $cf->ObjectTypeFromLookupType->isa(ref $self);
foreach my $value (
UNIVERSAL::isa( $args{$arg} => 'ARRAY' ) ? @{ $args{$arg} } : ( $args{$arg} ) )
=head2 AddWatcher
-Applies access control checking, then calls L<RT::Record/AddRoleMember>.
-Additionally, C<Email> is accepted as an alternative argument name for
-C<User>.
+Applies access control checking, then calls
+L<RT::Record::Role::Roles/AddRoleMember>. Additionally, C<Email> is
+accepted as an alternative argument name for C<User>.
Returns a tuple of (status, message).
=head2 DeleteWatcher
-Applies access control checking, then calls L<RT::Record/DeleteRoleMember>.
-Additionally, C<Email> is accepted as an alternative argument name for
-C<User>.
+Applies access control checking, then calls
+L<RT::Record::Role::Roles/DeleteRoleMember>. Additionally, C<Email> is
+accepted as an alternative argument name for C<User>.
Returns a tuple of (status, message).
}
unless ( $args{'MIMEObj'} ) {
+ my $data = ref $args{'Content'}? $args{'Content'} : [ $args{'Content'} ];
$args{'MIMEObj'} = MIME::Entity->build(
- Data => ( ref $args{'Content'}? $args{'Content'}: [ $args{'Content'} ] )
+ Type => "text/plain",
+ Charset => "UTF-8",
+ Data => [ map {Encode::encode("UTF-8", $_)} @{$data} ],
);
}
my $addresses = join ', ', (
map { RT::User->CanonicalizeEmailAddress( $_->address ) }
Email::Address->parse( $args{ $type . 'MessageTo' } ) );
- $args{'MIMEObj'}->head->replace( 'RT-Send-' . $type, Encode::encode_utf8( $addresses ) );
+ $args{'MIMEObj'}->head->replace( 'RT-Send-' . $type, Encode::encode( "UTF-8", $addresses ) );
}
}
# internal Message-ID now, so all emails sent because of this
# message have a common Message-ID
my $org = RT->Config->Get('Organization');
- my $msgid = $args{'MIMEObj'}->head->get('Message-ID');
+ my $msgid = Encode::decode( "UTF-8", $args{'MIMEObj'}->head->get('Message-ID') );
unless (defined $msgid && $msgid =~ /<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@\Q$org\E>/) {
- $args{'MIMEObj'}->head->set(
- 'RT-Message-ID' => Encode::encode_utf8(
+ $args{'MIMEObj'}->head->replace(
+ 'RT-Message-ID' => Encode::encode( "UTF-8",
RT::Interface::Email::GenMessageId( Ticket => $self )
)
);
#Record the correspondence (write the transaction)
my ( $Trans, $msg, $TransObj ) = $self->_NewTransaction(
Type => $args{'NoteType'},
- Data => ( $args{'MIMEObj'}->head->get('subject') || 'No Subject' ),
+ Data => ( Encode::decode( "UTF-8", $args{'MIMEObj'}->head->get('Subject') ) || 'No Subject' ),
TimeTaken => $args{'TimeTaken'},
MIMEObj => $args{'MIMEObj'},
CommitScrips => $args{'CommitScrips'},
return ( $Trans, $self->loc("Message could not be recorded"), undef );
}
- return ( $Trans, $self->loc("Message recorded"), $TransObj );
+ if ($args{NoteType} eq "Comment") {
+ $msg = $self->loc("Comments added");
+ } else {
+ $msg = $self->loc("Correspondence added");
+ }
+ return ( $Trans, $msg, $TransObj );
}
}
my $Message = MIME::Entity->build(
+ Subject => defined $args{UpdateSubject} ? Encode::encode( "UTF-8", $args{UpdateSubject} ) : "",
Type => 'text/plain',
- Subject => defined $args{UpdateSubject} ? Encode::encode_utf8( $args{UpdateSubject} ) : "",
Charset => 'UTF-8',
- Data => $args{'UpdateContent'} || "",
+ Data => Encode::encode("UTF-8", $args{'UpdateContent'} || ""),
);
my ( $Transaction, $Description, $Object ) = $self->$action(
MIMEObj => $Message,
TimeTaken => $args{'UpdateTimeWorked'},
DryRun => 1,
+ SquelchMailTo => $args{'SquelchMailTo'},
);
unless ( $Transaction ) {
$RT::Logger->error("Couldn't fire '$action' action: $Description");
my $self = shift;
my %args = @_;
my $Message = MIME::Entity->build(
- Type => 'text/plain',
- Subject => defined $args{Subject} ? Encode::encode_utf8( $args{'Subject'} ) : "",
+ Subject => defined $args{Subject} ? Encode::encode( "UTF-8", $args{'Subject'} ) : "",
(defined $args{'Cc'} ?
- ( Cc => Encode::encode_utf8( $args{'Cc'} ) ) : ()),
+ ( Cc => Encode::encode( "UTF-8", $args{'Cc'} ) ) : ()),
+ Type => 'text/plain',
Charset => 'UTF-8',
- Data => $args{'Content'} || "",
+ Data => Encode::encode( "UTF-8", $args{'Content'} || ""),
);
my ( $Transaction, $Object, $Description ) = $self->Create(
return ( 0, $self->loc("New ticket doesn't exist") );
}
+ # Can't merge into yourself
+ if ( $MergeInto->Id == $self->Id ) {
+ return ( 0, $self->loc("Can't merge a ticket into itself") );
+ }
+
# Make sure the current user can modify the new ticket.
unless ( $MergeInto->CurrentUserHasRight('ModifyTicket') ) {
return ( 0, $self->loc("Permission Denied") );
$RT::Handle->BeginTransaction();
- $self->_MergeInto( $MergeInto );
+ my ($ok, $msg) = $self->_MergeInto( $MergeInto );
- $RT::Handle->Commit();
+ $RT::Handle->Commit() if $ok;
- return ( 1, $self->loc("Merge Successful") );
+ return ($ok, $msg);
}
sub _MergeInto {
$self->AddLink( Type => 'MergedInto', Target => $MergeInto->Id());
$MergeInto->_SetLastUpdated;
+
+ return ( 1, $self->loc("Merge Successful") );
}
=head2 Merged
if ( $args{SetStarted}
&& $args{Lifecycle}->IsInitial($old)
&& !$args{NewLifecycle}->IsInitial($args{Status})
- && !$raw_started->Unix) {
+ && !$raw_started->IsSet) {
# Set the Started time to "now"
$self->_Set(
Field => 'Started',
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->SetContextObject( $self );
- $cf->LoadByNameAndQueue( Name => $field, Queue => $self->Queue );
- $cf->LoadByNameAndQueue( Name => $field, Queue => 0 ) unless $cf->id;
+ $cf->LoadByName(
+ Name => $field,
+ LookupType => $self->CustomFieldLookupType,
+ ObjectId => $self->Queue,
+ IncludeGlobal => 1,
+ );
return $cf;
}
$args{$_} = join ", ", map { $_->format } RT::EmailParser->ParseEmailAddress( $args{$_} || '' ) for qw(To Cc Bcc);
+ return (0, $self->loc("Can't forward: no valid email addresses specified") )
+ unless grep {length $args{$_}} qw/To Cc Bcc/;
+
my $mime = MIME::Entity->build(
- Subject => $args{Subject},
Type => $args{ContentType},
- Data => $args{Content},
+ Data => Encode::encode( "UTF-8", $args{Content} ),
);
- $mime->head->set(
+ $mime->head->replace(
$_ => RT::Interface::Email::EncodeToMIME( String => $args{$_} ) )
for grep defined $args{$_}, qw(Subject To Cc Bcc);
- $mime->head->set(
+ $mime->head->replace(
From => RT::Interface::Email::EncodeToMIME(
String => RT::Interface::Email::GetForwardFrom(
Transaction => $args{Transaction},