#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
use RT::Reminders;
use RT::URI::fsck_com_rt;
use RT::URI;
+use RT::URI::freeside;
use MIME::Entity;
}
}
+ $args{'Subject'} =~ s/\n//g;
+
$RT::Handle->BeginTransaction();
my %params = (
);
# Parameters passed in during an import that we probably don't want to touch, otherwise
- foreach my $attr qw(id Creator Created LastUpdated LastUpdatedBy) {
+ foreach my $attr (qw(id Creator Created LastUpdated LastUpdatedBy)) {
$params{$attr} = $args{$attr} if $args{$attr};
}
# Delete null integer parameters
foreach my $attr
- qw(TimeWorked TimeLeft TimeEstimated InitialPriority FinalPriority)
+ (qw(TimeWorked TimeLeft TimeEstimated InitialPriority FinalPriority))
{
delete $params{$attr}
unless ( exists $params{$attr} && $params{$attr} );
}
- foreach my $date qw(due starts started resolved) {
+ foreach my $date (qw(due starts started resolved)) {
my $dateobj = RT::Date->new($RT::SystemUser);
if ( defined ($args{$date}) and $args{$date} =~ /^\d+$/ ) {
$dateobj->Set( Format => 'unix', Value => $args{$date} );
$self->OwnerGroup->_AddMember( PrincipalId => $Owner->PrincipalId );
- my $watcher;
- foreach $watcher ( @{ $args{'Cc'} } ) {
+ foreach my $watcher ( @{ $args{'Cc'} } ) {
$self->_AddWatcher( Type => 'Cc', Email => $watcher, Silent => 1 );
}
- foreach $watcher ( @{ $args{'AdminCc'} } ) {
+ foreach my $watcher ( @{ $args{'AdminCc'} } ) {
$self->_AddWatcher( Type => 'AdminCc', Email => $watcher,
Silent => 1 );
}
- foreach $watcher ( @{ $args{'Requestor'} } ) {
+ foreach my $watcher ( @{ $args{'Requestor'} } ) {
$self->_AddWatcher( Type => 'Requestor', Email => $watcher,
Silent => 1 );
}
}
}
else {
- $RT::Logger->warn("$self -> DeleteWatcher got passed a bogus type");
+ $RT::Logger->warning("$self -> DeleteWatcher got passed a bogus type");
return ( 0,
$self->loc('Error in parameters to Ticket->DeleteWatcher') );
}
return ($queue_obj);
}
+sub SetSubject {
+ my $self = shift;
+ my $value = shift;
+ $value =~ s/\n//g;
+ return $self->_Set( Field => 'Subject', Value => $value );
+}
+
# }}}
# }}}
my $links = $self->{ $cache_key }
= RT::Links->new( $self->CurrentUser );
unless ( $self->CurrentUserHasRight('ShowTicket') ) {
- $links->Limit( FIELD => 'id', VALUE => 0 );
+ $links->Limit( FIELD => 'id', VALUE => 0, SUBCLAUSE => 'acl' );
return $links;
}
- # without this you will also get RT::User(s) instead of tickets!
- if ($field == 'Base' and $type == 'MemberOf') {
- my $rtname = RT->Config->Get('rtname');
- $links->Limit(
- FIELD => 'Base',
- OPERATOR => 'STARTSWITH',
- VALUE => "fsck.com-rt://$rtname/ticket/",
- );
- }
-
# Maybe this ticket is a merge ticket
- my $limit_on = 'Local'. $field;
+ #my $limit_on = 'Local'. $field;
# at least to myself
$links->Limit(
- FIELD => $limit_on,
- VALUE => $self->id,
+ FIELD => $field, #$limit_on,
+ OPERATOR => 'MATCHES',
+ VALUE => 'fsck.com-rt://%/ticket/'. $self->id,
ENTRYAGGREGATOR => 'OR',
);
$links->Limit(
- FIELD => $limit_on,
- VALUE => $_,
+ FIELD => $field, #$limit_on,
+ OPERATOR => 'MATCHES',
+ VALUE => 'fsck.com-rt://%/ticket/'. $_,
ENTRYAGGREGATOR => 'OR',
) foreach $self->Merged;
$links->Limit(
}
# Update time fields
- foreach my $type qw(TimeEstimated TimeWorked TimeLeft) {
+ foreach my $type (qw(TimeEstimated TimeWorked TimeLeft)) {
my $mutator = "Set$type";
$MergeInto->$mutator(
}
#add all of this ticket's watchers to that ticket.
- foreach my $watcher_type qw(Requestors Cc AdminCc) {
+ foreach my $watcher_type (qw(Requestors Cc AdminCc)) {
my $people = $self->$watcher_type->MembersObj;
my $addwatcher_type = $watcher_type;
my $batch = $self->TransactionBatch;
my %seen;
- my $types = join ',', grep !$seen{$_}++, grep defined, map $_->Type, grep defined, @{$batch};
+ my $types = join ',', grep !$seen{$_}++, grep defined, map $_->__Value('Type'), grep defined, @{$batch};
require RT::Scrips;
RT::Scrips->new($RT::SystemUser)->Apply(
# }}}
+=head2 CurrentUserCanSee
+
+Returns true if the current user can see the ticket, using ShowTicket
+
+=cut
+
+sub CurrentUserCanSee {
+ my $self = shift;
+ return $self->CurrentUserHasRight('ShowTicket');
+}
+
# {{{ sub HasRight
=head2 HasRight
sub TransactionCustomFields {
my $self = shift;
- return $self->QueueObj->TicketTransactionCustomFields;
+ my $cfs = $self->QueueObj->TicketTransactionCustomFields;
+ $cfs->SetContextObject( $self );
+ return $cfs;
}
# }}}