Hello,
thank you very much for all the code hint, it makes it simpler and easy to
follow.
I'm not very aware of HTML security problems. so far, what i understand
from your explanation is to escape the html code with the \ symbol before
the quoted html text.
the new code is now here, i also added a link at the bottom to create a
new dependson ticket wit a specific queue&owner.
It's one more open road to great RT customisation !
LinksList =>
{
title => 'Liens', # loc
attribute => 'Status',
value => sub {
my $Ticket = shift;
my @result;
my $base_url = RT->Config->Get('WebPath') .
'/Ticket/Display.html?id=';
#tickets with DependsOn relation
my $DepOn = $Ticket->DependsOn;
while( my $copain = $DepOn->Next ) {
my $url = $base_url . $copain->TargetObj->id;
if ($copain->TargetObj->Status =~ /^(?:new|open|stalled)$/
) {
push (@result, (\"<FONT COLOR=\"red\"><LI><a
href=\"$url\">", $copain->TargetObj->Subject, \"</a></LI></FONT>"));}
elsif ($copain->TargetObj->Status =~ /^resolved$/ ) {
push (@result, (\"<SPAN
CLASS=\"ticket-inactive\"><LI><a
href=\"$url\">", $copain->TargetObj->Subject, \"</a></LI></SPAN>"));}
}
#tickets with Child relation
my $members = $Ticket->Members();
while( my $copain = $members->Next ) {
my $url = $base_url . $copain->BaseObj->id;
if ($copain->BaseObj->Status =~ /^(?:new|open|stalled)$/ )
{
push (@result, (\"<FONT COLOR=\"blue\"><LI><a
href=\"$url\">", $copain->BaseObj->Subject, \"</a></LI></FONT>"));}
elsif ($copain->BaseObj->Status =~ /^resolved$/ ) {
push (@result, (\"<SPAN
CLASS=\"ticket-inactive\"><LI><a
href=\"$url\">", $copain->BaseObj->Subject, \"</a></LI></SPAN>"));}
}
if ( @result ) { # found links
@result = (\'<ul>', @result, \'</ul>');
}
$base_url = RT->Config->Get('WebPath') .
'/Ticket/Create.html?CloneTicket=';
push(@result, ( \"<a href=\"", $base_url, $Ticket->id,
\"&DependsOn-new=", $Ticket->id,\"&Queue=1&Owner=6\">", "CREER NOUVELLE
TACHE", \"</a>" ));
return @result;
}
},
Raphaël MOUNEYRES
Ruslan Zakirov <[email protected]>
Envoyé par : [email protected]
10/08/2011 15:13
A
Raphaël MOUNEYRES <[email protected]>
cc
Objet
Re: [rt-users] adding Ticket links in search result
2011/8/10 Raphaël MOUNEYRES <[email protected]>
Hi,
Ruz : I can see something related to a $LinkCallback, but the perl code is
still too tricky for me. Maybe in a few month ;)
Comments on code below.
So, I managed to have a new ColumnMap definition, working, with a great
usefull color customization (see attached image).
I had it working adding manually the '__LinksList__' in the Advanced tab
of search page, now i have to figure out how to add it to the default
choice list...
a good training !
Look at share/html/Search/Elements/BuildFormatString
Here is the revelant code added to
/opt/rt3/share/html/Elements/RT__Ticket/ColumnMap :
See comments inlined:
LinksList =>
{
title => 'Liens', # loc
attribute => 'Status',
value => sub {
my $Ticket = shift;
my $result = "<UL>";
my $SearchURL;
my $statuscolor;
#tickets avec relation DependsOn
my $DepOn = $Ticket->DependsOn;
if ($DepOn) {
$DepOn is always true, it just can be empty.
while( my $copain = $DepOn->Next ) {
$SearchURL = RT->Config->Get('WebPath') .
'/Ticket/Display.html?id=' . $copain->TargetObj->id;
put repeated part out of the loop, for example:
my $base_url = RT->Config->Get('WebPath') . '/Ticket/Display.html?id=';
inside loop:
my $url = $base_url . $copain->TargetObj->id;
$result .= <UL>;
above line is wrong :) It actually a valid perl code that is equivalent to
`$result .= undef` what is better in your case. You should move `$result
.= '<ul>';` outside of while loop.
if($copain->TargetObj->Status =~
/^(?:new|open|stalled)$/ ) {
$result .= "<FONT
COLOR=\"red\"><LI><a href=\"$SearchURL\">" . $copain->TargetObj->Subject .
"</a></LI></FONT>";}
As you return result as reference to one string scalar then you have to
escape HTML your self. With this code you added a security hole into your
RT. As solution, use array @results. Push parts into this array. If part
is valid and trusted HTML then push a reference, otherwise push scalar. At
the end return whole array. For example:
push @result, \"<FONT COLOR=\"red\"><LI><a
href=\"$SearchURL\">", $copain->TargetObj->Subject, \"html here", "text
here";
...
return @result;
else {
$result .= "<SPAN
CLASS=\"ticket-inactive\"><LI><a href=\"$SearchURL\">" .
$copain->TargetObj->Subject . "</a></LI></SPAN>";}
}
}
else {
$result .= 'Pas de tickets dependants';
This wouldn't work. Instead you can do the following:
...
my @result;
while ( ... ) {
...
}
if ( @result ) { # found links
@result = (\'<ul>', @result, '</ul>');
} else {
@result = ('No links');
}
return @result;
}
$result .= "</UL>";
return \$result;
}
},
Result shown as :
Raphaël MOUNEYRES
Ingénieur Moyens Tests
Avenue Paul Gellos 64990 Mouguerre
Phone: +33 (0)5 59 58 41 51
Ruslan Zakirov <[email protected]>
Envoyé par : [email protected]
10/08/2011 13:06
A
Raphaël MOUNEYRES <[email protected]>
cc
RT Users Mailing List <[email protected]>
Objet
Re: [rt-users] adding Ticket links in search result
10.08.2011 12:58 пользователь "Raphaël MOUNEYRES" <
[email protected]> написал:
>
>
> Hello,
>
> thanks for the hint, but it doesn't work as expected.
> In fact, in the advanced page, the fileds used are :
> '__DependsOn__',
> '__Children__'
> each of them is, by default, creating by itself a List of clickable
ticket IDs, and i'd like to add subject and formatting.
>
> Also, in /share/html/Elements/RT__Ticket/ColumnMap, i can see that the
'ExtendedStatus' is doing some query for dependedon tickets, so i can try
to do something similar, but i can't find the same things for 'Children'
or 'DependsOn'
>
> If someone can point me at the sourcecode trigered by the above fields,
i could change it to suit my needs
Code for links in the same file. It's just generated with a loop.
> thank you,
>
> Raphaël MOUNEYRES
>
>
>
>
> Gerard FENELON <[email protected]>
> Envoyé par : [email protected]
>
> 09/08/2011 12:17
> A
> RT Users Mailing List <[email protected]>
> cc
> Objet
> Re: [rt-users] adding Ticket links in search result
>
>
>
>
>
> Hi Raphael
>
> keep to the list.
> In particular because I don't have the answer to this further question.
>
> I have never tried anything like what you are trying.
> It is possible that for this you might have to use a ColumnMap
>
> However concerning "display the Ticket subject next to his number"
> I believe that '__id__ __Subject__ ' should work.
>
> Gerard
>
>
> On 2011-08-09 11:28, Raphaël MOUNEYRES wrote:
>
> Hi Gerard,
>
> i've tried some but i'm not sure to be able to do conditional formatting
such as :
> % my $inactive =
$member->QueueObj->IsInactiveStatus($member->Status);
> <span class="<% $inactive ? 'ticket-inactive' : '' %>">
> <%$member->Id%>: (<%$member->OwnerObj->Name%>) <%$member->Subject%>
[<% loc($member->Status) %>]
> </span>
>
> for example, if i do
> ' <b><a
href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></b>/TITLE:#',
> '<span class="ticket-inactive">__Children__</span>'
> for sure all children tickets are displayed as ticket-inactive, but not
depending on their actual status...
>
> Also i'd like to display the Ticket subject next to his number....
> Well i'm doing more experiments now, but any other hints are welcome.
>
> Raphaël MOUNEYRES
>
>
> Gerard FENELON <[email protected]>
> Envoyé par : [email protected]
>
> 09/08/2011 11:08
>
> A
> [email protected]
> cc
> Objet
> Re: [rt-users] adding Ticket links in search result
>
>
>
>
>
> Hello
>
> you can do a lot of things in the advanced tab of the search interface
> such as
>
> '<b><a href="/Ticket/Modify.html?id=__id__">__id__</a></b>/TITLE:#',
> '<span
class="yoyodine-status-__StatusNoLoc__">__ExtendedStatus__</span>',
> '<span
class="yoyodine-severity-__CustomField.{Severity}__">__CustomField.{Severity}__</span>',
> '<span class="yoyodine-priority-__CustomField.{Customer
priority}__">__CustomField.{Customer priority}__</span>',
>
> I would say, use this when you want to tweek the display.
> Use ColumnMap when you have to calculate values
>
> Gerard
>
>
> On 2011-08-09 10:48, Raphaël MOUNEYRES wrote:
> Hello,
>
> i'm trying to build a search wich would have a colum displaying the
tickets links exactly the same way as is TicketDisplay page (with 3.8
install)
> I found two things :
> - this code related to the above page is in
/opt/rt3/share/html/Elements/ShowLinks
> - in ticket search engine, i can display children/DependsOn links, but
the result will only show ticket ids without formatting.
>
> Should i create a new ColumnMap (as recently discussed) pasting some
code from the ShowLinks File, or any simpler way to modify the existing
colums ?
> Could someone help me choose the best way to go ?
>
> After a few month dealing with RT, i've been gaining some perl
programming experience, thanks guys !
>
> Raphaël MOUNEYRES
>
> --------
> 2011 Training: http://bestpractical.com/services/training.html
>
> #
> " Ce courriel et les documents qui lui sont joints peuvent contenir des
> informations confidentielles ou ayant un caractère privé. S'ils ne vous
sont
> pas destinés, nous vous signalons qu'il est strictement interdit de les
> divulguer, de les reproduire ou d'en utiliser de quelque manière que ce
> soit le contenu. Si ce message vous a été transmis par erreur, merci
d'en
> informer l'expéditeur et de supprimer immédiatement de votre système
> informatique ce courriel ainsi que tous les documents qui y sont
attachés."
>
>
> ******
>
> " This e-mail and any attached documents may contain confidential or
> proprietary information. If you are not the intended recipient, you are
> notified that any dissemination, copying of this e-mail and any
attachments
> thereto or use of their contents by any means whatsoever is strictly
> prohibited. If you have received this e-mail in error, please advise the
> sender immediately and delete this e-mail and all attached documents
> from your computer system."
> #
>
>
> --------
> RT Training Sessions (http://bestpractical.com/services/training.html)
> * Chicago, IL, USA — September 26 & 27, 2011
> * San Francisco, CA, USA — October 18 & 19, 2011
> * Washington DC, USA — October 31 & November 1, 2011
> * Melbourne VIC, Australia — November 28 & 29, 2011
> * Barcelona, Spain — November 28 & 29, 2011
#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caractère privé. S'ils ne vous
sont
pas destinés, nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque manière que ce
soit le contenu. Si ce message vous a été transmis par erreur, merci d'en
informer l'expéditeur et de supprimer immédiatement de votre système
informatique ce courriel ainsi que tous les documents qui y sont
attachés."
******
" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any
attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#
--------
RT Training Sessions (http://bestpractical.com/services/training.html)
* Chicago, IL, USA — September 26 & 27, 2011
* San Francisco, CA, USA — October 18 & 19, 2011
* Washington DC, USA — October 31 & November 1, 2011
* Melbourne VIC, Australia — November 28 & 29, 2011
* Barcelona, Spain — November 28 & 29, 2011
--
Best regards, Ruslan.
#
" Ce courriel et les documents qui lui sont joints peuvent contenir des
informations confidentielles ou ayant un caract�re priv�. S'ils ne vous sont
pas destin�s, nous vous signalons qu'il est strictement interdit de les
divulguer, de les reproduire ou d'en utiliser de quelque mani�re que ce
soit le contenu. Si ce message vous a �t� transmis par erreur, merci d'en
informer l'exp�diteur et de supprimer imm�diatement de votre syst�me
informatique ce courriel ainsi que tous les documents qui y sont attach�s."
******
" This e-mail and any attached documents may contain confidential or
proprietary information. If you are not the intended recipient, you are
notified that any dissemination, copying of this e-mail and any attachments
thereto or use of their contents by any means whatsoever is strictly
prohibited. If you have received this e-mail in error, please advise the
sender immediately and delete this e-mail and all attached documents
from your computer system."
#
--------
RT Training Sessions (http://bestpractical.com/services/training.html)
* Chicago, IL, USA September 26 & 27, 2011
* San Francisco, CA, USA October 18 & 19, 2011
* Washington DC, USA October 31 & November 1, 2011
* Melbourne VIC, Australia November 28 & 29, 2011
* Barcelona, Spain November 28 & 29, 2011