[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0-143-g561b93d165

? sunnavy sunnavy at bestpractical.com
Thu Dec 17 16:57:53 EST 2020


The branch, 5.0-trunk has been updated
       via  561b93d165e839fd98346b4249adcde8aead4430 (commit)
       via  e11105e072ac220ec3a0b3c974e6248090f21ca2 (commit)
       via  0e93cb58d08c2d20f59e66803c7b9edfa4117496 (commit)
       via  14857e4812bbaa50be53eeffafe0bb0d50222cd3 (commit)
       via  67e5fbc322894b535fa8abbbda61ff814b2d3af1 (commit)
      from  df26c551f8c1c0f890e8b1616495717ccdc56857 (commit)

Summary of changes:
 docs/UPGRADING-5.0                                 | 14 +++++++
 etc/RT_Config.pm.in                                | 11 +++++
 lib/RT/Config.pm                                   |  3 ++
 lib/RT/Interface/Web/MenuBuilder.pm                |  2 +-
 .../{ShowCustomFields => ShowArticleCustomFields}  | 47 ++++++----------------
 share/html/SelfService/Article/Display.html        | 45 ++++++++++++++++++---
 share/html/SelfService/Article/autohandler         | 16 +++++++-
 7 files changed, 94 insertions(+), 44 deletions(-)
 copy share/html/Elements/{ShowCustomFields => ShowArticleCustomFields} (73%)

- Log -----------------------------------------------------------------
commit 14857e4812bbaa50be53eeffafe0bb0d50222cd3
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Dec 10 13:26:00 2020 -0500

    Allow class-level rights to show self service articles
    
    Allow self service users to see article pages if they have
    access to see articles via ShowArticle at the class level.
    Previously self service users required global access.

diff --git a/share/html/SelfService/Article/autohandler b/share/html/SelfService/Article/autohandler
index 82be63dab4..01d15d57e7 100644
--- a/share/html/SelfService/Article/autohandler
+++ b/share/html/SelfService/Article/autohandler
@@ -46,9 +46,21 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
+my $classes = RT::Classes->new($session{'CurrentUser'});
+$classes->UnLimit;
 
-if ( $session{'CurrentUser'}->HasRight( Right => 'ShowArticle',
-                   Object => $RT::System )) {
+my $right = 'ShowArticle';
+my $can_see_articles;
+
+# Check global access, then check class-level rights
+if ( $session{'CurrentUser'}->HasRight( Right => $right, Object => $RT::System ) ) {
+    $can_see_articles = 1;
+}
+elsif ( grep { $_->CurrentUserHasRight($right) } @{ $classes->ItemsArrayRef } ) {
+    $can_see_articles = 1;
+}
+
+if ( $can_see_articles ) {
     $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS);    
 }
 else {

commit 0e93cb58d08c2d20f59e66803c7b9edfa4117496
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Dec 10 13:57:47 2020 -0500

    Display article content in a titlebox container
    
    Also set display page title to the article name rather than the
    generic "Article 1" title. This is more appropriate for end users
    viewing an FAQ entry.

diff --git a/share/html/SelfService/Article/Display.html b/share/html/SelfService/Article/Display.html
index 8355b9be08..b35a311cf5 100644
--- a/share/html/SelfService/Article/Display.html
+++ b/share/html/SelfService/Article/Display.html
@@ -45,11 +45,12 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /SelfService/Elements/Header, Title => loc('Display Article [_1]', $id) &>
-<div class="label col-3"><%$article->Name || loc("(no name)")%></div><br />
-<em><div class="value col-9"><%$article->Summary%></div></em>
+<& /SelfService/Elements/Header, Title => $article->Name &>
+<div id="article-display-container" class="mx-auto max-width-md">
+<&| /Widgets/TitleBox, title => $article->Summary, class => 'article-display-simple', content_class => 'mx-auto width-md' &>
 <& /Elements/ShowCustomFields, Object => $article &>
-
+</&>
+</div>
 <%init>
 
 my $article = RT::Article->new( $session{'CurrentUser'} );
@@ -63,7 +64,6 @@ unless ( $article->Id ) {
 unless ( $article->CurrentUserHasRight('ShowArticle') ) {
     $m->comp( "/Elements/Error", Why => loc("Permission Denied") );
 }
-my $title = loc( "Article #[_1]: [_2]", $article->Id, $article->Name || loc("(no name)"));
 
 $id = $article->id;
 

commit e11105e072ac220ec3a0b3c974e6248090f21ca2
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Fri Dec 11 09:30:09 2020 -0500

    Load class show/hide settings for article components
    
    Use the custom field settings to filter the content to display
    for the article.

diff --git a/share/html/Elements/ShowArticleCustomFields b/share/html/Elements/ShowArticleCustomFields
new file mode 100644
index 0000000000..4c286ec1ef
--- /dev/null
+++ b/share/html/Elements/ShowArticleCustomFields
@@ -0,0 +1,132 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2020 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (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 }}}
+% $m->callback( CallbackName => 'BeforeCustomFields', Object => $Object,
+%               ARGSRef => \%ARGS, CustomFields => $CustomFields);
+<div>
+% while ( my $CustomField = $CustomFields->Next ) {
+% my $Values = $Object->CustomFieldValues( $CustomField->Id );
+% my $count = $Values->Count;
+% next if $HideEmpty and not $count;
+% my $CustomFieldName = $CustomField->Name;
+%#The following substitution replaces all non-ID_Continue characters with a dash character. The ID_Continue Unicode property was chosen because it (combined with ID_Start) is meant for variable names. ID_Continue includes characters suitable for use in CSS-class names (even non-Latin ones, to support non-English custom field names) and excludes syntactic characters that are not (such as whitespace characters).
+% $CustomFieldName =~ s/\P{ID_Continue}+/-/g;
+% my @classes = (
+%   'custom-field',
+%   'custom-field-'.$CustomField->id,
+%   'custom-field-'.$CustomFieldName,
+%   'article-custom-field',
+% );
+% push @classes, 'unset-field' if not $count;
+% $m->callback( CallbackName => 'ModifyFieldClasses', CustomField => $CustomField,
+%               Object => $Object, Classes => \@classes );
+  <div class="form-row <% join(' ', @classes) %>" id="CF-<%$CustomField->id%>-ShowRow">
+% if ($HideFieldNames->{$CustomField->id}) {
+    <div class="value col-12 <% $count ? '' : ' no-value' %>">
+%} else {
+    <div class="label col-3"><% $CustomField->Name %>:</div>
+    <div class="value col-9 <% $count ? '' : ' no-value' %>">
+% }
+      <span class="current-value">
+% unless ( $count ) {
+<&|/l&>(no value)</&>
+% } elsif ( $count == 1 ) {
+%   $print_value->( $CustomField, $Values->First );
+% } else {
+<ul class="list-group list-group-compact">
+% while ( my $Value = $Values->Next ) {
+<li class="list-group-item">
+% $print_value->( $CustomField, $Value );
+</li>
+% }
+</ul>
+% }
+      </span>
+    </div>
+% $m->callback( CallbackName => 'AfterCustomFieldValue', CustomField => $CustomField,
+%               Object => $Object );
+  </div>
+% }
+</div>
+% $m->callback( CallbackName => 'AfterCustomFields', Object => $Object,
+%               ARGSRef => \%ARGS );
+<%INIT>
+$m->callback(
+    %ARGS,
+    CallbackName => 'MassageCustomFields',
+    Object       => $Object,
+    CustomFields => $CustomFields,
+);
+
+# don't print anything if there are no custom fields
+return unless $CustomFields->First;
+$CustomFields->GotoFirstItem;
+
+my $print_value = sub {
+    my ($cf, $value) = @_;
+
+    my $comp = "ShowCustomField". $cf->Type;
+    $m->callback(
+        CallbackName => 'ShowComponentName',
+        Name         => \$comp,
+        CustomField  => $cf,
+        Object       => $Object,
+    );
+    if ( $m->comp_exists( $comp ) ) {
+        $m->comp( $comp, Object => $value );
+    } else {
+        $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
+    }
+};
+
+</%INIT>
+<%ARGS>
+$Object => undef
+$CustomFields => $Object->CustomFields
+$HideEmpty => 0
+$HideFieldNames => {}
+</%ARGS>
diff --git a/share/html/SelfService/Article/Display.html b/share/html/SelfService/Article/Display.html
index b35a311cf5..94c293246a 100644
--- a/share/html/SelfService/Article/Display.html
+++ b/share/html/SelfService/Article/Display.html
@@ -47,8 +47,10 @@
 %# END BPS TAGGED BLOCK }}}
 <& /SelfService/Elements/Header, Title => $article->Name &>
 <div id="article-display-container" class="mx-auto max-width-md">
-<&| /Widgets/TitleBox, title => $article->Summary, class => 'article-display-simple', content_class => 'mx-auto width-md' &>
-<& /Elements/ShowCustomFields, Object => $article &>
+% my $title = "";
+% $title = $article->Summary if $include{Summary};
+<&| /Widgets/TitleBox, title => $title, class => 'article-display-simple', content_class => 'mx-auto width-md' &>
+<& /Elements/ShowArticleCustomFields, Object => $article, CustomFields => $custom_fields, HideFieldNames => \%hide_field_names &>
 </&>
 </div>
 <%init>
@@ -66,6 +68,37 @@ unless ( $article->CurrentUserHasRight('ShowArticle') ) {
 }
 
 $id = $article->id;
+my $class = $article->ClassObj;
+
+# Build up the hash of things to include/exclude, as well
+# as the array of custom field IDs to limit by
+my %include = (Name => 1, Summary => 1, EscapeHTML => 1);
+my @exclude_cf_ids;
+my %hide_field_names;
+
+my $cfs = $article->CustomFields;
+while ( my $cf = $cfs->Next ) {
+    $include{"CF-Title-" . $cf->Id} = 1;
+    $include{"CF-Value-" . $cf->Id} = 1;
+}
+
+# Load show/hide settings from class configuration
+foreach my $key ( keys %include ) {
+    $include{$key} = not $class->FirstAttribute("Skip-$key");
+    if ($key =~ /^CF-Value-(\d+)$/ && !$include{$key}) {
+        push(@exclude_cf_ids, $1);
+    }
+    if ($key =~ /^CF-Title-(\d+)$/ && !$include{$key}) {
+        $hide_field_names{$1} = 1;
+    }
+}
+
+my $custom_fields = $article->CustomFields;
+if ( scalar(@exclude_cf_ids) ) {
+    $custom_fields->Limit( FIELD    => 'id',
+                           OPERATOR => 'NOT IN',
+                           VALUE    => \@exclude_cf_ids );
+}
 
 </%init>
 <%args>

commit 561b93d165e839fd98346b4249adcde8aead4430
Merge: df26c551f8 e11105e072
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Dec 18 05:34:47 2020 +0800

    Merge branch '5.0/self-service-display-article' into 5.0-trunk

diff --cc etc/RT_Config.pm.in
index 2fc459c4dd,1f02a8488d..84f15053f2
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@@ -2969,9 -2969,22 +2969,20 @@@ If this is not set at all, then $Homepa
  
  Set(
      $SelfServicePageComponents,
 -    [
 -        qw(QuickCreate QueueList MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards SavedSearches FindUser MyAssets FindAsset FindGroup) # loc_qw
 -    ]
 +    [qw(SelfServiceTopArticles SelfServiceNewestArticles)]
  );
  
+ =item C<$SelfServiceShowArticleSearch>
+ 
+ If enabled, C<$SelfServiceShowArticleSearch> displays a "Search Articles"
+ box in the menu bar in the self service interface. This option controls
+ only showing or hiding the search box. Users still need appropriate rights
+ to see article search results and view articles.
+ 
+ =cut
+ 
+ Set($SelfServiceShowArticleSearch, 0);
+ 
  =back
  
  =head2 Articles

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


More information about the rt-commit mailing list