%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC %# %# %# (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 }}} <& /Elements/Header, Title => loc('Browse by topic') &> <& /Elements/Tabs &> <&|/l&>All topics % if (defined $class) { > <% $currclass_name %> % } % if ($id != 0) { > <& /Articles/Elements/ShowTopic, topic => $currtopic &> % }

<&|/l&>Browse by topic

% if (defined $class) {

<% $currclass_name %>

% my $rtopic = RT::Topic->new( $session{'CurrentUser'} ); % $rtopic->Load($id); % unless ( $rtopic->Id() % && $rtopic->ObjectId() == $currclass->Id ) % { % # Show all of them % $ProduceTree->( 0 ); % } else { % my @showtopics = ( $rtopic ); % my $parent = $rtopic->ParentObj; % while ( $parent->Id ) { % unshift @showtopics, $parent; % $parent = $parent->ParentObj; % } % # List the topics. % for my $t ( @showtopics ) { % } % } % } else { % }
% if (@articles) { % if ($id) {

<&|/l, $currtopic->Name&>Articles in [_1]

% } elsif ($class) {

<&|/l&>Articles with no topics

% } % } <%init> my $Classes; my $currclass; my $currclass_id; my $currclass_name; my $currtopic; if ( defined $class ) { if ($class) { $currclass = RT::Class->new( $session{'CurrentUser'} ); $currclass->Load($class); $currclass_id = $currclass->Id; $currclass_name = $currclass->Name; } else { $currclass = $RT::System; $currclass_id = 0; $currclass_name = 'Global Topics'; } } else { $Classes = RT::Classes->new( $session{'CurrentUser'} ); $Classes->LimitToEnabled(); } if ($id) { $currtopic = RT::Topic->new( $session{'CurrentUser'} ); $currtopic->Load($id); } my $ProduceTree; $ProduceTree = sub { my ( $parentid ) = @_; my $topics = RT::Topics->new( $session{'CurrentUser'} ); $topics->LimitToObject($currclass); $topics->LimitToKids($parentid || 0); $topics->OrderBy( FIELD => 'Name' ); return unless $topics->Count; $m->out(""); }; my @articles; if ($id) { my $Articles = RT::ObjectTopics->new($session{'CurrentUser'}); $Articles->Limit(FIELD => 'ObjectType', VALUE => 'RT::Article'); $Articles->Limit(FIELD => 'Topic', VALUE => $id); while (my $objtopic = $Articles->Next) { my $a = RT::Article->new($session{'CurrentUser'}); $a->Load($objtopic->ObjectId); push @articles, $a; } } elsif ($class) { my $Articles = RT::Articles->new($session{'CurrentUser'}); my $TopicsAlias = $Articles->Join( TYPE => 'left', ALIAS1 => 'main', FIELD1 => 'id', TABLE2 => 'ObjectTopics', FIELD2 => 'ObjectId', ); $Articles->Limit( LEFTJOIN => $TopicsAlias, FIELD => 'ObjectType', VALUE => 'RT::Article', ); $Articles->Limit( ALIAS => $TopicsAlias, FIELD => 'Topic', OPERATOR => 'IS', VALUE => 'NULL', QUOTEVALUE => 0, ); $Articles->Limit( FIELD => 'Class', OPERATOR => '=', VALUE => $class, ); @articles = @{$Articles->ItemsArrayRef}; } <%args> $id => 0 $class => undef $showall => undef