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

? sunnavy sunnavy at bestpractical.com
Wed Jun 10 16:31:16 EDT 2020


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

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

    Link to RT ticket create on RTIR create pages
    
    It's possible that users couldn't access RT ticket create page, when
    their default queue 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>

commit aebb4794467ae47558b34c3318e35c7f58d1dffd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jun 11 03:33:30 2020 +0800

    Don't redirect to RTIR create on RT create page if there is no default queue
    
    When there is no default queue, RT defaults to the first queue current
    user can create in alphabetic order, which could be an RTIR one. In such
    case, it's more correct to stick to RT create page, where user could
    choose from all the queues. So here we default to the first non-RTIR
    queue instead.

diff --git a/html/Callbacks/RTIR/Ticket/Create.html/Init b/html/Callbacks/RTIR/Ticket/Create.html/Init
new file mode 100644
index 00000000..aa261984
--- /dev/null
+++ b/html/Callbacks/RTIR/Ticket/Create.html/Init
@@ -0,0 +1,65 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%INIT>
+# RTIR create pages also call this callback, which we need to skip too
+return if $ARGSRef->{Queue} || $m->request_path =~ m{^/RTIR/} || GetDefaultQueue();
+
+# Find the first non-RTIR queue current user can create
+my $cache_key = SetObjectSessionCache(
+    ObjectType       => 'Queue',
+    CheckRight       => 'CreateTicket',
+    CacheNeedsUpdate => RT->System->QueueCacheNeedsUpdate,
+);
+my ($queue) = map { $_->{Id} } grep { !RT::IR->OurQueue( $_->{Id} ) } @{ $session{$cache_key}{objects} };
+$ARGSRef->{Queue} = $queue if $queue;
+
+</%INIT>
+
+<%ARGS>
+$ARGSRef => {}
+</%ARGS>

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


More information about the rt-commit mailing list