[Rt-commit] rtir branch, 4.0/hide-lookup-on-selfservice, created. 4.0.0rc2-1-g909c7d4

Jim Brandt jbrandt at bestpractical.com
Fri Jul 8 13:08:07 EDT 2016


The branch, 4.0/hide-lookup-on-selfservice has been created
        at  909c7d4d2fcdfd58f22b32ad9124702c6ea45f8e (commit)

- Log -----------------------------------------------------------------
commit 909c7d4d2fcdfd58f22b32ad9124702c6ea45f8e
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jul 8 13:06:07 2016 -0400

    Suppress lookup and other RTIR auto linking in SelfService
    
    SelfService users don't have access to the lookup tool or other
    resources automatically linked to with the RTIR MakeClicky
    code, so skip it for SelfService.
    
    Fixes: I#31868

diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index 2b08856..c3ac85f 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -57,13 +57,19 @@ my $escaper = sub {
 
 my %super = %{$ARGS{actions}};
 
+# Don't show links in the Self Service interface
+my $SelfService = 0;
+my $request_path = $HTML::Mason::Commands::r->path_info;
+$request_path =~ s!/{2,}!/!g;
+$SelfService = 1 if $request_path =~ m{^/SelfService/};
+
 my %actions;
 %actions = (
     default => sub {
         my %args = @_;
         $args{value} = $escaper->($args{value});
-        # don't execute on non-rtir tickets
-        return $args{value} unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $args{value} unless defined $args{type} and !$SelfService;
         return qq{<a href="}. RT::IR->HREFTo("Tools/Lookup.html?".$args{lookup_params}."q=".$args{value}).qq{">$args{value}</a>};
     },
     url => sub {
@@ -73,8 +79,8 @@ my %actions;
         my $escaped_host = $escaper->($host);
         my $super = $super{url} ? $super{url}->(%args) : $escaper->($args{value});
 
-        # don't execute on non-rtir tickets
-        return $super unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $super unless defined $args{type} and !$SelfService;
 
         my $result = qq{<a class="button" href="}. RT::IR->HREFTo("Tools/Lookup.html?".$args{lookup_params}."type=host&q=".$escaped_host).qq{">}
             .loc('lookup "[_1]"', $host) .qq{</a>};
@@ -87,8 +93,8 @@ my %actions;
         my $escaped_host = $escaper->($host);
         my $super = $super{url_overwrite} ? $super{url_overwrite}->(%args) : $escaper->($args{value});
 
-        # don't execute on non-rtir tickets
-        return $super unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $super unless defined $args{type} and !$SelfService;
 
         my $result = qq{<a class="button" href="}. RT::IR->HREFTo("Tools/Lookup.html?".$args{lookup_params}."type=host&q=".$escaped_host).qq{">}
             .loc('lookup "[_1]"', $host) .qq{</a>};
@@ -97,8 +103,8 @@ my %actions;
     ip => sub {
         my %args = @_;
 
-        # don't execute on non-rtir tickets
-        return $escaper->($args{value}) unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $escaper->($args{value}) unless defined $args{type} and !$SelfService;
 
         $args{host} ||= $args{value};
         my $escaped_host = $escaper->($args{host});
@@ -123,8 +129,8 @@ my %actions;
     ipdecimal => sub {
         my %args = @_;
 
-        # don't execute on non-rtir tickets
-        return $escaper->($args{value}) unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $escaper->($args{value}) unless defined $args{type} and !$SelfService;
 
         my $i = unpack "L",$args{value};
         return $args{value} unless $args{value} > 33554432;
@@ -142,8 +148,8 @@ my %actions;
     email => sub {
         my %args = @_;
 
-        # don't execute on non-rtir tickets
-        return $escaper->($args{value}) unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $escaper->($args{value}) unless defined $args{type} and !$SelfService;
 
         my $email = $args{'value'}; $email =~ s/^<|>$//g;
         my $escaped_email = $escaper->($email);
@@ -172,8 +178,8 @@ my %actions;
     noc => sub {
         my %args = @_;
 
-        # don't execute on non-rtir tickets
-        return $escaper->($args{value}) unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $escaper->($args{value}) unless defined $args{type} and !$SelfService;
 
         $args{value} = $escaper->($args{value});
         my $result = qq{<a class="button" href="}. RT::IR->HREFTo(qq{Tools/Lookup.html?$args{lookup_params}type=handle&q=$args{value}}).qq{">}
@@ -183,8 +189,8 @@ my %actions;
     host => sub {
         my %args = @_;
 
-        # don't execute on non-rtir tickets
-        return $escaper->($args{value}) unless defined $args{type};
+        # don't execute on non-rtir tickets or in SelfService
+        return $escaper->($args{value}) unless defined $args{type} and !$SelfService;
 
         $args{value} = $escaper->($args{value});
         my $result = qq{<a class="button" href="}. RT::IR->HREFTo(qq{Tools/Lookup.html?$args{lookup_params}type=host&q=$args{value}}). qq{">}

-----------------------------------------------------------------------


More information about the rt-commit mailing list