[Rt-devel] AT Design advice sought

Todd Chapman rt at chaka.net
Thu Feb 17 18:46:21 EST 2005


Still looking for advice on this, but I have a solution
that is working (option 2). I defined Ticket_Vendor.pm like so:

package RT::Ticket;

use strict;
no warnings qw(redefine);

my $Orig_AddLink = \&_AddLink;

*_AddLink = sub {

    my $self = shift;
    my ($linkid, $msg) = $Orig_AddLink->($self, @_);

    return ($linkid, $msg) unless $linkid;

    my $linkObj = RT::Link->new( $self->CurrentUser );
    my ($LinkId, $Msg) = $linkObj->Load($linkid);

    $LinkId or return ($linkid, $msg);

    my $TargetObj = $linkObj->TargetObj();
    my $BaseObj = $linkObj->BaseObj();

    return ($linkid, $msg) unless (ref $BaseObj eq 'RT::Ticket');

    if (ref $TargetObj eq 'RTx::AssetTracker::Asset') {

        $TargetObj->_NewTransaction(
            Type     => 'TicketLink',
            NewValue => $BaseObj->Id,
        );

    }

    return ($linkid, $msg);

};

1;

The only catch is that I had to patch RT to always return
the link id from _AddLink, which is probably the way it
should be. If not, I'll have to come up with another solution.

-Todd



More information about the Rt-devel mailing list