From 264736ed9ca007d07b079ff50193b9f5dcef58de Mon Sep 17 00:00:00 2001 From: hirami Date: Fri, 7 Jan 2022 18:07:21 +0900 Subject: [PATCH 1/5] FIX: Article title with no permission listed in CustomerFAQExplorer See https://github.com/RotherOSS/FAQ/issues/11 --- Kernel/Modules/CustomerFAQExplorer.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Kernel/Modules/CustomerFAQExplorer.pm b/Kernel/Modules/CustomerFAQExplorer.pm index fab6884..4579141 100644 --- a/Kernel/Modules/CustomerFAQExplorer.pm +++ b/Kernel/Modules/CustomerFAQExplorer.pm @@ -251,6 +251,24 @@ sub Run { $SortBy = 'Changed'; $OrderBy = 'Down'; $SearchLimit = 10; + + # Need GetSubCategories => 1, so cannot use $CategoryIDsRef + $FAQSearch{CategoryIDs} = $FAQObject->CustomerCategorySearch( + CustomerUser => $Self->{UserLogin}, + GetSubCategories => 1, + Mode => 'Customer', + UserID => $Self->{UserID}, + ); + } + + # search mode + else { + $FAQSearch{CategoryIDs} = $FAQObject->CustomerCategorySearch( + CustomerUser => $Self->{UserLogin}, + GetSubCategories => 1, + Mode => 'Customer', + UserID => $Self->{UserID}, + ); } # search all FAQ articles within the given category From b0427646b5a9fe6e91b172b78366240ed2928c34 Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 14 Mar 2022 16:00:34 +0100 Subject: [PATCH 2/5] Issue #11: remove a backup file, add a .gitignore file --- .gitignore | 8 + .../Standard/AgentFAQLanguage.tt.save | 214 ------------------ 2 files changed, 8 insertions(+), 214 deletions(-) create mode 100644 .gitignore delete mode 100644 Kernel/Output/HTML/Templates/Standard/AgentFAQLanguage.tt.save diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..28475a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Editor swap files +*.swn +*.swp +*.swo +*~ + +# TidyAll used for the hook .git/hooks/pre-commit +TidyAll diff --git a/Kernel/Output/HTML/Templates/Standard/AgentFAQLanguage.tt.save b/Kernel/Output/HTML/Templates/Standard/AgentFAQLanguage.tt.save deleted file mode 100644 index 8ad3267..0000000 --- a/Kernel/Output/HTML/Templates/Standard/AgentFAQLanguage.tt.save +++ /dev/null @@ -1,214 +0,0 @@ -# -- -# OTOBO is a web-based ticketing system for service organisations. -# -- -# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/ -# Copyright (C) 2019-2020 Rother OSS GmbH, https://otobo.de/ -# -- -# This program is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation, either version 3 of the License, or (at your option) any later version. -# This program 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, see . -# -- - -[% RenderBlockStart("Overview") %] -
-

[% Translate("FAQ Language Management") | html %]

- - [% BreadcrumbPath = [ - { - Name => Translate('FAQ Language Management'), - Link => Env("Action"), - }, - ] - %] - - [% SWITCH Data.Action %] - [% CASE 'Add' %] - [% BreadcrumbPath.push({ Name => Translate("Add FAQ Language"),}) %] - [% CASE 'Change' %] - [% USE EditTitle = String(Translate("Edit FAQ Language")) %] - [% BreadcrumbPath.push({ Name => EditTitle.append( ': ', Data.Name ) }) %] - [% END %] - - [% INCLUDE "Breadcrumb.tt" Path = BreadcrumbPath Type = "Agent" %] - -
- -[% RenderBlockStart("Disabled") %] -
-
-

[% Translate("Notice") | html %]

-
-
-
- - - -

[% Translate("This feature is disabled!") | html %]

-
-

- [% Translate("Use this feature if you want to work with multiple languages.") | html %] -

-
- -
-
-
-
-
-
-[% RenderBlockEnd("Disabled") %] - -[% RenderBlockStart("ActionList") %] -
- -
-

[% Translate("Actions") | html %]

-
-
- -
-
-[% RenderBlockEnd("ActionList") %] -
-[% RenderBlockStart("OverviewResult") %] -
-
-
-

[% Translate("List") | html %]

-
-
- - - - - - - - - -[% RenderBlockStart("NoDataFoundMsg") %] - - - -[% RenderBlockEnd("NoDataFoundMsg") %] -[% RenderBlockStart("OverviewResultRow") %] - - - - -[% RenderBlockEnd("OverviewResultRow") %] - -
[% Translate("Name") | html %][% Translate("Delete") | html %]
- [% Translate("No data found.") | html %] -
[% Data.Name | html %] - - - [% Translate("Delete") | html %]: [% Data.Name | html %] - -
-
-[% RenderBlockEnd("OverviewResult") %] - -[% RenderBlockStart("OverviewUpdate") %] -
-
-
-[% RenderBlockStart("HeaderAdd") %] -

[% Translate("Add Language") | html %]

-[% RenderBlockEnd("HeaderAdd") %] -[% RenderBlockStart("HeaderEdit") %] -

[% Translate("Edit Language") | html %]

-[% RenderBlockEnd("HeaderEdit") %] -
-
-
- - - -
- -
- -
-

[% Translate("This field is required.") | html %]

-
-
-

[% Translate(Data.NameServerErrorMessage) | html %]

-
-
- -
- - [% Translate("or") | html %] - [% Translate("Cancel") | html %] -
-
-
-
-
-
-
-[% RenderBlockEnd("OverviewUpdate") %] -
-
-
-
-[% RenderBlockEnd("Overview") %] - -[% RenderBlockStart("Delete") %] -[% RenderBlockStart("NoAffectedItems") %] -
- -

- [% Data.Name | html %] -

-
-
-

- [% Translate("Do you really want to delete this language?") | html %] -

-[% RenderBlockEnd("NoAffectedItems") %] - -[% RenderBlockStart("AffectedItems") %] -

- [% Translate("You can not delete this language. It is used in at least one FAQ article!") | html %] -

-

- [% Translate("This language is used in the following FAQ Article(s)") | html %]: -

- - - -[% RenderBlockEnd("AffectedItems") %] -[% RenderBlockEnd("Delete") %] From 1d94af5787a5213be36e92833e3ea9e5a9b6f733 Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 14 Mar 2022 16:40:54 +0100 Subject: [PATCH 3/5] Issue #11: tidying --- Kernel/Modules/CustomerFAQExplorer.pm | 57 +++++++++++++++------------ 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/Kernel/Modules/CustomerFAQExplorer.pm b/Kernel/Modules/CustomerFAQExplorer.pm index 4579141..100a764 100644 --- a/Kernel/Modules/CustomerFAQExplorer.pm +++ b/Kernel/Modules/CustomerFAQExplorer.pm @@ -2,7 +2,7 @@ # OTOBO is a web-based ticketing system for service organisations. # -- # Copyright (C) 2001-2019 OTRS AG, https://otrs.com/ -# Copyright (C) 2019-2020 Rother OSS GmbH, https://otobo.de/ +# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/ # -- # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -16,8 +16,15 @@ package Kernel::Modules::CustomerFAQExplorer; +use v5.24; use strict; use warnings; + +# core modules + +# CPAN modules + +# OTOBO modules use Kernel::Language qw(Translatable); our $ObjectManagerDisabled = 1; @@ -26,10 +33,7 @@ sub new { my ( $Type, %Param ) = @_; # allocate new hash for object - my $Self = {%Param}; - bless( $Self, $Type ); - - return $Self; + return bless {%Param}, $Type; } sub Run { @@ -44,7 +48,7 @@ sub Run { # get config data my $StartHit = int( $ParamObject->GetParam( Param => 'StartHit' ) || 1 ); - my $SearchLimit = $Config->{SearchLimit} || 200; + my $SearchLimit = $Config->{SearchLimit} || 200; my $SearchPageShown = $Config->{SearchPageShown} || 3; my $SortBy = $ParamObject->GetParam( Param => 'SortBy' ) || $Config->{'SortBy::Default'} @@ -121,7 +125,7 @@ sub Run { ); # AddJSData for ES - my $ESActive = $ConfigObject->Get( 'Elasticsearch::Active' ); + my $ESActive = $ConfigObject->Get('Elasticsearch::Active'); $LayoutObject->AddJSData( Key => 'ESActive', @@ -136,14 +140,14 @@ sub Run { # show search results if ( $Self->{Subaction} && $Self->{Subaction} eq 'Search' ) { - my $SearchName = Translatable("Search").":"; - for my $Mode ( qw/Keyword What/ ) { + my $SearchName = Translatable("Search") . ":"; + for my $Mode (qw/Keyword What/) { my $String = $ParamObject->GetParam( Param => $Mode ); - if ( $String ) { - $Search{ $Mode } = $String; - $FAQSearch{ $Mode } = "*$String*"; + if ($String) { + $Search{$Mode} = $String; + $FAQSearch{$Mode} = "*$String*"; my $ModeName = $Mode eq 'What' ? 'Fulltext' : $Mode; - $SearchName .= " ".Translatable($ModeName)." \"$String\";"; + $SearchName .= " " . Translatable($ModeName) . " \"$String\";"; } } @@ -155,11 +159,12 @@ sub Run { CategoryID => 0, }, ); + # output search information $LayoutObject->Block( Name => 'FAQPathCategoryElementNoLink', Data => { - Name => $SearchName, + Name => $SearchName, }, ); @@ -168,7 +173,7 @@ sub Run { } # no search ( standard mode ) - else { + else { # show FAQ path $LayoutObject->FAQPathShow( FAQObject => $FAQObject, @@ -241,7 +246,7 @@ sub Run { UserID => $Self->{UserID}, ); - # include Category if not in base Category (0), or search mode + # use given category, or limit to the categories that are available for the customer if ( $CategoryID > 0 ) { $FAQSearch{CategoryIDs} = [$CategoryID], } @@ -254,10 +259,10 @@ sub Run { # Need GetSubCategories => 1, so cannot use $CategoryIDsRef $FAQSearch{CategoryIDs} = $FAQObject->CustomerCategorySearch( - CustomerUser => $Self->{UserLogin}, + CustomerUser => $Self->{UserLogin}, GetSubCategories => 1, - Mode => 'Customer', - UserID => $Self->{UserID}, + Mode => 'Customer', + UserID => $Self->{UserID}, ); } @@ -384,14 +389,14 @@ sub Run { $Link .= 'Order=' . $LayoutObject->LinkEncode($OrderBy) . ';'; my $ActionString; - if ( %Search ) { + if (%Search) { $ActionString = "Action=CustomerFAQExplorer;Subaction=Search;"; - if ( $FAQSearch{CategoryIDs} ) { - $ActionString .= "CategoryID=$CategoryID;"; - } - for my $Mode ( keys %Search ) { - $ActionString .= "$Mode=$Search{ $Mode };"; - } + if ( $FAQSearch{CategoryIDs} ) { + $ActionString .= "CategoryID=$CategoryID;"; + } + for my $Mode ( keys %Search ) { + $ActionString .= "$Mode=$Search{ $Mode };"; + } } else { $ActionString = "Action=CustomerFAQExplorer;CategoryID=$CategoryID"; From 72182c78018612453f8f430336897d09c2dad66b Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 14 Mar 2022 16:41:26 +0100 Subject: [PATCH 4/5] Issue #11: do not use ',' for terminating a statement --- Kernel/Modules/CustomerFAQExplorer.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Modules/CustomerFAQExplorer.pm b/Kernel/Modules/CustomerFAQExplorer.pm index 100a764..65e85b9 100644 --- a/Kernel/Modules/CustomerFAQExplorer.pm +++ b/Kernel/Modules/CustomerFAQExplorer.pm @@ -248,7 +248,7 @@ sub Run { # use given category, or limit to the categories that are available for the customer if ( $CategoryID > 0 ) { - $FAQSearch{CategoryIDs} = [$CategoryID], + $FAQSearch{CategoryIDs} = [$CategoryID]; } # get the latest articles for the root category (else empty) From 6f620867b989f7105c36ec6154804b0f93cbdb0b Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 14 Mar 2022 16:42:31 +0100 Subject: [PATCH 5/5] Issue #11: consolidate the calls to CustomerCategorySearch() --- Kernel/Modules/CustomerFAQExplorer.pm | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Kernel/Modules/CustomerFAQExplorer.pm b/Kernel/Modules/CustomerFAQExplorer.pm index 65e85b9..d84c1c8 100644 --- a/Kernel/Modules/CustomerFAQExplorer.pm +++ b/Kernel/Modules/CustomerFAQExplorer.pm @@ -250,13 +250,7 @@ sub Run { if ( $CategoryID > 0 ) { $FAQSearch{CategoryIDs} = [$CategoryID]; } - - # get the latest articles for the root category (else empty) - elsif ( !%Search ) { - $SortBy = 'Changed'; - $OrderBy = 'Down'; - $SearchLimit = 10; - + else { # Need GetSubCategories => 1, so cannot use $CategoryIDsRef $FAQSearch{CategoryIDs} = $FAQObject->CustomerCategorySearch( CustomerUser => $Self->{UserLogin}, @@ -266,14 +260,11 @@ sub Run { ); } - # search mode - else { - $FAQSearch{CategoryIDs} = $FAQObject->CustomerCategorySearch( - CustomerUser => $Self->{UserLogin}, - GetSubCategories => 1, - Mode => 'Customer', - UserID => $Self->{UserID}, - ); + # get the latest articles for the root category (else empty) + if ( $CategoryID <= 0 && !%Search ) { + $SortBy = 'Changed'; + $OrderBy = 'Down'; + $SearchLimit = 10; } # search all FAQ articles within the given category