1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 %# CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 %# END BPS TAGGED BLOCK }}}
48 % if ( $ARGS{id} && $ARGS{id} ne 'new' && RT->Config->Get('LinkArticlesOnInclude') ) {
49 <input type="hidden" name="<%$ARGS{'id'}%>-RefersTo" value="<% join(' ',grep {$_} sort keys %uri) %>" />
52 <table class="articles-select-article">
53 % unless (RT->Config->Get('HideArticleSearchOnReplyCreate')) {
55 <td><&|/l&>Search for Articles matching</&></td>
56 <td><input size=20 name="<% $name_prefix %>Articles_Content" /></td>
59 <td><&|/l&>Include Article:</&></td>
60 <td><input size=20 name="<% $name_prefix %>Articles-Include-Article-Named" /></td>
61 <td><input type="submit" name="Go" value="Go" /></td>
64 % if ($hotlist->Count) {
66 <td><&|/l&>Select an Article to include</&></td>
67 <td><select name="<% $name_prefix %>Articles-Include-Article-Named-Hotlist" onchange="this.form.submit()">
68 <option value="" selected><&|/l&>-</&></option>
69 % while (my $article = $hotlist->Next) {
70 <option value="<% $article->Id %>"><%$article->Name|| loc('(no name)')%>: <%$article->Summary || ''%></option>
74 <td><input type="submit" name="Go" value="Go" /></td>
77 % my %dedupe_articles;
78 % while (my $article = $articles_content->Next) {
79 % $dedupe_articles{$article->Id}++;
82 <td><%$article->Name|| loc('(no name)')%>: <%$article->Summary%></td>
83 <td><input type="submit" name="<% $name_prefix %>Articles-Include-Article-<%$article->Id%>" value="Go" /></td>
86 % while (my $article = $articles_basics->Next) {
87 % next if $dedupe_articles{$article->Id};
90 <td><%$article->Name || loc('(no name)')%>: <%$article->Summary || ''%></td>
91 <td><input type="submit" name="<% $name_prefix %>Articles-Include-Article-<%$article->Id%>" value="Go" /></td>
97 <&|/l, $QueueObj->Name &>Choose from Topics for [_1]</&>
100 <select name="<% $name_prefix %>Articles-Include-Topic" onchange="this.form.submit()">
101 <option value="" selected>-</option>
103 <option value="<% $_->{id} %>"><%' ' x $_->{depth} . ($_->{name}|| loc('(no name)')) |n%>
108 <td><input type="submit" name="Go" value="Go" /></td>
111 % if ( $ARGS{$name_prefix .'Articles-Include-Topic'} ) {
114 <&|/l, $included_topic->Name &>Select an Article from [_1]</&>
117 <select name="<% $name_prefix %>Articles-Include-Article" onchange="this.form.submit()">
118 <option value="" selected>-</option>
119 % while ( my $art = $topic_articles->Next ) {
120 <option value="<% $art->id %>"><%$art->Name||loc('(no name)')%>: <%$art->Summary%></option>
124 <td><input type="submit" value="Go" name="Go" /></td>
134 my $QueueObj = $ARGS{QueueObj};
135 if ( $ARGS{id} && $ARGS{id} ne 'new' && !$QueueObj ) {
136 my $ticket = RT::Ticket->new( $session{CurrentUser} );
137 $ticket->Load( $ARGS{id} );
138 $QueueObj = $ticket->QueueObj;
142 $m->callback(CallbackName => "Init", skip => \$skip, Queue => $QueueObj);
145 my $name_prefix = '';
146 if ( $ARGS{'MessageBoxName'} ) {
147 $name_prefix = $ARGS{'MessageBoxName'} .'-';
150 # convert Articles-Include-Article => $id to Articles-Include-Article-$id
151 if ( my $tmp = $ARGS{$name_prefix ."Articles-Include-Article"} ) {
152 $ARGS{$name_prefix ."Articles-Include-Article-$tmp"}++;
156 if ( $ARGS{id} && $ARGS{id} ne 'new' ) {
157 $uri{$_}++ for split ' ', ($ARGS{$ARGS{'id'}.'-RefersTo'} || '');
159 foreach my $arg (keys %ARGS) {
160 next if $name_prefix && substr($arg, 0, length($name_prefix)) ne $name_prefix;
162 my $article = RT::Article->new($session{'CurrentUser'});
163 $article->LoadByInclude(
164 Field => substr($arg, length($name_prefix)),
165 Value => $ARGS{$arg},
168 $uri{$article->URI}++;
175 my $articles_content =
176 RT::Articles->new( $session{'CurrentUser'} );
177 my $articles_basics = RT::Articles->new( $session{'CurrentUser'} );
178 if ( my $tmp = $ARGS{ $name_prefix ."Articles_Content" } ) {
179 $articles_content->LimitCustomField(
180 VALUE => $tmp, OPERATOR => 'LIKE'
182 $articles_content->LimitAppliedClasses( Queue => $QueueObj );
184 $articles_basics->Limit( SUBCLAUSE => 'all',
188 ENTRYAGGREGATOR => "OR" );
189 $articles_basics->Limit( SUBCLAUSE => 'all',
193 ENTRYAGGREGATOR => "OR" );
194 $articles_basics->LimitAppliedClasses( Queue => $QueueObj );
197 my $hotlist = RT::Articles->new( $session{'CurrentUser'} );
198 $hotlist->LimitHotlistClasses;
199 $hotlist->LimitAppliedClasses( Queue => $QueueObj );
201 my ( $topic_articles, $topics, $included_topic );
202 $topic_articles = RT::Articles->new( $session{CurrentUser} );
205 my $top_topic = RT::Topic->new( $session{CurrentUser} );
206 $top_topic->LoadByCols( Name => 'Queues', Parent => 0 , ObjectType => 'RT::System', ObjectId => 1);
208 if ( $top_topic->id ) {
209 my $queue_topic = RT::Topic->new( $session{CurrentUser} );
210 $queue_topic->LoadByCols( Name => $QueueObj->Name, Parent => $top_topic->id );
211 if ( $queue_topic->id ) {
213 # store all topics below $queue_topic to $topics
214 topics( $queue_topic, $topics, 0 );
216 if ( my $tmp = $ARGS{ $name_prefix .'Articles-Include-Topic'} ) {
217 $included_topic = RT::Topic->new( $session{CurrentUser} );
218 $included_topic->Load( $tmp );
219 $topic_articles->LimitTopics( $tmp );
220 $topic_articles->OrderBy( FIELD => 'Name' );
226 # recursively get all the topics given a top topic
231 while ( my $topic = $parent->Children->Next ) {
232 push @$out, { id => $topic->id, name => $topic->Name, depth => $depth };
233 topics( $topic, $out, $depth+1 );