[rt-users] whats wrong with my new Condition...

Forrest Stanley fstanley at netburner.com
Mon Oct 21 13:19:10 EDT 2002


This condition is supposed to return true when the owner has responded to a 
request. The scrip changes the status to resolved when the condition is 
true. I ran perl insert_condition_OwnerCorrespond.pl and it ran fine. But 
when I tested the scrip, nothing happend. I am learning php, so my mistake 
might be easy to spot. I used the RT/FM hackers guide as an example to 
create this.




----------------------------------------------------------OwnerCorrespond.pm

# ScripCondition: OwnerCorrespond.pm
# IsApplicable returns true if correspondence is
#   completed by the ticket owner

# Created by Forrest Stanley

package RT::Condition::OwnerCorrespond;
require RT::Condition::Generic;
@ISA = qw(RT::Condition::Generic);

sub IsApplicable {
     my $self = shift;

     my $creator = $self->TransactionObj->CreatorObj->EmailAddress;

     return($self->TransactionObj->Type eq 'Correspond' && $creator =~ 
$self->TicketObj->OwnerObj->EmailAddress );
}
1;

--------------------------------------------------------insert_condition_OwnerCorrespond.pl 

#! /usr/local/bin/perl -w

use lib "/opt/rt2/lib";
use lib "/opt/rt2/etc";

use config;
use Carp;

use RT::Handle;
use RT::User;
use RT::CurrentUser;

$RT::Handle = new RT::Handle( $RT::DatabaseType );
$RT::Handle->Connect;

my $CurrentUser = new RT::CurrentUser();

use RT::Interface::CLI  qw(CleanEnv LoadConfig DBConnect
                            GetCurrentUser GetMessageContent);

CleanEnv();
LoadConfig();
DBConnect();

$CurrentUser->LoadByName('RT_System');

my @ScripConditions = (
                          {
                           Name => 'OnOwnerRespond',
                           Description => 'When Owner responds or comments',
                           Argument => 'null',
                           ExecModule => 'OwnerCorrespond',
                          },
                         );

print "Creating ScripConditions...";

use RT::ScripConditions;
for $item (@ScripConditions) {
     my $new_entry = new RT::ScripCondition($CurrentUser);
     my $return = $new_entry->Create(%$item);
     print $return.".";
}

print "done.\n";

$RT::Handle->Disconnect();

1;




More information about the rt-users mailing list