[Rt-commit] rt branch 5.0/include-articles-msg-fix created. rt-5.0.4-71-g454dea7cc9

BPS Git Server git at git.bestpractical.com
Sat Jul 22 10:00:14 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/include-articles-msg-fix has been created
        at  454dea7cc94ebdbce61772dc89784cc6da67a99a (commit)

- Log -----------------------------------------------------------------
commit 454dea7cc94ebdbce61772dc89784cc6da67a99a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 22 12:43:15 2023 +0300

    actually support to include multiple articles at the same time

diff --git a/share/html/Elements/MessageBox b/share/html/Elements/MessageBox
index dc24afa547..dffac6bbef 100644
--- a/share/html/Elements/MessageBox
+++ b/share/html/Elements/MessageBox
@@ -50,7 +50,9 @@
   <div class="col-12">
 % }
 <textarea autocomplete="off" class="form-control messagebox <% $Type eq 'text/html' ? 'richtext' : '' %>" <% $SuppressAttachmentWarning ? 'suppress-attachment-warning' : '' %> <% $width_attr %>="<% $Width %>" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>" id="<% $Name %>" placeholder="<% $Placeholder %>">
-% $m->comp('/Articles/Elements/IncludeArticle', %ARGS, IncludeArticleId => $article_id, QueueObj => $QueueObj) if $IncludeArticle;
+% if ($IncludeArticle) {
+% $m->comp('/Articles/Elements/IncludeArticle', %ARGS, IncludeArticleId => $_, QueueObj => $QueueObj) for @article_id;
+% }
 % $m->callback( %ARGS, SignatureRef => \$signature, DefaultRef => \$Default, MessageRef => \$message );
 % if (RT->Config->Get("SignatureAboveQuote", $session{'CurrentUser'})) {
 <% $Default || '' %><% $signature %><% $message %></textarea>
@@ -136,16 +138,16 @@ if ( $IncludeSignature and $signature =~ /\S/ ) {
     $signature = '';
 }
 
-my $article_id;
+my @article_id;
 if ( $IncludeDefaultArticle && defined $QueueObj && $QueueObj->Id ) {
     # Load a default article
-    $article_id = $QueueObj->DefaultValue('Article') if $QueueObj->DefaultValue('Article');
-}
-else {
-    # Load from the page, if provided
-    $article_id = $ARGS{'IncludeArticleId'} if $ARGS{'IncludeArticleId'};
+    push @article_id, $QueueObj->DefaultValue('Article')
+        if $QueueObj->DefaultValue('Article');
 }
 
+# Load from the page, if provided
+push @article_id, grep $_, @IncludeArticleId;
+
 # wrap="something" seems to really break IE + richtext
 my $wrap_type = $Type eq 'text/html' ? '' : 'wrap="soft"';
 
@@ -168,6 +170,7 @@ $Width                     => RT->Config->Get('MessageBoxWidth', $session{'Curre
 $Height                    => RT->Config->Get('MessageBoxHeight', $session{'CurrentUser'} ) || 15
 $IncludeSignature          => RT->Config->Get('MessageBoxIncludeSignature');
 $IncludeArticle            => 1;
+ at IncludeArticleId          => ();
 $Type                      => RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'}) ? 'text/html' : 'text/plain';
 $SuppressAttachmentWarning => 0
 $Placeholder               => loc('Type your message here')

commit 2f66feb3b9c96101bd84be9a6a684c99e3e59aff
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Jul 22 12:25:06 2023 +0300

    IncludeArticleId can be an array, fix checks on Create/Update

diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index aa412c30f8..aac9fd98de 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -523,14 +523,14 @@ if ( $ARGS{SubmitTicket} ) {
     $checks_failure = 1 unless $status;
 }
 
-if ($ARGS{IncludeArticleId}) {
+for my $aid (@IncludeArticleId) {
     my $article = RT::Article->new($session{'CurrentUser'});
-    my ($ret, $msg) = $article->Load( $ARGS{IncludeArticleId} );
+    my ($ret, $msg) = $article->Load( $aid );
 
     if (!$ret) {
         # Make sure we don't finalize the ticket if we won't be able to include the article
         $checks_failure = 1;
-        push @results, loc('Unable to load article "[_1]"', $ARGS{IncludeArticleId});
+        push @results, loc('Unable to load article "[_1]"', $aid);
     }
 }
 
@@ -597,4 +597,5 @@ $MemberOf => undef
 $QuoteTransaction => undef
 $CloneTicket => undef
 $AddGroupCc => undef
+ at IncludeArticleId => ()
 </%ARGS>
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 6446e46042..1272683e5b 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -339,14 +339,14 @@ my $TicketObj = LoadTicket($id);
 
 my @results;
 
-if ($ARGS{IncludeArticleId}) {
+for my $aid (@IncludeArticleId) {
     my $article = RT::Article->new($session{'CurrentUser'});
-    my ($ret, $msg) = $article->Load( $ARGS{IncludeArticleId} );
+    my ($ret, $msg) = $article->Load( $aid );
 
     if (!$ret) {
         # Make sure we don't finalize the update if we won't be able to include the article
         $checks_failure = 1;
-        push @results, loc('Unable to load article "[_1]"', $ARGS{IncludeArticleId});
+        push @results, loc('Unable to load article "[_1]"', $aid);
     }
 }
 
@@ -474,4 +474,5 @@ $TicketObj->CurrentUser->AddRecentlyViewedTicket($TicketObj);
 $id => undef
 $Action => ''
 $DefaultStatus => undef
+ at IncludeArticleId => ()
 </%ARGS>

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list