One link, two actions

English! place to talk about development, programming and coding
Post Reply
faelric
Znuny newbie
Posts: 9
Joined: 16 Sep 2010, 08:01
Znuny Version: 2

One link, two actions

Post by faelric »

Hi guys,

Does anyone knows how to edit the source code to allow OTRS perform two actions?

for example:

Code: Select all

<a href="$Env{"Baselink"}Action=AgentTicketZoom&TicketID=$Data{"TicketID"}&ArticleID=$Data{"ArticleID"}&QueueID=$Data{"QueueID"}" onmouseover="window.status='$JSText{"Zoom"}'; return true;" onmouseout="window.status='';" title="$QData{"Title"}">$Data{"TicketNumber"}</a>
Lets you zoom into the ticket view

and

Code: Select all

<a href="$Env{"Baselink"}Action=AgentTicketLock&Subaction=Lock&TicketID=$Data{"TicketID"}" onmouseover="window.status='$JSText{"Ticket locked!"}'; return true;" onmouseout="window.status=''; ">$Data{"TicketNumber"}</a>
Lets you lock the ticket

So, end result should be viewing the ticket while locking it at the same time.

Thanks.
Mike_B
Moderator
Posts: 266
Joined: 12 Jan 2010, 18:16
Znuny Version: CVS HEAD

Re: One link, two actions

Post by Mike_B »

Hi Faelric,

I guess it would be nicest if you actually modify the Modules/AgentTicketZoom.pm to include an option for it. Like so:

Code: Select all

my $Lock = $Self->{ParamObject}->GetParam( Param => 'Lock' ); 
and then:

Code: Select all

# of course you should look up lock states first, hard coding is evil, but this is POC
if ($Lock eq 'Lock') {
    # first check if ticket is already locked
        ...
    # if not, lock the ticket
     $TicketObject->LockSet(
	Lock => 'lock',
	TicketID => $Param{TicketID},
 	UserID => $Self->{UserID}, 
    )
}
Now if your URL is like this: otrs/index.pl?Action=AgentTicketZoom&TicketID=nnn&ArticleID=nnn&Lock=Lock the lock will be set when opening the URL.
--
Mike
huntingbears.nl - @michielbeijen on Twitter
faelric
Znuny newbie
Posts: 9
Joined: 16 Sep 2010, 08:01
Znuny Version: 2

Re: One link, two actions

Post by faelric »

The POC sounds great.

But, I am unable to understand the error :

Modification of non-creatable hash value attempted, subscript "Kernel/Modules/AgentTicketZoom.pm"

When I click on the TicketZoom. It seems that the hash pre-created does not contain the value?
Post Reply