[Rt-commit] rtir branch, 5.0/rt-create-ticket-link, created. 4.0.1rc1-148-gc6c3997f

? sunnavy sunnavy at bestpractical.com
Wed Jun 3 09:36:01 EDT 2020


The branch, 5.0/rt-create-ticket-link has been created
        at  c6c3997f787ecd301c3c59c2c97b5bbc75098bfb (commit)

- Log -----------------------------------------------------------------
commit c6c3997f787ecd301c3c59c2c97b5bbc75098bfb
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri May 29 22:49:33 2020 +0800

    Link to RT ticket create on RTIR create pages when possible
    
    It's possible that users couldn't access RT ticket create page, when
    their default queue or the first queue(in alphabetic order) they can
    create tickets in is an RTIR one, in which case RT will redirect to RTIR
    create pages automatically.
    
    This commit adds a link to RT ticket create page with a non-RTIR queue
    specified, to get around this edge issue.

diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 7532e80d..48d31381 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -543,4 +543,28 @@ PageWidgets()->child('simple_search')->raw_html( $m->scomp(
     Placeholder => 'Search Incidents'
 ) );
 PageWidgets()->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('/Elements/CreateTicket', SendTo => '/RTIR/Create.html?Queue=' . RT::IR::GetRTIRDefaultQueue()) );
+
+if ( $request_path =~ m{$re_rtir_path(?:Incident/)?Create\.html} ) {
+    my $default_queue = GetDefaultQueue();
+    my $queue;
+    if ( $default_queue && !RT::IR->OurQueue($default_queue) ) {
+        $queue = $default_queue;
+    }
+    else {
+        # Find the first non-RTIR queue current user can create
+        my $cache_key = SetObjectSessionCache(
+            ObjectType       => 'Queue',
+            CheckRight       => 'CreateTicket',
+            CacheNeedsUpdate => RT->System->QueueCacheNeedsUpdate,
+        );
+        ($queue) = map { $_->{Id} } grep { !RT::IR->OurQueue( $_->{Id} ) } @{ $session{$cache_key}{objects} };
+    }
+
+    if ($queue) {
+        PageMenu()->child(
+            rt_create_ticket => title => loc('RT Create Ticket'),
+            path             => "/Ticket/Create.html?Queue=$queue",
+        );
+    }
+}
 </%INIT>

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


More information about the rt-commit mailing list