Blesta Source Documentation

SupportManagerKbCategories extends SupportManagerModel

SupportManagerKbCategories model

Table of Contents

Methods

__construct() Constructor
add() Creates a new knowledge base category
delete() Deletes a knowledge base category
edit() Updates a knowledge base category
get() Retrieves a category
getAccessTypes() Retrieves a list of access types and their language
getAll() Retrieves a list of all categories for the given company that are first-descendants under the given parent, unless $parent_id is boolean false, or $categorize is set to true, in which case all categories for the company are returned
getAllParents() Retrieves all parent categories for the given category, including the given category
getItemCount() Fetches the total number of categories and articles directly descended from the given category
validateCategoryDeletion() Validates whether the given category can be deleted
validateCompanyMatches() Validates that the given parent category belongs to the same company as the current category
validateParent() Validates that the given parent category can be assigned to the given category
getCategories() Partially constructs a Record object for fetching categories
getRules() Retrieves rules for validating adding/editing a category
Methods

add()

Creates a new knowledge base category

public add(array<string|int, mixed> $vars) : stdClass
Parameters
$vars : array<string|int, mixed>

A list of category fields including:

  • parent_id The category ID of this child category's parent (optional)
  • company_id The ID of the company to assign this category to
  • name The name of this category
  • description The category description (optional)
  • access The type of access to give to this category ("public", "private", "hidden", or "staff"; optional, default public)
Return values
stdClass

An stdClass object representing the category, or void on error

delete()

Deletes a knowledge base category

public delete(int $category_id) : mixed
Parameters
$category_id : int

The ID of the category to delete

edit()

Updates a knowledge base category

public edit(int $category_id, array<string|int, mixed> $vars) : stdClass
Parameters
$category_id : int

The ID of the category to edit

$vars : array<string|int, mixed>

A list of category fields including (all optional):

  • parent_id The category ID of this child category's parent
  • name The name of this category
  • description The category description
  • access The type of access to give to this category ("public", "private", "hidden", or "staff")
Return values
stdClass

An stdClass object representing the category, or void on error

get()

Retrieves a category

public get(int $category_id) : mixed
Parameters
$category_id : int

The ID of the category to fetch

Return values
mixed

An stdClass object representing the category, or false if it does not exist

getAccessTypes()

Retrieves a list of access types and their language

public getAccessTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of access types and their language

getAll()

Retrieves a list of all categories for the given company that are first-descendants under the given parent, unless $parent_id is boolean false, or $categorize is set to true, in which case all categories for the company are returned

public getAll(int $company_id[, mixed $parent_id = false ][, bool $categorize = false ][, mixed $access = null ]) : array<string|int, mixed>
Parameters
$company_id : int

The ID of the company whose categories to fetch

$parent_id : mixed = false

The ID of the category whose children to fetch; null for no parent (i.e. base/home category); or boolean false to ignore the parent (optional, default false)

$categorize : bool = false

True to nest categories within their respective parents (set a $parent_id to avoid duplicate results), or false for a flattened list (optional, default false)

$access : mixed = null

A numerically-indexed array containing the access levels of categories that can be fetched, or null for all (i.e. "public", "private", "hidden", or "staff"; optional, default null for all)

Return values
array<string|int, mixed>

A list of categories. If $categorize is true, each parent category will contain the attribute 'children' with a further list of nested categories

getAllParents()

Retrieves all parent categories for the given category, including the given category

public getAllParents(int $category_id[, array<string|int, mixed> $exclude = [] ]) : array<string|int, mixed>
Parameters
$category_id : int

The child category for which to retrieve parents for

$exclude : array<string|int, mixed> = []

An array of parent categories to exclude from the results (optional, default empty array)

Return values
array<string|int, mixed>

A numerically-indexed array of categories ordered by the highest category down to, and including, the given category

getItemCount()

Fetches the total number of categories and articles directly descended from the given category

public getItemCount(int $category_id[, mixed $access = null ]) : array<string|int, mixed>
Parameters
$category_id : int

The ID of the category whose item count to fetch

$access : mixed = null

A numerically-indexed array containing the access levels of articles/categories that can be fetched, or null for all (i.e. "public", "private", "hidden", or "staff"; optional, default null for all)

Return values
array<string|int, mixed>

An array containing:

  • articles The number of articles within this category
  • categories The number of subcategories within this category

validateCategoryDeletion()

Validates whether the given category can be deleted

public validateCategoryDeletion(int $category_id) : bool
Parameters
$category_id : int

The ID of the category to delete

Return values
bool

True if the category can be deleted, or false otherwise

validateCompanyMatches()

Validates that the given parent category belongs to the same company as the current category

public validateCompanyMatches(int $parent_category_id, int $company_id) : bool
Parameters
$parent_category_id : int

The ID of the parent category to validate

$company_id : int

The ID of the company to check against

Return values
bool

True if the parent does not exist or matches the company, false otherwise

validateParent()

Validates that the given parent category can be assigned to the given category

public validateParent(int $parent_category_id, int $category_id) : bool
Parameters
$parent_category_id : int

The ID of the parent category

$category_id : int

The ID of the category to assign the parent to

Return values
bool

True if the category can be assigned to the parent, or false otherwise

getCategories()

Partially constructs a Record object for fetching categories

private getCategories([int $category_id = null ][, int $company_id = null ]) : Record
Parameters
$category_id : int = null

The ID of the category to fetch (optional)

$company_id : int = null

The ID of the company whose categories to fetch (optional)

Return values
Record

A partially-constructed Record object

getRules()

Retrieves rules for validating adding/editing a category

private getRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

A set of input data

$edit : bool = false

True to fetch the edit rules, or false for the add rules (optional, default false)

Return values
array<string|int, mixed>

A set of validation rules

Tags
subpackage

plugins.supportmanager

copyright

Copyright (c) 2014, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results