<%INIT>
use RT::Crypt::GnuPG;

$COLUMN_MAP->{'Take'} = {
    title => 'Take',
    value => sub {
        my $t = shift;
        return '' if $t->Owner != $RT::Nobody->id;
        my $action = 'Take';
        my $link = RT->Config->Get('WebPath') ."/Ticket/Display.html?Action=$action&id=". $t->id;
        $link = qq{<a href="$link">}. $t->loc($action) .qq{</a>};
        return \$link;
    },
};
$COLUMN_MAP->{'TakeOrSteal'} = {
    title => 'Take/Steal',
    value => sub {
        my $t = shift;
        return '' if $t->Owner == $t->CurrentUser->id;
        my $action = 'Take';
        $action = 'Steal' if $t->Owner != $RT::Nobody->id;
        my $link = RT->Config->Get('WebPath') ."/Ticket/Display.html?Action=$action&id=". $t->id;
        $link = qq{<a href="$link">}. $t->loc($action) .qq{</a>};
        return \$link;
    },
};
$COLUMN_MAP->{'HasIncident'} = {
    title => 'Has Incident?',
    value => sub {
        my $t = shift;
        my $yesno;
        if ( RT::IR->RelevantIncidents( $t )->Count ) {
            $yesno = '<span class="yes">'. $t->loc('yes') .'</span>';
        }
        else {
            $yesno = '<span class="no">'. $t->loc('no') .'</span>';
        }

        return \$yesno;
    },
};
$COLUMN_MAP->{'LookupToolChildrenActions'} = {
    title => 'Actions',
    value => sub {
        my $t = shift;
        my ($lid, $show) = split /,/, pop(), 2;
        my %show = map { lc($_) => 1 } split /,/, $show;

        my @res;
        if ( $show{'link'} ) {
            push @res, \'<a href="',
                RT->Config->Get('WebPath') .'/RTIR/Display.html?Child='. $t->id .'&id='. $lid,
                \'">',
                '[' . $t->loc("Link") .']',
                \'</a>'
            ;
        }
        if ( $lid != $t->id && $show{'merge'} ) {
            push @res, \'<a href="',
                RT->Config->Get('WebPath') .'/RTIR/Merge/?SelectedTicket='. $t->id .'&id='. $lid,
                \'">',
                '[' . $t->loc("Merge") .']',
                \'</a>'
            ;
        }
        return @res;
    },
};
$COLUMN_MAP->{'LookupToolIncidentActions'} = {
    title => 'Actions',
    value => sub {
        my $t = shift;
        my ($lid, $show) = split /,/, pop(), 2;
        my %show = map { lc($_) => 1 } split /,/, $show;

        my @res;
        if ( $show{'link'} ) {
            push @res, \'<a href="',
                RT->Config->Get('WebPath') .'/RTIR/Display.html?Child='. $lid .'&id='. $t->id,
                \'">',
                '[' . $t->loc("Link") .']',
                \'</a>'
            ;
        }
        if ( $lid != $t->id && $show{'merge'} ) {
            push @res, \'<a href="',
                RT->Config->Get('WebPath') .'/RTIR/Merge/?SelectedTicket='. $lid .'&id='. $t->id,
                \'">',
                '[' . $t->loc("Merge") .']',
                \'</a>'
            ;
        }
        push @res, \'<a href="',
            RT->Config->Get('WebPath') .'/RTIR/Create.html?Queue=Investigations&Incident='. $t->id,
            \'">',
            '[' . $t->loc("Investigate") .']',
            \'</a>'
        ;
        return @res;
    },
};

</%INIT>
<%ARGS>
$COLUMN_MAP => undef
</%ARGS>
