Kernel::System::FAQ

NAME

Kernel::System::FAQ – FAQ lib

DESCRIPTION

All FAQ functions. E. g. to add FAQs or to get FAQs.

PUBLIC INTERFACE

new()

create an object. Do not use it directly, instead use:

    use Kernel::System::ObjectManager;
    local $Kernel::OM = Kernel::System::ObjectManager->new();
    my $FAQObject = $Kernel::OM->Get('Kernel::System::FAQ');

FAQGet()

get an FAQ item

    my %FAQ = $FAQObject->FAQGet(
        ItemID        => 123,
        ItemFields    => 0,        # Optional, default 0. To include the item field content for this
                                   #   FAQ item on the return structure.
        DynamicFields => 0,        # Optional, default 0. To include the faq dynamic fields.
        UserID        => 1,
    );

Returns:

    %FAQ = (
        ID                => 32,
        ItemID            => 32,
        FAQID             => 32,
        Number            => 100032,
        CategoryID        => '2',
        CategoryName'     => 'CategoryA::CategoryB',
        CategoryShortName => 'CategoryB',
        LanguageID        => 1,
        Language          => 'en',
        Title             => 'Article Title',
        Approved          => 1,                              # or 0
        ValidID           => 1,
        Valid             => 'valid',
        Keywords          => 'KeyWord1 KeyWord2',
        Helpful           => 20,                             # number of votes who thought this article was helpful
        NotHelpful        => 5,                              # number of votes who thought this article was not helpful
        StateID           => 1,
        State             => 'internal (agent)',             # or 'external (customer)' or
                                                             # 'public (all)'
        StateTypeID       => 1,
        StateTypeName     => 'internal',                     # or 'external' or 'public'
        CreatedBy         => 1,
        Changed'          => '2011-01-05 21:53:50',
        ChangedBy         => '1',
        Created           => '2011-01-05 21:53:50',
        Name              => '1294286030-31.1697297104732',  # FAQ Article name or
                                                             # systemtime + '-' + random number
    );

    my %FAQ = $FAQObject->FAQGet(
        ItemID     => 123,
        ItemFields => 1,
        UserID     => 1,
    );

Returns:

    %FAQ = (

        # Compatibility ID names.
        ID                => 32,
        FAQID             => 32,

        ItemID            => 32,
        Number            => 100032,
        CategoryID        => '2',
        CategoryName      => 'CategoryA::CategoryB',
        CategoryShortName => 'CategoryB',
        LanguageID        => 1,
        Language          => 'en',
        Title             => 'Article Title',
        Field1            => 'The Symptoms',
        Field2            => 'The Problem',
        Field3            => 'The Solution',
        Field4            => undef,                          # Not active by default
        Field5            => undef,                          # Not active by default
        Field6            => 'Comments',
        Approved          => 1,                              # or 0
        ValidID           => 1,
        ContentType       => 'text/plain',                  # or 'text/html'
        Valid             => 'valid',
        Keywords          => 'KeyWord1 KeyWord2',
        Helpful           => 20,                             # number of votes who thought this article was helpful
        NotHelpful        => 5,                              # number of votes who thought this article was not helpful
        StateID           => 1,
        State             => 'internal (agent)',             # or 'external (customer)' or
                                                             # 'public (all)'
        StateTypeID       => 1,
        StateTypeName     => 'internal',                     # or 'external' or 'public'
        CreatedBy         => 1,
        Changed           => '2011-01-05 21:53:50',
        ChangedBy         => '1',
        Created           => '2011-01-05 21:53:50',
        Name              => '1294286030-31.1697297104732',  # FAQ Article name or
                                                             # systemtime + '-' + random number
    );

FAQAdd()

add an article

    my $ItemID = $FAQObject->FAQAdd(
        Title       => 'Some Text',
        CategoryID  => 1,
        StateID     => 1,
        LanguageID  => 1,
        Number      => '13402',          # (optional)
        Keywords    => 'some keywords',  # (optional)
        Field1      => 'Symptom...',     # (optional)
        Field2      => 'Problem...',     # (optional)
        Field3      => 'Solution...',    # (optional)
        Field4      => 'Field4...',      # (optional)
        Field5      => 'Field5...',      # (optional)
        Field6      => 'Comment...',     # (optional)
        Approved    => 1,                # (optional)
        ValidID     => 1,
        ContentType => 'text/plain',     # or 'text/html'
        UserID      => 1,
    );

Returns:

    $ItemID = 34;

Events:

    FAQCreate

FAQUpdate()

update an article

   my $Success = $FAQObject->FAQUpdate(
        ItemID      => 123,
        CategoryID  => 1,
        StateID     => 1,
        LanguageID  => 1,
        Approved    => 1,
        ValidID     => 1,
        ContentType => 'text/plan',     # or 'text/html'
        Title       => 'Some Text',
        Field1      => 'Problem...',
        Field2      => 'Solution...',
        UserID      => 1,
        ApprovalOff => 1,               # optional, (if set to 1 approval is ignored. This is
                                        #   important when called from FAQInlineAttachmentURLUpdate)
    );

Returns:

    $Success = 1 ;          # or undef if can't update the FAQ article

Events:

    FAQUpdate

AttachmentAdd()

add article attachments, returns the attachment id

    my $AttachmentID = $FAQObject->AttachmentAdd(
        ItemID      => 123,
        Content     => $Content,
        ContentType => 'text/xml',
        Filename    => 'somename.xml',
        Inline      => 1,   (0|1, default 0)
        UserID      => 1,
    );

Returns:

    $AttachmentID = 123 ;               # or undef if can't add the attachment

AttachmentGet()

get attachment of article

    my %File = $FAQObject->AttachmentGet(
        ItemID => 123,
        FileID => 1,
        UserID => 1,
    );

Returns:

    %File = (
        Filesize    => '540286',                # file size in bytes
        ContentType => 'image/jpeg',
        Filename    => 'Error.jpg',
        Content     => '...'                    # file binary content
    );

AttachmentDelete()

delete attachment of article

    my $Success = $FAQObject->AttachmentDelete(
        ItemID => 123,
        FileID => 1,
        UserID => 1,
    );

Returns:

    $Success = 1 ;              # or undef if attachment could not be deleted

AttachmentIndex()

return an attachment index of an article

    my @Index = $FAQObject->AttachmentIndex(
        ItemID     => 123,
        ShowInline => 0,   ( 0|1, default 1)
        UserID     => 1,
    );

Returns:

    @Index = (
        {
            Filesize    => '527.6 KBytes',
            ContentType => 'image/jpeg',
            Filename    => 'Error.jpg',
            FilesizeRaw => 540286,
            FileID      => 6,
            Inline      => 0,
            CreateTime  => '1977-12-12 12:00:00',
            CreateBy    => 123,
            ChangeTime  => '1977-12-12 12:00:00',
            ChangeBy    => 123,
        },
        {,
            Filesize => '430.0 KBytes',
            ContentType => 'image/jpeg',
            Filename => 'Solution.jpg',
            FilesizeRaw => 440286,
            FileID => 5,
            Inline => 1,
            CreateTime  => '1977-12-12 12:00:00',
            CreateBy    => 123,
            ChangeTime  => '1977-12-12 12:00:00',
            ChangeBy    => 123,
        },
        {
            Filesize => '296 Bytes',
            ContentType => 'text/plain',
            Filename => 'AdditionalComments.txt',
            FilesizeRaw => 296,
            FileID => 7,
            Inline => 0,
            CreateTime  => '1977-12-12 12:00:00',
            CreateBy    => 123,
            ChangeTime  => '1977-12-12 12:00:00',
            ChangeBy    => 123,
        },
    );

FAQCount()

Count the number of articles for a defined category. Only valid FAQ articles will be counted.

    my $ArticleCount = $FAQObject->FAQCount(
        CategoryIDs => [1,2,3,4],
        ItemStates =>  {
            1 => 'internal',
            2 => 'external',
            3 => 'public',
        },
        OnlyApproved => 1,   # optional (default 0)
        Valid        => 1,   # optional (default 0)
        UserID       => 1,
    );

Returns:

    $ArticleCount = 3;

FAQDelete()

Delete an article.

    my $DeleteSuccess = $FAQObject->FAQDelete(
        ItemID => 1,
        UserID => 123,
    );

Returns:

    $DeleteSuccess = 1;              # or undef if article could not be deleted

Events:

    FAQDelete

FAQHistoryAdd()

add an history to an article

    my $AddSuccess = $FAQObject->FAQHistoryAdd(
        ItemID => 1,
        Name   => 'Updated Article.',
        UserID => 1,
    );

Returns:

    $AddSuccess = 1;               # or undef if article history could not be added

FAQHistoryGet()

get an array with hash reference with the history of an article

    my $HistoryDataArrayRef = $FAQObject->FAQHistoryGet(
        ItemID => 1,
        UserID => 1,
    );

Returns:

    $HistoryDataArrayRef = [
        {
            CreatedBy => 1,
            Created   => '2010-11-02 07:45:15',
            Name      => 'Created',
        },
        {
            CreatedBy => 1,
            Created   => '2011-06-14 12:53:55',
            Name      => 'Updated',
        },
    ];

FAQHistoryDelete()

delete the history of an article

    my $DeleteSuccess = $FAQObject->FAQHistoryDelete(
        ItemID => 1,
        UserID => 1,
    );

Returns:

    $DeleteDuccess = 1;                # or undef if history could not be deleted

FAQJournalGet()

get the system journal

    my $HistoryDataArrayRef = $FAQObject->FAQJournalGet(
        UserID => 1,
    );

Returns:

    $JournalDataArrayRef = [
        {
            ItemID    => '32',
            Number    => '10004',
            Category  => 'My Category',
            Subject   => 'New Article',
            Action    => 'Created',
            CreatedBy => '1',
            Created   => '2011-01-05 21:53:50',
        },
        {
            ItemID    => '4',
            Number    => '10004',
            Category  => 'My Category',
            Subject   => "New Article",
            Action    => 'Updated',
            CreatedBy => '1',
            Created   => '2011-01-05 21:55:32',
        }
    ];

KeywordList()

get a list of keywords as a hash, with their count as the value:

    my %Keywords = $FAQObject->KeywordList(
        Valid  => 1,
        UserID => 1,
    );

Returns:

    %Keywords = (
          'macosx'   => 8,
          'ubuntu'   => 1,
          'outlook'  => 2,
          'windows'  => 3,
          'exchange' => 1,
    );

FAQKeywordArticleList()

Get a keyword and related faq articles lookup list (optional only for the given languages). You can build a list for a agent or customer. If you give only a UserID the result is for the given UserID, with a additional CustomerUser the list is only for the given CustomerUser.

    my %FAQKeywordArticleList = $FAQObject->FAQKeywordArticleList(
        UserID       => 1,
        CustomerUser => 'tt',           # optional (with this the result is only customer faq article)
        Languages    => [ 'en', 'de' ], # optional
    );

Returns

    my %FAQKeywordArticleList = (
        'ExampleKeyword' => [
            12,
            13,
        ],
        'TestKeyword' => [
            876,
        ],
    );

FAQPathListGet()

returns a category array reference

    my $CategoryIDArrayRef = $FAQObject->FAQPathListGet(
        CategoryID => 150,
        UserID     => 1,
    );

Returns:

    $CategoryIDArrayRef = [
        {
            CategoryID => '2',
            ParentID => '0',
            Name => 'My Category',
            Comment => 'My First Category',
            ValidID => '1',
        },
        {
            CategoryID => '4',
            ParentID => '2',
            Name => 'Sub Category A',
            Comment => 'This Is Category A',
            ValidID => '1',
        },
    ];

FAQLogAdd()

adds accessed FAQ article to the access log table

    my $Success = $FAQObject->FAQLogAdd(
        ItemID        => '123456',
        Interface     => 'internal',
        RemoteAddress => '192.168.0.1',         # optional
        UserAgent     => 'Some user agent',     # optional
        UserID        => 1,
    );

Returns:

    $Success =1;                # or undef if FAQLog could not be added

FAQTop10Get()

Returns an array with the top 10 FAQ article ids.

    my $Top10IDsRef = $FAQObject->FAQTop10Get(
        Interface   => 'public',
        CategoryIDs => [ 1, 2, 3 ],  # (optional) Only show the Top-10 articles from these categories
        Limit       => 10,           # (optional, default 10)
        UserID      => 1,
    );

Returns:

    $Top10IDsRef = [
        {
            'ItemID'    => 13,
            'Count'     => 159,               # number of visits
            'Interface' => 'public',
        },
        {
            'ItemID'    => 6,
            'Count'     => 78,
            'Interface' => 'public',
        },
        {
            'ItemID'    => 4,
            'Count'     => 59,
            'Interface' => 'internal',
        },
        {
            'ItemID'    => 20,
            'Count'     => 29,
            'Interface' => 'public',
        },
        {
            'ItemID'    => 1,
            'Count'     => 24,
            'Interface' => 'external',
        },
        {
            'ItemID'    => 11,
            'Count'     => 24,
            'Interface' => 'internal',
        },
        {
            'ItemID'    => 5,
            'Count'     => 18,
            'Interface' => 'internal',
        },
        {
            'ItemID'    => 9,
            'Count'     => 16,
            'Interface' => 'external',
        },
        {
            'ItemID'    => 2,
            'Count'     => 14,
            'Interface' => 'internal'
        },
        {
            'ItemID'    => 14,
            'Count'     => 6,
            'Interface' => 'public',
        }
    ];

FAQInlineAttachmentURLUpdate()

Updates the URLs of uploaded inline attachments.

    my $Success = $FAQObject->FAQInlineAttachmentURLUpdate(
        ItemID     => 12,
        FormID     => 456,
        FileID     => 5,
        Attachment => \%Attachment,
        UserID     => 1,
    );

Returns:

    $Success = 1;               # of undef if attachment URL could not be updated

FAQArticleTitleClean()

strip/clean up a FAQ article title

    my $NewTitle = $FAQObject->FAQArticleTitleClean(
        Title      => $OldTitle,
        Size       => $TitleSizeToBeDisplayed   # optional, if 0 do not cut title
    );

FAQContentTypeSet()

Sets the content type of 1, some or all FAQ items, by a given parameter or determined by the FAQ item content

    my $Success = $FAQObject->FAQContentTypeSet(
        FAQItemIDs  => [ 1, 2, 3 ],             # optional,
        ContentType => 'some content type',     # optional,
    );

DEPRECATED FUNCTIONS

HistoryGet()

Deprecated, use FAQJournalGet() instead.

PRIVATE FUNCTIONS

_FAQApprovalUpdate()

update the approval state of an article

    my $Success = $FAQObject->_FAQApprovalUpdate(
        ItemID     => 123,
        Approved   => 1,    # 0|1 (default 0)
        UserID     => 1,
    );

_FAQApprovalTicketCreate()

creates an approval ticket

    my $Success = $FAQObject->_FAQApprovalTicketCreate(
        ItemID     => 123,
        CategoryID => 2,
        LanguageID => 1,
        FAQNumber  => 10211,
        Title      => 'Some Title',
        StateID    => 1,
        UserID     => 1,
    );
Scroll to Top