[Rt-devel] Adding Button to Ticket Actions

Todd Chapman todd at chaka.net
Mon Dec 3 18:05:26 EST 2007


Matthew,

We do just what you want.

In file /opt/rt3/Callbacks/myCompany/Ticket/Elements/Tabs/Default :

<%init>
if ($Ticket) {
my $groups = $session{CurrentUser}->UserObj->OwnGroups();
$groups->Limit(FIELD => 'Name', VALUE => 'CanMarkSpam' );

    if ( $groups->Count
        ||  $session{CurrentUser}->HasRight( Right => 'SuperUser',
Object => $RT::System  )) {
        $actions->{'zz'} = { title => loc('Spam'),
                                        path =>
'Ticket/Display.html?Action=Spam&id='.$Ticket->id };
    }
}
</%init>
<%args>
$Ticket =>undef
$tabs => undef
$actions => undef
</%args>


And then we customize Display.html:

    if (defined $ARGS{'Action'}) {
        if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold|Delete|Spam)$/) {
            my $action = $1;
            my ($res, $msg)=$TicketObj->$action();
            push(@Actions, $msg);
        }
    }


And then in Ticket_Local.pm:

sub Spam {

    my $self = shift;

    $self->Reject();
    my $requestors = $self->Requestors->UserMembersObj->ItemsArrayRef();
    my ($rv, $msg);
    for ( @$requestors ) {
        $_->CurrentUser( $RT::SystemUser );
        ($rv, $msg) = $_->PrincipalObj->SetDisabled(1);
    }
    $RT::Logger->debug( $self->CurrentUser->UserObj->Name . ' marking
ticket ' . $self->id . ' as spam!' );
    return (1, 'spammer disabled!') if $rv;
}


-Todd

On 12/3/07, Matthew Ekstrand-Abueg <mattea at rescomp.berkeley.edu> wrote:
> Dear RT Devel Group,
>
> I am trying to create an additional button to quickly and easily mark something
> as Spam in our current infrastructure (a Custom Field).  For look and ease of
> acccess, I wanted to put this in the header actions along with the following:
>
>     * Steal ··· Comment · Reply · Resolve
>
> I would preferrably like to do this as a Callback if possible, but I can't
> figure out where I would add this, or even how the Callbacks work in terms of
> which directory tree controls what (local/Callbacks vs local/html/Callbacks vs
> local/share/html/Callbacks vs share/html/Callbacks ).  Any help with
> this would be greatly appreciated.
>
> --
> Matthew Ekstrand-Abueg
> Systems Administrator
> Network Infrastructure, RSSP-IT
> UC Berkeley
>
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
>
> SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:
>
> If you sign up for a new RT support contract before December 31, we'll take
> up to 20 percent off the price. This sale won't last long, so get in touch today.
>     Email us at sales at bestpractical.com or call us at +1 617 812 0745.
>
>


More information about the Rt-devel mailing list