NAME
Kernel::System::FAQ::Category – sub module of Kernel::System::FAQ
DESCRIPTION
All FAQ category functions.
PUBLIC INTERFACE
CategoryAdd()
add a category
my $CategoryID = $FAQObject->CategoryAdd(
Name => 'CategoryA',
Comment => 'Some comment', # Optional
ParentID => 2, # Mandatory, but could be 0
ValidID => 1,
UserID => 1,
);
Returns:
$CategoryID = 34; # or undef if category could not be added
CategoryCount()
Count the number of categories.
my $CategoryCount = $FAQObject->CategoryCount(
ParentIDs => [ 1, 2, 3, 4 ],
UserID => 1,
);
Returns:
$CategoryCount = 6;
CategoryDelete()
Delete a category.
my $DeleteSuccess = $FAQObject->CategoryDelete(
CategoryID => 123,
UserID => 1,
);
Returns:
DeleteSuccess = 1; # or undef if category could not be deleted
CategoryDuplicateCheck()
check a category for duplicate name under the same parent
my $Exists = $FAQObject->CategoryDuplicateCheck(
CategoryID => 1,
Name => 'Some Name',
ParentID => 1,
UserID => 1,
);
Returns:
$Exists = 1; # if category name already exists with the same parent
# or 0 if the name does not exists with the same parent
CategoryGet()
get a category as hash
my %Category = $FAQObject->CategoryGet(
CategoryID => 1,
UserID => 1,
);
Returns:
%Category = (,
CategoryID => 2,
ParentID => 0,
Name => 'My Category',
Comment => 'This is my first category.',
ValidID => 1,
);
CategoryGroupGet()
get groups of a category
my $GroupArrayRef = $FAQObject->CategoryGroupGet(
CategoryID => 3,
UserID => 1,
);
Returns:
$GroupArrayRef = [
2,
9,
10,
];
CategoryGroupGetAll()
get all category-groups
my $AllCategoryGroupHashRef = $FAQObject->CategoryGroupGetAll(
UserID => 1,
);
Returns:
$AllCategoryGroupHashRef = {
1 => {
2 => 1,
},
2 => {
2 => 1,
9 => 1,
10 => 1,
},
3 => {
2 => 1,
9 => 1,
10 => 1,
},
4 => {
1 => 1,
2 => 1,
3 => 1,
4 => 1,
5 => 1,
9 => 1,
10 => 1,
},
};
CategoryList()
get the category list as hash
my $CategoryHashRef = $FAQObject->CategoryList(
Valid => 1, # (optional)
UserID => 1,
);
Returns:
$CategoryHashRef = {
0 => {
1 => 'Misc',
2 => 'My Category',
},
2 => {
3 => 'Sub Category A',
4 => 'Sub Category B',
},
};
CategorySearch()
get the category search as an array ref
my $CategoryIDArrayRef = $FAQObject->CategorySearch(
Name => 'Test',
ParentID => 3,
ParentIDs => [ 1, 3, 8 ],
CategoryIDs => [ 2, 5, 7 ],
OrderBy => 'Name',
SortBy => 'down',
UserID => 1,
);
Returns:
$CategoryIDArrayRef = [
2,
];
CategorySubCategoryIDList()
get all subcategory ids of a category
my $SubCategoryIDArrayRef = $FAQObject->CategorySubCategoryIDList(
ParentID => 1,
Mode => 'Public', # (Agent, Customer, Public)
CustomerUser => 'tt',
UserID => 1,
);
Returns:
$SubCategoryIDArrayRef = [
3,
4,
5,
6,
];
CategoryTreeList()
get all categories as tree (with their long names)
my $CategoryTree = $FAQObject->CategoryTreeList(
Valid => 0, # (0|1, optional)
UserID => 1,
);
Returns:
$CategoryTree = {
1 => 'Misc',
2 => 'My Category',
3 => 'My Category::Sub Category A',
4 => 'My Category::Sub Category B',
};
CategoryUpdate()
update a category
my $Success = $FAQObject->CategoryUpdate(
CategoryID => 2,
ParentID => 1,
Name => 'Some Category',
Comment => 'some comment',
UserID => 1,
);
Returns:
$Success = 1; # or undef if category could not be updated
AgentCategorySearch()
get the category search as array ref
my $CategoryIDArrayRef = $FAQObject->AgentCategorySearch(
ParentID => 3, # (optional, default 0)
GetSubCategories => 1, # (optional, default 0)
UserID => 1,
);
Returns:
$CategoryIDArrayRef = [
'4',
'8',
];
CustomerCategorySearch()
get the category search as hash
my $CategoryIDArrayRef = @{$FAQObject->CustomerCategorySearch(
CustomerUser => 'tt',
ParentID => 3, # (optional, default 0)
Mode => 'Customer',
GetSubCategories => 1 # (optional), default 0)
UserID => 1,
)};
Returns:
$CategoryIDArrayRef = [
'4',
'8',
];
PublicCategorySearch()
get the category search as hash
my $CategoryIDArrayRef = $FAQObject->PublicCategorySearch(
ParentID => 3, # (optional, default 0)
Mode => 'Public',
UserID => 1,
);
Returns:
$CategoryIDArrayRef = [
'4',
'8',
];
GetUserCategories()
get user category-groups
my $UserCategoryGroupHashRef = $FAQObject->GetUserCategories(
Type => 'rw',
UserID => 1,
);
Returns:
$UserCategoryGroupHashRef = {
1 => {},
0 => {
1 => 'Misc',
2 => 'My Category',
},
2 => {
3 => 'Sub Category A',
4 => 'Sub Category B',
},
3 => {},
4 => {},
};
GetUserCategoriesLongNames()
get user category-groups (show category long names)
my $UserCategoryGroupHashRef = $FAQObject->GetUserCategoriesLongNames(
Type => 'rw',
UserID => 1,
);
Returns:
$UserCategoryGroupHashRef = {
1 => 'Misc',
2 => 'My Category',
3 => 'My Category::Sub Category A',
4 => 'My Category::Sub Category A',
};
GetCustomerCategories()
get customer user categories
my $CustomerUserCategoryHashRef = $FAQObject->GetCustomerCategories(
CustomerUser => 'hans',
Type => 'rw',
UserID => 1,
);
Returns:
$CustomerUserCategoryHashRef = {
1 => {},
0 => {
1 => 'Misc',
2 => 'My Category',
},
2 => {
3 => 'Sub Category A',
4 => 'Sub Category B',
},
3 => {},
4 => {},
};
GetCustomerCategoriesLongNames()
get customer category-groups (show category long names)
my $CustomerCategoryGroupHashRef = $FAQObject->GetCustomerCategoriesLongNames(
CustomerUser => 'hans',
Type => 'rw',
UserID => 1,
);
Returns:
$CustomerCategoryGroupHashRef = {
1 => 'Misc',
2 => 'My Category',
3 => 'My Category::Sub Category A',
4 => 'My Category::Sub Category A',
};
GetPublicCategoriesLongNames()
get public category-groups (show category long names)
my $PublicCategoryGroupHashRef = $FAQObject->GetPublicCategoriesLongNames(
Type => 'rw',
UserID => 1,
);
Returns:
$PublicCategoryGroupHashRef = {
1 => 'Misc',
2 => 'My Category',
3 => 'My Category::Sub Category A',
4 => 'My Category::Sub Category A',
};
CheckCategoryUserPermission()
get user permission for a category
my $PermissionString = $FAQObject->CheckCategoryUserPermission(
CategoryID => '123',
Type => 'rw', # (optional) rw or ro, default ro
UserID => 1,
);
Returns:
$PermissionString = 'rw'; # or 'ro' or ''
CheckCategoryCustomerPermission()
get customer user permission for a category
my $PermissionString $FAQObject->CheckCategoryCustomerPermission(
CustomerUser => 'mm',
CategoryID => '123',
UserID => 1,
);
Returns:
$PermissionString = 'rw'; # or 'ro' or ''
SetCategoryGroup()
set groups to a category
my $Success = $FAQObject->SetCategoryGroup(
CategoryID => 3,
GroupIDs => [ 2,4,1,5,77 ],
UserID => 1,
);
Returns:
$Success = 1; # or undef if groups could not be set to a category
PRIVATE FUNCTIONS
_UserCategories()
reduces the categories ( from CategoryList() ) to only the ones where the user has privileges.
my $UserCategories = $FAQObject->_UserCategories(
Categories => $CategoryHashRef, # as returned form CategoryList()
CategoryGroups => $CategoryGroupHashRef, # as returned from CategoryGroupGetAll
UserGroups => $UserGroupsHashRef,
UserID => 123,
);
Returns:
$UserCategoies = {
0 => {
1 => 'Misc',
2 => 'My Category',
},
2 => {
3 => 'Sub Category A',
},
};