1%# BEGIN BPS TAGGED BLOCK {{{ 2%# 3%# COPYRIGHT: 4%# 5%# This software is Copyright (c) 1996-2021 Best Practical Solutions, LLC 6%# <sales@bestpractical.com> 7%# 8%# (Except where explicitly superseded by other copyright notices) 9%# 10%# 11%# LICENSE: 12%# 13%# This work is made available to you under the terms of Version 2 of 14%# the GNU General Public License. A copy of that license should have 15%# been provided with this software, but in any event can be snarfed 16%# from www.gnu.org. 17%# 18%# This work is distributed in the hope that it will be useful, but 19%# WITHOUT ANY WARRANTY; without even the implied warranty of 20%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21%# General Public License for more details. 22%# 23%# You should have received a copy of the GNU General Public License 24%# along with this program; if not, write to the Free Software 25%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 26%# 02110-1301 or visit their web page on the internet at 27%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. 28%# 29%# 30%# CONTRIBUTION SUBMISSION POLICY: 31%# 32%# (The following paragraph is not intended to limit the rights granted 33%# to you to modify and distribute this software under the terms of 34%# the GNU General Public License and is only of importance to you if 35%# you choose to contribute your changes and enhancements to the 36%# community by submitting them to Best Practical Solutions, LLC.) 37%# 38%# By intentionally submitting any modifications, corrections or 39%# derivatives to this work, or any other work intended for use with 40%# Request Tracker, to Best Practical Solutions, LLC, you confirm that 41%# you are the copyright holder for those contributions and you grant 42%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, 43%# royalty-free, perpetual, license to use, copy, create derivative 44%# works based on those contributions, and sublicense and distribute 45%# those contributions and any derivatives thereof. 46%# 47%# END BPS TAGGED BLOCK }}} 48<%PERL> 49 50foreach my $queues ( @{ $portlet_config{ $queue } } ) { 51 foreach my $queue_name ( keys %{ $queues } ) { 52 my $queue_obj = RT::Queue->new( $session{ CurrentUser } ); 53 my ( $ret ) = $queue_obj->Load( $queue_name ); 54 unless ( $ret ) { 55 RT::Logger->error( "Couldn't load queue $queue_name" ); 56 next; 57 } 58 my $link_types = $queues->{$queue_name}; 59 my $query = "Queue = '$queue_name'"; 60 61 my $ticket_id = $TicketObj->id; 62 if ( grep { lc $_ eq 'all' } @$link_types ) { 63 $query .= " AND ( LinkedTo = $ticket_id OR LinkedFrom = $ticket_id )"; 64 } 65 else { 66 my @link_relations = map { $_ . " = $ticket_id" } @$link_types; 67 my $link_query = join( ' OR ', @link_relations ); 68 if ($link_query) { 69 $query .= ' AND ( ' . $link_query . ' )'; 70 } 71 else { 72 $query = 'id=0'; 73 } 74 } 75 76 # create an identifiable class name for the linked queue portlet so 77 # we can specifically target it apart from ticket-info-links. 78 my $linked_queue_class = 'linked-queue'; 79 80 my $query_string = $m->comp( '/Elements/QueryString', Query => $query ); 81 my $title_href = RT->Config->Get( 'WebPath' ) . "/Search/Results.html?$query_string"; 82 my $title_class = 'inverse'; 83 my $class = 'ticket-info-links' . ' ' . $linked_queue_class; 84 my $titleright_raw = ''; 85 86$m->callback( CallbackName => 'MassageTitleBox', 87 ARGSRef => \%ARGS, 88 title => \$queue_name, 89 title_href => \$title_href, 90 titleright_raw => \$titleright_raw, 91 title_class => \$title_class, 92 class => \$class, 93); 94 95</%PERL> 96 97<&| /Widgets/TitleBox, 98 title => $queue_name, 99 title_href => $title_href, 100 titleright_raw => $titleright_raw, 101 title_class => $title_class, 102 class => $class, 103 content_class => 'linked-queue-portlet', 104&> 105 106<%PERL> 107my @queries = map { "$query AND $_" } q{Status = '__Active__'}, q{Status = '__Inactive__'}; 108my @empty_messages = ( loc( '(No active tickets)' ), loc( '(No inactive tickets)' ) ); 109 110$m->callback( CallbackName => 'MassageQueries', 111 ARGSRef => \%ARGS, 112 Queue => $queue_name, 113 Queries => \@queries, 114 EmptyMessages => \@empty_messages, 115); 116 117my $format = ( exists RT->Config->Get('LinkedQueuePortletFormats')->{$queue_name} 118 ? RT->Config->Get('LinkedQueuePortletFormats')->{$queue_name} 119 : RT->Config->Get('LinkedQueuePortletFormats')->{'Default'} ); 120 121my $i = 0; 122for my $query ( @queries ) { 123 $i++; 124 my $empty_message = shift @empty_messages; 125 my $order_by = $OrderBy; 126 my $rows = $Rows; 127 128$m->callback( CallbackName => 'MassageSearchArgs', 129 ARGSRef => \%ARGS, 130 Queue => $queue_name, 131 Query => $query, 132 Format => \$format, 133 OrderBy => \$order_by, 134 Rows => \$rows, 135); 136 my $tickets = RT::Tickets->new($session{CurrentUser}); 137 $tickets->FromSQL($query); 138 if ( $tickets->Count ) { 139</%PERL> 140<& /Elements/CollectionList, %ARGS, 141 %$DECODED_ARGS, 142 Class => 'RT::Tickets', 143 Query => $query, 144 Format => $format, 145 OrderBy => $order_by, 146 Rows => $rows, 147 ShowHeader => 0, 148 Page => $DECODED_ARGS->{"Page-$queue_name-$i"} || 1, 149 PageParam => "Page-$queue_name-$i", 150 PassArguments => [ keys %$DECODED_ARGS ], 151&> 152 153% } else { 154 <div class="empty-message"><% $empty_message %></div> 155% } 156% } 157 158</&> 159% } 160%} 161<%INIT> 162my %portlet_config = RT->Config->Get( 'LinkedQueuePortlets' ); 163return unless %portlet_config; 164my $queue = $TicketObj->QueueObj->Name; 165return unless $portlet_config{ $queue }; 166</%INIT> 167 168 169<%ARGS> 170$TicketObj 171$OrderBy => 'Due' 172$Rows => 8 173</%ARGS> 174