[Rt-commit] rt branch, 5.0/self-service-display-article, created. rt-5.0.0-137-g2d3d55a665

Jim Brandt jbrandt at bestpractical.com
Thu Dec 10 16:41:43 EST 2020


The branch, 5.0/self-service-display-article has been created
        at  2d3d55a665440e366305c7b6e471c49567d64fbf (commit)

- Log -----------------------------------------------------------------
commit 67e5fbc322894b535fa8abbbda61ff814b2d3af1
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Dec 10 11:49:17 2020 -0500

    Add SelfServiceShowArticleSearch configuration option
    
    This replaces a previous rights check for global ShowArticle
    permission to show the article search. The new configuration
    option is also global, so it has the same scope with less
    overhead than a rights check.
    
    It also makes it possible to show the search box in different
    rights configurations, like when granting article access rights
    at the class level.

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index da90d1912e..f2e84f2c3a 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -218,4 +218,18 @@ will migrate your existing tokens to the new core RT tables.
 
 =back
 
+=head1 UPGRADING FROM 5.0.0 AND EARLIER
+
+=over 4
+
+=item *
+
+In the self service interface, the "Search Articles" box in the menu bar previously
+was displayed to users who had the global right "ShowArticle". This is now
+controlled by a new configuration option C<$SelfServiceShowArticleSearch>. This new
+option defaults to off, so if you currently allow self service users to use article search,
+enable this option to keep the article search box available.
+
+=back
+
 =cut
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 2539240f4d..1f02a8488d 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2974,6 +2974,17 @@ Set(
     ]
 );
 
+=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
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 59ce078f1c..64ef153f30 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1688,6 +1688,9 @@ our %META;
     SelfServiceShowGroupTickets => {
         Widget => '/Widgets/Form/Boolean',
     },
+    SelfServiceShowArticleSearch => {
+        Widget => '/Widgets/Form/Boolean',
+    },
     ShowSearchResultCount => {
         Widget => '/Widgets/Form/Boolean',
     },
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 1d63dc177d..b83c8da250 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -1659,7 +1659,7 @@ sub BuildSelfServiceNav {
         $about_me->child( logout => title => loc('Logout'), path => $logout_url );
     }
 
-    if ($current_user->HasRight( Right => 'ShowArticle', Object => RT->System )) {
+    if ( RT->Config->Get('SelfServiceShowArticleSearch') ) {
         $widgets->child( 'goto-article' => raw_html => $HTML::Mason::Commands::m->scomp('/SelfService/Elements/SearchArticle') );
     }
 

commit 1d382799b679fcab419131f50fa8ac7f9223ddd1
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..b201bcd414 100644
--- a/share/html/SelfService/Article/autohandler
+++ b/share/html/SelfService/Article/autohandler
@@ -46,9 +46,22 @@
 %#
 %# 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 2d3d55a665440e366305c7b6e471c49567d64fbf
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;
 

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


More information about the rt-commit mailing list