Property | Type | Description | |
---|---|---|---|
$Categories | Merged Category data, including Pure + UserCategory. | ||
$JoinRecentUsers | Whether or not to join users to recent posts. Forums with a lot of categories may need to optimize using this setting and simpler views. | ||
$ShardCache | Whether or not to explicitly shard the categories cache. | ||
$Watching | boolean |
Method | Description | |
---|---|---|
__construct ( ) | Class constructor. Defines the related database table name. | |
addCategoryColumns ( object $Data ) | Modifies category data before it is returned. | |
allowedDiscussionTypes ( array $PermissionCategory, array $category = [] ) : array | Checks the allowed discussion types on a category. | |
applyUpdates ( ) | If looking at the root node, make sure it exists and that the nested set columns exist in the table. | |
calculateDisplayAs ( &$category ) | Maintains backwards compatibilty with DisplayAs: Default-type categories by calculating the DisplayAs property into an expected DisplayAs type: Categories, Heading, or Discussions. Respects the now-deprecated config setting Vanilla.Categories.DoHeadings. Once we can be sure that all instances have their categories' DisplayAs properties explicitly set in the database (i.e., not Default) we can deprecate/remove this function. | |
categories ( integer | string | boolean $ID = false ) : array | Gets either all of the categories or a single category. | |
categoryUrl ( $Category, string $Page = '', boolean | true $WithDomain = true ) : string | Build URL to a category page. | |
categoryWatch ( $AllDiscussions = true ) : array | ||
checkPermission ( array $category, string $permission ) : boolean | Check a category's permission. | |
clearCache ( ) | ||
clearUserCache ( ) | ||
counts ( $Column ) : array | ||
createCollection ( Gdn_SQLDriver $sql = null, Gdn_Cache $cache = null ) : CategoryCollection | Create a new category collection tied to this model. | |
defaultCategory ( ) : mixed | ||
delete ( $where = [], $options = [] ) | Delete a category. | |
deleteAndReplace ( object $category, integer $newCategoryID ) | Delete a single category and assign its discussions to another. | |
deleteID ( integer $categoryID, array $options = [] ) : boolean | Delete a category. | |
filterCategoryPermissions ( array $categoryIDs ) : array | Remove categories that a user does not have permission to view. | |
filterChildren ( array &$categories, string $childField = 'Children' ) | Recursively remove children from categories configured to display as "Categories" or "Flat". | |
filterFollowing ( array $categories ) : array | Filter a category tree to only the followed categories. | |
flattenTree ( array $categories ) : array | Return a flattened version of a tree. | |
get ( string $OrderFields = '', string $OrderDirection = 'asc', integer $Limit = false, integer $Offset = false ) : Gdn_DataSet | Get list of categories (respecting user permission). | |
getAll ( ) : object | Get list of categories (disregarding user permission for admins). | |
getAncestors ( $categoryID, boolean $checkPermissions = true, boolean $includeHeadings = false ) : array | Get all of the ancestor categories above this one. | |
getByCode ( $Code ) : object | Get data for a single category selected by Url Code. Disregards permissions. | |
getByPermission ( string $Permission = 'Discussions.Add', null $CategoryID = null, array $Filter = [], array $PermFilter = [] ) : array | ||
getChildTree ( integer | string $id, array $options = [] ) : array | Get a category tree based on, but not including a parent category. | |
getChildren ( integer $categoryID ) | Get the child categories of a category. | |
getDescendantCountByCode ( $Code ) | Return the number of descendants for a specific category. | |
getDescendantsByCode ( string $Code ) : object | ||
getDisplayAsOptions ( ) : array | ||
getFiltered ( array $RestrictIDs = false, string $Permissions = false, array $ExcludeWhere = false ) : Gdn_DataSet | Get a list of categories, considering several filters | |
getFull ( $CategoryID = false, $Permissions = false ) | ||
getFullByUrlCode ( string $UrlCode ) : object | Get full data for a single category by its URL slug. Respects permissions. | |
getID ( integer $categoryID, string $datasetType = DATASET_TYPE_OBJECT, array $options = [] ) : object | array | Get data for a single category selected by ID. Disregards permissions. | |
getMaxDisplayDepth ( ) : integer | Get the maximum display depth for categories. | |
getNavDepth ( ) : integer | Get the category nav depth. | |
getRolePermissions ( integer $categoryID ) : array | Get the role specific permissions for a category. | |
getRootDisplayAs ( ) : string | Get the display type for the root category. | |
getSubtree ( string $parentCategory, boolean $includeParent = true ) : array | Get the subtree starting at a given parent. | |
getTreeAsFlat ( integer | string $id, integer | null $offset = null, integer | null $limit = null, string | null $filter = null, string $orderFields = 'Name', string $orderDirection = 'asc' ) : array | ||
getWhereCache ( array $Where ) : array | A simplified version of GetWhere that polls the cache instead of the database. | |
givePoints ( integer $UserID, integer $Points, string $Source = 'Other', integer $CategoryID, integer $Timestamp = false ) | Give a user points specific to this category. | |
hasChildren ( string $CategoryID ) : boolean | Check whether category has any children categories. | |
instance ( ) : CategoryModel | The shared instance of this object. | |
joinCategories ( &$Data, string $Column = 'CategoryID', array $Options = [] ) | ||
joinModerators ( array $Data, string $Permission = 'Vanilla.Comments.Edit', string $Column = 'Moderators' ) | ||
joinRecent ( &$categoryTree ) | Join recent posts and users to a category tree. | |
joinRecentChildPosts ( null &$Category = null, null &$Categories = null ) | ||
joinRecentPosts ( &$Data, null $CategoryID = null ) : boolean | ||
joinUserCategory ( ) : boolean | Whether or not to join information from GDN_UserCategory in {@link CategoryModel::calculateUser()}. | |
joinUserData ( &$Categories, boolean $AddUserCategory = true ) | Add UserCategory modifiers | |
makeTree ( $Categories, null $Root = null ) : array | ||
permissionCategory ( mixed $Category ) | Return the category that contains the permissions for the given category. | |
rebuildTree ( boolean $BySort = false ) | Rebuilds the category tree. We are using the Nested Set tree model. | |
recalculateTree ( ) | Recalculate the dynamic tree columns in the category. | |
save ( $FormPostValues, array | false $Settings = false ) : integer | Saves the category. | |
saveSubtree ( array $subtree, $parentID ) | Save a subtree. | |
saveTree ( array $TreeArray ) | Saves the category tree based on a provided tree array. We are using the Nested Set tree model. | |
saveUserTree ( integer $CategoryID, mixed $Set ) | Grab the Category IDs of the tree. | |
setCache ( integer | boolean $ID = false, array | boolean $Data = false ) | Grab and update the category cache | |
setField ( integer $ID, array | string $Property, boolean | false $Value = false ) : array | string | Set a property on a category. | |
setJoinUserCategory ( boolean $joinUserCategory ) : CategoryModel | Set whether or not to join information from GDN_UserCategory in {@link CategoryModel::calculateUser()}. | |
setLocalField ( $ID, $Property, $Value ) : boolean | Set a property of a currently-loaded category in memory. | |
setRecentPost ( $CategoryID ) | ||
setStopHeadingsCalculation ( boolean $stopHeadingCalculation ) : CategoryModel | Checks to see if the passed category depth is greater than the NavDepth and if so, stops calculating Headings as a DisplayAs property in the calculateDisplayAs method. Once we can be sure that all instances have their categories' DisplayAs properties explicitly set in the database (i.e., not Default) we can deprecate/remove this function. | |
where ( $Row, $Where ) : boolean |
Method | Description | |
---|---|---|
_MakeTreeChildren ( $Category, $Categories, null $DepthAdj = null ) : array | ||
_SetTree ( array &$Node, integer $Left = 1, integer $Depth ) | ||
_treeSort ( $A, $B ) : integer | Utility method for sorting via usort. | |
buildCache ( integer $CategoryID = null ) | Build and augment the category cache. | |
rebuildLock ( boolean $release = false ) : boolean | Request rebuild mutex. |
Method | Description | |
---|---|---|
calculate ( &$category ) | Calculate the dynamic fields of a category. | |
calculateData ( array &$Data ) | Build calculated category data on the passed set. | |
calculateUser ( &$category, $addUserCategory = null ) | Calculate the user-specific information on a category. | |
castID ( integer | string | null $category ) : integer | string | null | Cast a category ID or slug to be passed to the various {@link CategoryCollection} methods. | |
gatherLastIDs ( array $categoryTree, &$result = null ) | Gather all of the last discussion and comment IDs from the categories. | |
getOne ( string | integer $id ) | Get a single category from the collection. | |
getUserCategories ( ) : array | mixed | Get the per-category information for the current user. | |
joinRecentInternal ( &$categoryTree, array $discussions, array $comments ) | This method supports {@link CategoryModel::joinRecent()}. | |
loadAllCategories ( ) | Load all of the categories from the cache or the database. | |
saveSubtreeInternal ( array $subtree, integer | null $parentID = null, boolean $rebuild = true ) | Save a subtree. |
protected static _MakeTreeChildren ( $Category, $Categories, null $DepthAdj = null ) : array | ||
$Category | ||
$Categories | ||
$DepthAdj | null | |
return | array |
public __construct ( ) |
public static addCategoryColumns ( object $Data ) | ||
$Data | object | SQL result. |
public applyUpdates ( ) |
protected static buildCache ( integer $CategoryID = null ) | ||
$CategoryID | integer | The category to |
public static calculateDisplayAs ( &$category ) | ||
$category | The category to calculate the DisplayAs property for. |
public static categoryWatch ( $AllDiscussions = true ) : array | ||
return | array | Category IDs. |
public createCollection ( Gdn_SQLDriver $sql = null, Gdn_Cache $cache = null ) : CategoryCollection | ||
$sql | Gdn_SQLDriver | |
$cache | Gdn_Cache | |
return | CategoryCollection | Returns a new collection. |
public deleteAndReplace ( object $category, integer $newCategoryID ) | ||
$category | object | |
$newCategoryID | integer | Unique ID of category all discussion are being move to. |
public deleteID ( integer $categoryID, array $options = [] ) : boolean | ||
$categoryID | integer | The ID of the category to delete. |
$options | array | An array of options to affect the behavior of the delete. - **newCategoryID**: The new category to point discussions to. |
return | boolean | Returns **true** on success or **false** otherwise. |
public static filterCategoryPermissions ( array $categoryIDs ) : array | ||
$categoryIDs | array | An array of categories to filter. |
return | array | Returns an array of category IDs that are okay to view. |
public static filterChildren ( array &$categories, string $childField = 'Children' ) | ||
$categories | array | |
$childField | string |
public filterFollowing ( array $categories ) : array | ||
$categories | array | The category tree to filter. |
return | array | Returns a category tree. |
public static flattenTree ( array $categories ) : array | ||
$categories | array | The category tree. |
return | array | Returns the flattened category tree. |
public static getChildren ( integer $categoryID ) | ||
$categoryID | integer | The category to get the children of. |
public getDescendantCountByCode ( $Code ) |
public getDescendantsByCode ( string $Code ) : object | ||
$Code | string | Where condition. |
return | object | DataSet |
public static getDisplayAsOptions ( ) : array | ||
return | array |
public getFiltered ( array $RestrictIDs = false, string $Permissions = false, array $ExcludeWhere = false ) : Gdn_DataSet | ||
$RestrictIDs | array | Optional list of category ids to mask the dataset |
$Permissions | string | Optional permission to require. Defaults to Vanilla.Discussions.View. |
$ExcludeWhere | array | Exclude categories with any of these flags |
return | Gdn_DataSet |
public getFullByUrlCode ( string $UrlCode ) : object | ||
$UrlCode | string | Unique category slug from URL. |
return | object | SQL results. |
public getMaxDisplayDepth ( ) : integer | ||
return | integer | Returns the display depth as an integer. |
public getRolePermissions ( integer $categoryID ) : array | ||
$categoryID | integer | The ID of the category to get the permissions for. |
return | array | Returns an array of permissions. |
public static getRootDisplayAs ( ) : string | ||
return | string |
public getTreeAsFlat ( integer | string $id, integer | null $offset = null, integer | null $limit = null, string | null $filter = null, string $orderFields = 'Name', string $orderDirection = 'asc' ) : array | ||
$id | integer | string | The parent category ID or slug. |
$offset | integer | null | Offset results by given value. |
$limit | integer | null | Total number of results should not exceed this value. |
$filter | string | null | Restrict results to only those with names matching this value, if provided. |
$orderFields | string | |
$orderDirection | string | |
return | array |
public getWhereCache ( array $Where ) : array | ||
$Where | array | |
return | array |
public static givePoints ( integer $UserID, integer $Points, string $Source = 'Other', integer $CategoryID, integer $Timestamp = false ) | ||
$UserID | integer | The user to give the points to. |
$Points | integer | The number of points to give. |
$Source | string | The source of the points. |
$CategoryID | integer | The category to give the points for. |
$Timestamp | integer | The time the points were given. |
public hasChildren ( string $CategoryID ) : boolean | ||
$CategoryID | string | Unique ID for category being checked. |
return | boolean |
public static instance ( ) : CategoryModel | ||
return | CategoryModel | Returns the instance. |
public static joinCategories ( &$Data, string $Column = 'CategoryID', array $Options = [] ) | ||
$Column | string | Name of database column. |
$Options | array | The 'Join' key may contain array of columns to join on. |
public joinRecent ( &$categoryTree ) |
public static joinRecentChildPosts ( null &$Category = null, null &$Categories = null ) | ||
$Category | null | |
$Categories | null |
public static joinRecentPosts ( &$Data, null $CategoryID = null ) : boolean | ||
$Data | ||
$CategoryID | null | |
return | boolean |
public joinUserCategory ( ) : boolean | ||
return | boolean | Returns the joinUserCategory. |
public static joinUserData ( &$Categories, boolean $AddUserCategory = true ) | ||
$AddUserCategory | boolean |
public static permissionCategory ( mixed $Category ) | ||
$Category | mixed |
protected static rebuildLock ( boolean $release = false ) : boolean | ||
$release | boolean | |
return | boolean | whether we may rebuild |
public rebuildTree ( boolean $BySort = false ) | ||
$BySort | boolean | Rebuild the tree by sort order instead of existing tree order. |
public recalculateTree ( ) |
public saveSubtree ( array $subtree, $parentID ) | ||
$subtree | array | A nested array where each array contains a CategoryID and optional Children element. |
public saveUserTree ( integer $CategoryID, mixed $Set ) | ||
$CategoryID | integer | |
$Set | mixed |
public setJoinUserCategory ( boolean $joinUserCategory ) : CategoryModel | ||
$joinUserCategory | boolean | The new value to set. |
return | CategoryModel | Returns `$this` for fluent calls. |
public static setLocalField ( $ID, $Property, $Value ) : boolean | ||
$ID | ||
$Property | ||
$Value | ||
return | boolean |
public setStopHeadingsCalculation ( boolean $stopHeadingCalculation ) : CategoryModel | ||
$stopHeadingCalculation | boolean | |
return | CategoryModel |
public static $Categories |
public $JoinRecentUsers |
public static $ShardCache |