FAQ Top 10 to Agent Dashboard

Moderator: crythias

Post Reply
Misfitz
Znuny newbie
Posts: 43
Joined: 22 Feb 2012, 16:21
Znuny Version: 3_3_3
Real Name: Patrick Veit
Company: Ametras mobility

FAQ Top 10 to Agent Dashboard

Post by Misfitz »

Hi,

i want to add the FAQTopTen Checkbox at the Agent Dashboard at the right side under Settings.

The Agent Dashboard should look like this:
Settings_FAQ.png
How can i do this?

I have added a new Dashlet "FAQTopTen.pm" in the folder C:\Programme (x86)\OTRS\OTRS\Kernel\Output\HTML\ and the FAQTopTen.xml into the folder C:\Programme (x86)\OTRS\Kernel\Config\Files here are the codes:

Code: Select all


# --
# Kernel/Output/HTML/FAQMenuGeneric.pm
# Copyright (C) 2001-2010 xxx, http://otrs.org/
# --
# $Id: FAQMenuGeneric.pm,v 1.3 2010/11/24 21:55:09 cr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::FAQTopTen;

use strict;
use warnings;

use vars qw($VERSION);
$VERSION = qw($Revision: 1.3 $) [1];


=item FAQShowTop10()

Shows an info box wih the Top 10 FAQ articles.
Depending on the uses interface (agent, customer, public) only the appropriate
articles are shown here.

    $LayoutObject->FAQShowTop10(
        FAQObject       => $FAQObject,                 # needed for core module interaction
        Mode            => 'Public',                   # (Agent, Customer, Public)
        CategoryID      => 5,
        Interface       => $Self->{Interface},
        InterfaceStates => $Self->{InterfaceStates},
        UserID          => 1,
        Nav             => 'none',                     # optional
    );

=cut

sub FAQShowTop10 {
    my ( $Self, %Param ) = @_;

    # check parameters
    for my $ParamName (qw(FAQObject Mode Interface InterfaceStates UserID)) {
        if ( !$Param{$ParamName} ) {
            $Self->{LogObject}->Log(
                Priority => 'error',
                Message  => "Need $ParamName!",
            );
            return;
        }
    }

    # check needed stuff
    if ( !defined $Param{CategoryID} ) {
        $Self->{LogObject}->Log(
            Priority => 'error',
            Message  => "Need CategoryID!",
        );
        return;
    }

    # check mode
    if ( $Param{Mode} !~ m{ Agent | Customer | Public }xms ) {
        $Self->{LogObject}->Log(
            Priority => 'error',
            Message  => 'Mode must be either Agent, Customer or Public!',
        );
        return;
    }

    # check CustomerUser
    if ( $Param{Mode} eq 'Customer' && !$Param{CustomerUser} ) {
        $Self->{LogObject}->Log(
            Priority => 'error',
            Message  => 'Need CustomerUser!',
        );
        return;
    }

    # store FAQ object locally
    $Self->{FAQObject} = $Param{FAQObject};

    my $Result = -1;

    # show last added/updated articles
    my $Show = $Self->{ConfigObject}->Get('FAQ::Explorer::Top10::Show');
    if ( $Show->{ $Param{Interface}->{Name} } ) {

        # to store search param for categories
        my %CategorySearchParam;

        # if subcategories should also be shown
        if ( $Self->{ConfigObject}->Get('FAQ::Explorer::Top10::ShowSubCategoryItems') ) {

            # find the subcategories of this category
            my $SubCategoryIDsRef = $Self->{FAQObject}->CategorySubCategoryIDList(
                ParentID     => $Param{CategoryID},
                Mode         => $Param{Mode},
                ItemStates   => $Param{InterfaceStates},
                CustomerUser => $Param{CustomerUser} || '',
                UserID       => $Param{UserID},
            );

            # search in the given category and add the subcategory
            $CategorySearchParam{CategoryIDs} = [ $Param{CategoryID}, @{$SubCategoryIDsRef} ];
        }

        # get the top 10 articles for categories with at least ro permissions
        my $Top10ItemIDsRef = $Self->{FAQObject}->FAQTop10Get(
            Interface => $Param{Interface}->{Name},
            Limit     => $Self->{ConfigObject}->Get('FAQ::Explorer::Top10::Limit') || 10,
            UserID    => $Param{UserID},
            %CategorySearchParam,
        );

        # there is something to show
        if ( @{$Top10ItemIDsRef} ) {

            $Result = 1;

            # show the info box
            $Self->Block(
                Name => 'InfoBoxFAQMiniList',
                Data => {
                    Header => 'Top 10 FAQ articles',
                },
            );

            # show the RSS Feed icon
            if ( $Param{Mode} eq 'Public' ) {

                $Self->Block(
                    Name => 'InfoBoxFAQMiniListNewsRSS',
                    Data => {
                        Type  => 'Top10',
                        Title => 'FAQ Articles (Top 10)',
                    },
                );
            }

            my $Number;
            for my $Top10Item ( @{$Top10ItemIDsRef} ) {

                # increase the number
                $Number++;

                # get FAQ data
                my %FAQData = $Self->{FAQObject}->FAQGet(
                    ItemID => $Top10Item->{ItemID},
                    UserID => $Param{UserID},
                );

                # show the article row
                $Self->Block(
                    Name => 'InfoBoxFAQMiniListItemRow',
                    Data => {
                        Nav => $Param{Nav},
                        %FAQData,
                    },
                );

                # show the Top10 position number
                $Self->Block(
                    Name => 'InfoBoxFAQMiniListItemRowPositionNumber',
                    Data => {
                        Number => $Number,
                    },
                );
            }
        }
    }

    return $Result;
}

Code: Select all

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <otrs_config version="1.0" init="Application">
        <ConfigItem Name="DashboardBackend###0150-FAQTopTen" Required="0" Valid="1">
            <Description Lang="en">Parameters for the dashboard FAQTopTen. "Group" are used to restriced access to the plugin (e. g. Group: admin;group1;group2;). "Default" means if the plugin is enabled per default, "ResponseID" defines the StdResponse displayed in dashboard.</Description>
            <Description Lang="de">Parameter für das Dashboard Repair. "Group" ist verwendet um den Zugriff auf das Plugin einzuschränken (z. B. Group: admin;group1;group2;). "Default" gibt an ob das Plugin per default aktiviert ist,"ResponseID" definiert die StdResponse, die im Dashboard angezeigt wird.</Description>
            <Group>FAQ</Group>
            <SubGroup>Frontend::Agent::Dashboard</SubGroup>
            <Setting>
                <Hash>
                    <Item Key="Module">Kernel::Output::HTML::FAQTopTen</Item>
                    <Item Key="Title">FAQ Top Ten</Item>
                    <Item Key="Description">Top 10 der FAQ</Item>
                    # <Item Key="Attributes">StateType=repair;</Item>
                    <Item Key="Filter">All</Item>
                    # <Item Key="Time">Age</Item>
                    <Item Key="Limit">10</Item>
                    <Item Key="Permission">rw</Item>
                    <Item Key="Block">ContentLarge</Item>
                    <Item Key="Group"></Item>
                    <Item Key="Default">1</Item>
                    <Item Key="CacheTTLLocal">0.5</Item>
                </Hash>
            </Setting>
        </ConfigItem>   
    </otrs_config>
After Rebuild the config, i get the errormessage

Software error:

Can't locate object method "new" via package "Kernel::Output::HTML::FAQTopTen" at C:/PROGRA~2/OTRS/OTRS//Kernel/Modules/AgentDashboard.pm line 412.


What is wrong?
You do not have the required permissions to view the files attached to this post.
Misfitz
Znuny newbie
Posts: 43
Joined: 22 Feb 2012, 16:21
Znuny Version: 3_3_3
Real Name: Patrick Veit
Company: Ametras mobility

Re: FAQ Top 10 to Agent Dashboard

Post by Misfitz »

Nobody can help me??
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: FAQ Top 10 to Agent Dashboard

Post by crythias »

Misfitz wrote:Can't locate object method "new" via package "Kernel::Output::HTML::FAQTopTen"
It means what it says. You will need to have a "sub new" method to validate that the pieces are in place for the usage when it runs.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Misfitz
Znuny newbie
Posts: 43
Joined: 22 Feb 2012, 16:21
Znuny Version: 3_3_3
Real Name: Patrick Veit
Company: Ametras mobility

Re: FAQ Top 10 to Agent Dashboard

Post by Misfitz »

Hi crythias,

thanks for your answer, but how can i get a "sub new" methode?

I'm not really a programmer ;-)
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: FAQ Top 10 to Agent Dashboard

Post by crythias »

You create one. Copy it from something similar.

The basic idea of "new" is that you validate the pieces of the request before you make the object that runs on those pieces.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Misfitz
Znuny newbie
Posts: 43
Joined: 22 Feb 2012, 16:21
Znuny Version: 3_3_3
Real Name: Patrick Veit
Company: Ametras mobility

Re: FAQ Top 10 to Agent Dashboard

Post by Misfitz »

but this is allready there, i copied "FAQMenuGeneric.pm" and created "FAQTopTen.pm":

C:\Programme (x86)\OTRS\OTRS\Kernel\Output\HTML\FAQTopTen.pm
Unbenannt.JPG

Code: Select all

# --
# Kernel/Output/HTML/FAQTopTen.pm
# Copyright (C) 2001-2010 xxx, http://otrs.org/
# --
# $Id: FAQMenuGeneric.pm,v 1.3 2010/11/24 21:55:09 cr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::FAQTopTen;

use strict;
use warnings;

use vars qw($VERSION);
$VERSION = qw($Revision: 1.3 $) [1];


=item FAQShowTop10()

Shows an info box wih the Top 10 FAQ articles.
Depending on the uses interface (agent, customer, public) only the appropriate
articles are shown here.

    $LayoutObject->FAQShowTop10(
        FAQObject       => $FAQObject,                 # needed for core module interaction
        Mode            => 'Public',                   # (Agent, Customer, Public)
        CategoryID      => 5,
        Interface       => $Self->{Interface},
        InterfaceStates => $Self->{InterfaceStates},
        UserID          => 1,
        Nav             => 'none',                     # optional
    );

=cut
also the .xml doesn't appears in the sysconfig menu:

DashboardBackend###0150-FAQTopTen

Code: Select all

        <?xml version="1.0" encoding="iso-8859-1" ?>
        <otrs_config version="1.0" init="Application">
            <ConfigItem Name="DashboardBackend###0150-FAQTopTen" Required="0" Valid="1">
                <Description Lang="en">Parameters for the dashboard FAQTopTen. "Group" are used to restriced access to the plugin (e. g. Group: admin;group1;group2;). "Default" means if the plugin is enabled per default, "ResponseID" defines the StdResponse displayed in dashboard.</Description>
                <Description Lang="de">Parameter für das Dashboard Repair. "Group" ist verwendet um den Zugriff auf das Plugin einzuschränken (z. B. Group: admin;group1;group2;). "Default" gibt an ob das Plugin per default aktiviert ist,"ResponseID" definiert die StdResponse, die im Dashboard angezeigt wird.</Description>
                <Group>FAQ</Group>
                <SubGroup>Frontend::Agent::Dashboard</SubGroup>
                <Setting>
                    <Hash>
                        <Item Key="Module">Kernel::Output::HTML::FAQTopTen</Item>
                        <Item Key="Title">FAQ Top Ten</Item>
                        <Item Key="Description">Top 10 der FAQ</Item>
                        # <Item Key="Attributes">StateType=repair;</Item>
                        <Item Key="Filter">All</Item>
                        # <Item Key="Time">Age</Item>
                        <Item Key="Limit">10</Item>
                        <Item Key="Permission">rw</Item>
                        <Item Key="Block">ContentLarge</Item>
                        <Item Key="Group"></Item>
                        <Item Key="Default">1</Item>
                        <Item Key="CacheTTLLocal">0.5</Item>
                    </Hash>
                </Setting>
            </ConfigItem>   
        </otrs_config>
You do not have the required permissions to view the files attached to this post.
Post Reply