[Rt-commit] rt branch, 4.4/queue-include-article, repushed
Craig Kaiser
craig at bestpractical.com
Fri Jan 12 08:41:41 EST 2018
The branch 4.4/queue-include-article was deleted and repushed:
was 33862b2ec4f58e6ce3947066d8cb29917ff734e0
now b78185488e6776d52c71fbe34a2ca8e9e43f9453
1: 06593b6a3 ! 1: b78185488 Include Article on Ticket create per Queue
@@ -1,10 +1,11 @@
Author: Craig Kaiser <craig at bestpractical.com>
- Include Article on ticket create, based on queue
+ Include Article on Ticket create per Queue
- Add functionality to include an Articles content automatically on Ticket create
- for the specified Queue. This feature can be set on Queue create and
- Queue modify.
+ Can add a default Article to Queues. Where the content of the Article
+ will be added to each Ticket created in that Queue, on create. The Article to be
+ included per Queue can be set in the web UI page for modifying Queue or
+ in RT_SiteConfig.
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
--- a/lib/RT/Queue.pm
@@ -34,7 +35,7 @@
+sub ArticleIncluded {
+ my $self = shift;
+ my $value = shift;
-+
+
+ my $attr = $self->FirstAttribute('ArticleIncluded') or return 0;
+ return $attr->Content;
+}
@@ -50,7 +51,7 @@
+ if ( $MyArticle->ValidateName($value) and $value ){
+ return (0, $self->loc("Invalid Article Name [_1]", $value));
+ }
-
++
+ my ($status, $msg) = $self->SetAttribute(
+ Name => 'ArticleIncluded',
+ Description => 'Include Article on ticket create, for Queue.',
@@ -75,6 +76,11 @@
+==head2 SetArticleIncluded
+
+Takes a name value and sets the ArticleIncluded attr for the queue to that name.
++Can also set the article to be included in RT_SiteConfig.pm:
++ Set(%ArticleIncluded,
++ 'MyQueue' => 'MyArticle',
++ 'General' => 'General Info'
++ );
+
=head2 SubjectTag
@@ -95,11 +101,15 @@
$args{'Status'} = $cycle->DefaultOnCreate;
}
-+ if ( $QueueObj->ArticleIncluded ) {
++ my %config = RT->Config->Get('ArticleIncluded') unless ( !RT->Config->Get('ArticleIncluded') );
++ if ( $QueueObj->ArticleIncluded || exists($config{$QueueObj->Name})) {
+ my $MyArticle = RT::Article->new(RT->SystemUser);
++ if ( $MyArticle->ValidateName($config{$QueueObj->Name}) and $config{$QueueObj->Name} ) {
++ return (0, 0, "Invalid Article Name: $config{$QueueObj->Name}, check your RT_SiteConfig.pm");
++ }
+ my $ObjectCustomFieldValue = RT::ObjectCustomFieldValue->new(RT->SystemUser);
+ my $MIMEObj = $args{'MIMEObj'};
-+ $MyArticle->LoadByCols(Name => $QueueObj->ArticleIncluded);
++ $MyArticle->LoadByCols(Name => $QueueObj->ArticleIncluded ? $QueueObj->ArticleIncluded : $config{$QueueObj->Name} );
+ $ObjectCustomFieldValue->LoadByCols(ObjectId => $MyArticle->id);
+ my $ArticleContent = MIME::Entity->build( Type => "text/plain" , Data => $ObjectCustomFieldValue->Content() );
+ $MIMEObj->add_part($ArticleContent);
@@ -108,6 +118,21 @@
$args{'Status'} = lc $args{'Status'};
unless ( $cycle->IsValid( $args{'Status'} ) ) {
return ( 0, 0,
+@@
+ }
+ }
+
++=head2 ArticleIncluded
++
++Provide a hash %ArticleIncluded where the Queue and the article name are specified.
++ Set(%ArticleIncluded,
++ General => MyArticle,
++ );
++
++=cut
+
+ =head2 DeleteWatcher
+
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
--- a/share/html/Admin/Queues/Modify.html
@@ -116,13 +141,30 @@
% }
</td></tr>
-+<tr><td align="right"><&|/l&>Include Article</&>:</td>
-+ <td colspan="3"><input name="ArticleIncluded" value="<% $ARGS{'ArticleIncluded'} || ($Create ? "" : $QueueObj->ArticleIncluded || '' ) %>" size="20"/></td>
++<td><&|/l&>Include Article:</&></td>
++<td><select name="ArticleIncluded">
++ <option value="<% $ARGS{'ArticleInclduded'} || ($Create ? "" : $QueueObj->ArticleIncluded || '') %>"><% $ARGS{'ArticleIncluded'} || ($QueueObj->ArticleIncluded || '-') %></option>
++<option value="">-</option>
++% while (my $article = $hotlist->Next) {
++<option value="<% $article->Name %>"><% $article->Name %></option>
++% }
++</select>
+</tr>
+
<tr><td align="right"><&|/l&>Subject Tag</&>:</td>
<td colspan="3"><input name="SubjectTag" value="<% $ARGS{'SubjectTag'} || ($Create ? "" : $QueueObj->SubjectTag || '' ) %>" size="60" /></td>
</tr>
+@@
+ my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
+ $QueueObj->Load( $id ) if !$id || $id eq 'new';
+
++my $hotlist = RT::Articles->new( $session{'CurrentUser'});
++$hotlist->LimitHotlistClasses;
++$hotlist->LimitAppliedClasses ( Queue => $QueueObj );
++
+ $EnabledChecked = 'checked="checked"';
+
+ unless ($Create) {
@@
$QueueObj->Load($id) || $QueueObj->Load($Name) || Abort(loc("Couldn't load queue '[_1]'", $Name));
}
@@ -152,4 +194,3 @@
$SetEnabled => undef
$SetCrypt => undef
$SLAEnabled => undef
-
2: 94acd171d < -: ------- Change input method for Article, to drop down box
3: 84143cf64 < -: ------- Articles can be set in config per Queue
4: 33862b2ec < -: ------- Allow user to switch to no Article to be included
More information about the rt-commit
mailing list