[Rt-commit] rt branch, 4.4/queue-include-article, repushed
Craig Kaiser
craig at bestpractical.com
Tue Jan 16 14:39:57 EST 2018
The branch 4.4/queue-include-article was deleted and repushed:
was b78185488e6776d52c71fbe34a2ca8e9e43f9453
now 2dc903d4fbf4e382e8123a6eeee73225300acf9c
1: b78185488 ! 1: 2dc903d4f Include Article on Ticket create per Queue
@@ -4,8 +4,7 @@
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.
+ included per Queue can be set in the web UI page for modify Queue.
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
--- a/lib/RT/Queue.pm
@@ -35,7 +34,7 @@
+sub ArticleIncluded {
+ my $self = shift;
+ my $value = shift;
-
++
+ my $attr = $self->FirstAttribute('ArticleIncluded') or return 0;
+ return $attr->Content;
+}
@@ -44,10 +43,18 @@
+ my $self = shift;
+ my $value = shift;
+
++ my $MyArticle = RT::Article->new(RT->SystemUser);
++ unless ( $value =~ /^\d+$/ ) {
++ $MyArticle->LoadByCols( name => $value)
++ }else {
++ $MyArticle->LoadByCols( id => $value)
++ }
++ $value = $MyArticle->Name;
+
+ return ( 0, $self->loc('Permission Denied') )
+ unless $self->CurrentUserHasRight('AdminQueue');
+
-+ my $MyArticle = RT::Article->new(RT->SystemUser);
++ $MyArticle = RT::Article->new(RT->SystemUser);
+ if ( $MyArticle->ValidateName($value) and $value ){
+ return (0, $self->loc("Invalid Article Name [_1]", $value));
+ }
@@ -63,28 +70,6 @@
sub Delete {
my $self = shift;
-@@
-
- =cut
-
-+=head2 ArticleIncluded
-+
-+The article name to be included on create of any ticket created in the queue.
-+The ID value of the article will be loaded from the name, and used to get the article content in Ticket.pm.
-+
-+
-+==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
-
- Returns the current value of SubjectTag.
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
--- a/lib/RT/Ticket.pm
@@ -98,23 +83,10 @@
);
@@
+ unless ( defined $args{'Status'} && length $args{'Status'} ) {
$args{'Status'} = $cycle->DefaultOnCreate;
}
-
-+ 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 ? $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);
-+ }
-+
+-
$args{'Status'} = lc $args{'Status'};
unless ( $cycle->IsValid( $args{'Status'} ) ) {
return ( 0, 0,
@@ -122,17 +94,10 @@
}
}
-+=head2 ArticleIncluded
-+
-+Provide a hash %ArticleIncluded where the Queue and the article name are specified.
-+ Set(%ArticleIncluded,
-+ General => MyArticle,
-+ );
-+
-+=cut
-
+-
=head2 DeleteWatcher
+ Applies access control checking, then calls
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
--- a/share/html/Admin/Queues/Modify.html
@@ -141,35 +106,41 @@
% }
</td></tr>
-+<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 class='label' valign="right"><&|/l&>Article Included</&>:</td>
++<td class="messagebox-container">
++<& /Articles/Elements/BeforeMessageBox, %ARGS &>
++</td></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'} );
+
+ <%INIT>
+ my ($title, @results, @no_redirect_results, $Disabled, $EnabledChecked);
+-my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
++$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 );
++$ARGS{QueueObj} = $QueueObj;
++
++my @ArticlesIncluded = grep {/Articles-Include-Article-(.+)/} keys %ARGS;
++
++foreach(@ArticlesIncluded){
++ if( $ARGS{$_} eq 'Go' && length $ARGS{$_} ){
++ $_ =~ /Articles-Include-Article-(.+)/;
++ $ARGS{'ArticleIncluded'} = $1;
++ }elsif ( $ARGS{$_} ){
++ $ARGS{'ArticleIncluded'} = $ARGS{$_};
++ }
++}
+
$EnabledChecked = 'checked="checked"';
unless ($Create) {
@@
- $QueueObj->Load($id) || $QueueObj->Load($Name) || Abort(loc("Couldn't load queue '[_1]'", $Name));
- }
- }
--
if ( $QueueObj->Id ) {
$title = loc('Configuration for queue [_1]', $QueueObj->Name );
my @attribs= qw(Description CorrespondAddress CommentAddress Name SortOrder
@@ -179,6 +150,12 @@
# we're asking about enabled on the web page but really care about disabled
if ( $SetEnabled ) {
@@
+ AttributesRef => \@attribs,
+ ARGSRef => \%ARGS,
+ );
+-
+ push @results, UpdateRecordObject(
+ AttributesRef => \@attribs,
Object => $QueueObj,
ARGSRef => \%ARGS
);
@@ -186,6 +163,14 @@
$Disabled = $ARGS{'Disabled'} = $Enabled? 0: 1;
$EnabledChecked = "" if $QueueObj->Disabled;
+@@
+
+
+ <%ARGS>
++$QueueObj => undef
+ $id => undef
+ $result => undef
+ $Name => undef
@@
$CorrespondAddress => undef
$CommentAddress => undef
@@ -194,3 +179,47 @@
$SetEnabled => undef
$SetCrypt => undef
$SLAEnabled => undef
+
+diff --git a/share/html/Articles/Elements/BeforeMessageBox b/share/html/Articles/Elements/BeforeMessageBox
+--- a/share/html/Articles/Elements/BeforeMessageBox
++++ b/share/html/Articles/Elements/BeforeMessageBox
+@@
+ <tr>
+ <td><&|/l&>Select an Article to include</&></td>
+ <td><select name="<% $name_prefix %>Articles-Include-Article-Named-Hotlist" onchange="this.form.submit()">
+-<option value="" selected><&|/l&>-</&></option>
++% my $QueueObj = $ARGS{QueueObj};
++<option value="" selected><&|/l&><% $QueueObj? $QueueObj->ArticleIncluded? $QueueObj->ArticleIncluded: '-':'-'%></&></option>
++% if ( $QueueObj && $QueueObj->ArticleIncluded ) {
++<option value="undef">-</option>
++% }
+ % while (my $article = $hotlist->Next) {
+-<option value="<% $article->Id %>"><%$article->Name|| loc('(no name)')%>: <%$article->Summary || ''%></option>
++% if( $QueueObj ) { unless( $article->Name eq $QueueObj->ArticleIncluded ){
++<option value="<% $article->Id %>"><% $article->Name|| loc('(no name)')%>: <%$article->Summary || ''%></option>
++% } }else{
++<option value="<% $article->Id %>"><% $article->Name|| loc('(no name)')%>: <%$article->Summary || ''%></option>
++% }
+ % }
+ </select>
+ </td>
+
+diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
+--- a/share/html/Ticket/Create.html
++++ b/share/html/Ticket/Create.html
+@@
+ $m->abort();
+ }
+ }
++
++if ( $QueueObj->ArticleIncluded ) {
++ my $MyArticle = RT::Article->new(RT->SystemUser);
++ my $ObjectCustomFieldValue = RT::ObjectCustomFieldValue->new(RT->SystemUser);
++ $MyArticle->LoadByCols(name => $QueueObj->ArticleIncluded );
++ $ObjectCustomFieldValue->LoadByCols(ObjectId => $MyArticle->id);
++ $ARGS{Content} = $ObjectCustomFieldValue->Content();
++}
++
+ PageMenu->child( basics => raw_html => q[<a href="#basics" onclick="return switchVisibility('Ticket-Create-basics','Ticket-Create-details');">] . loc('Basics') . q[</a>]);
+ PageMenu->child( details => raw_html => q[<a href="#details" onclick="return switchVisibility('Ticket-Create-details','Ticket-Create-basics');">] . loc('Details') . q[</a>]);
+ </%INIT>
More information about the rt-commit
mailing list