Vanilla 2  2.0.18.8
 All Data Structures Namespaces Files Functions Variables Pages
CategoryModel Class Reference
Inheritance diagram for CategoryModel:
Collaboration diagram for CategoryModel:

Public Member Functions

 __construct ()
 
 Delete ($Category, $ReplacementCategoryID)
 
 GetByCode ($Code)
 
 GetID ($CategoryID)
 
 Get ($OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetAll ()
 
 GetDescendantCountByCode ($Code)
 
 GetDescendantsByCode ($Code)
 
 GetFull ($CategoryID= '', $Permissions=FALSE)
 
 GetFullByUrlCode ($UrlCode)
 
 HasChildren ($CategoryID)
 
 RebuildTree ()
 
 SaveTree ($TreeArray)
 
 Save ($FormPostValues)
 
 SaveUserTree ($CategoryID, $Set)
 
 SetField ($ID, $Property, $Value=FALSE)
 
 ApplyUpdates ()
 
- Public Member Functions inherited from Gdn_Model
 __construct ($Name= '')
 
 DefineSchema ()
 
 Save ($FormPostValues, $Settings=FALSE)
 
 Insert ($Fields)
 
 Update ($Fields, $Where=FALSE, $Limit=FALSE)
 
 Delete ($Where= '', $Limit=FALSE, $ResetData=FALSE)
 
 FilterForm ($Data)
 
 FilterSchema ($Data)
 
 Get ($OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 GetCount ($Wheres= '')
 
 GetID ($ID, $DatasetType=FALSE)
 
 GetWhere ($Where=FALSE, $OrderFields= '', $OrderDirection= 'asc', $Limit=FALSE, $Offset=FALSE)
 
 ValidationResults ()
 
 Validate ($FormPostValues, $Insert=FALSE)
 
 SaveToSerializedColumn ($Column, $RowID, $Name, $Value= '')
 
 SetProperty ($RowID, $Property, $ForceValue=FALSE)
 
- Public Member Functions inherited from Gdn_Pluggable
 __construct ()
 
 GetReturn ($PluginName, $HandlerName)
 
 FireEvent ($EventName)
 
 __call ($MethodName, $Arguments)
 
- Public Member Functions inherited from Gdn_SliceProvider
 EnableSlicing (&$Sender)
 
 Slice ($SliceName, $Arguments=array())
 
 AddSliceAsset ($Asset)
 
 RenderSliceConfig ()
 

Static Public Member Functions

static CategoryWatch ()
 
static Categories ($ID=FALSE)
 
static JoinCategories (&$Data, $Column= 'CategoryID', $Options=array())
 
static JoinUserData (&$Categories, $AddUserCategory=TRUE)
 
static GetAncestors ($CategoryID, $CheckPermissions=TRUE)
 
static GetSubtree ($ID)
 
static JoinModerators ($Data, $Permission= 'Vanilla.Comments.Edit', $Column= 'Moderators')
 
static SetCache ($ID=FALSE, $Data=FALSE)
 
static AddCategoryColumns ($Data)
 

Data Fields

const CACHE_KEY = 'Categories'
 
 $Watching = FALSE
 
- Data Fields inherited from Gdn_Model
 $Data
 
 $Database
 
 $DateInserted = 'DateInserted'
 
 $DateUpdated = 'DateUpdated'
 
 $InsertUserID = 'InsertUserID'
 
 $Name
 
 $PrimaryKey = 'id'
 
 $Schema
 
 $SQL
 
 $UpdateUserID = 'UpdateUserID'
 
 $Validation
 
- Data Fields inherited from Gdn_Pluggable
 $EventArguments
 
 $Returns = array()
 
 $HandlerType
 

Static Public Attributes

static $Categories = NULL
 

Protected Member Functions

 _SetTree (&$Node, $Left=1, $Depth=0)
 
 _TreeSort ($A, $B)
 
- Protected Member Functions inherited from Gdn_Model
 _BeforeGet ()
 
 AddInsertFields (&$Fields)
 
 AddUpdateFields (&$Fields)
 

Static Protected Member Functions

static CalculateData (&$Data)
 

Additional Inherited Members

- Protected Attributes inherited from Gdn_Pluggable
 $ClassName
 
- Protected Attributes inherited from Gdn_SliceProvider
 $SliceHandler
 
 $SliceConfig
 

Constructor & Destructor Documentation

__construct ( )

Class constructor. Defines the related database table name.

Since
2.0.0 public

Member Function Documentation

_SetTree ( $Node,
  $Left = 1,
  $Depth = 0 
)
protected
Since
2.0.18 protected
Parameters
array$Node
int$Left
int$Depth

Here is the caller graph for this function:

_TreeSort (   $A,
  $B 
)
protected

Utility method for sorting via usort.

Since
2.0.18 protected
Parameters
$AFirst element to compare.
$BSecond element to compare.
Returns
int -1, 1, 0 (per usort)
static AddCategoryColumns (   $Data)
static

Modifies category data before it is returned.

Adds CountAllDiscussions column to each category representing the sum of discussions within this category as well as all subcategories.

Since
2.0.17 public
Parameters
object$DataSQL result.

Here is the call graph for this function:

Here is the caller graph for this function:

ApplyUpdates ( )

If looking at the root node, make sure it exists and that the nested set columns exist in the table.

Since
2.0.15 public

Here is the call graph for this function:

static CalculateData ( $Data)
staticprotected
Since
2.0.18 public
Parameters
array$DataDataset.
static Categories (   $ID = FALSE)
static
Since
2.0.18 public
Parameters
int$ID
Returns
object DataObject

Here is the call graph for this function:

Here is the caller graph for this function:

static CategoryWatch ( )
static
Since
2.0.18 public
Returns
array Category IDs.

Here is the call graph for this function:

Here is the caller graph for this function:

Delete (   $Category,
  $ReplacementCategoryID 
)

Delete a single category and assign its discussions to another.

Since
2.0.0 public
Parameters
object$Category
int$ReplacementCategoryIDUnique ID of category all discussion are being move to.

Here is the call graph for this function:

Here is the caller graph for this function:

Get (   $OrderFields = '',
  $OrderDirection = 'asc',
  $Limit = FALSE,
  $Offset = FALSE 
)

Get list of categories (respecting user permission).

Since
2.0.0 public
Parameters
string$OrderFieldsIgnored.
string$OrderDirectionIgnored.
int$LimitIgnored.
int$OffsetIgnored.
Returns
Gdn_DataSet SQL results.

Here is the call graph for this function:

GetAll ( )

Get list of categories (disregarding user permission for admins).

Since
2.0.0 public
Parameters
string$OrderFieldsIgnored.
string$OrderDirectionIgnored.
int$LimitIgnored.
int$OffsetIgnored.
Returns
object SQL results.

Here is the call graph for this function:

Here is the caller graph for this function:

static GetAncestors (   $CategoryID,
  $CheckPermissions = TRUE 
)
static

Get all of the ancestor categories above this one.

Parameters
int | string$CategoryThe category ID or url code.
bool$CheckPermissionsWhether or not to only return the categories with view permission.
Returns
array

Here is the caller graph for this function:

GetByCode (   $Code)

Get data for a single category selected by Url Code. Disregards permissions.

Since
2.0.0 public
Parameters
int$CodeIDUnique Url Code of category we're getting data for.
Returns
object SQL results.

Here is the call graph for this function:

Here is the caller graph for this function:

GetDescendantCountByCode (   $Code)

Return the number of descendants for a specific category.

Here is the call graph for this function:

GetDescendantsByCode (   $Code)
Since
2.0.18 public
Parameters
string$CodeWhere condition.
Returns
object DataSet

Here is the call graph for this function:

GetFull (   $CategoryID = '',
  $Permissions = FALSE 
)

Get full data for a single category or all categories. Respects Permissions.

If no CategoryID is provided, it gets all categories.

Since
2.0.0 public
Parameters
int$CategoryIDUnique ID of category to return.
string$PermissionsPermission to check.
Returns
object SQL results.

Here is the call graph for this function:

Here is the caller graph for this function:

GetFullByUrlCode (   $UrlCode)

Get full data for a single category by its URL slug. Respects permissions.

Since
2.0.0 public
Parameters
string$UrlCodeUnique category slug from URL.
Returns
object SQL results.

Here is the call graph for this function:

GetID (   $CategoryID)

Get data for a single category selected by ID. Disregards permissions.

Since
2.0.0 public
Parameters
int$CategoryIDUnique ID of category we're getting data for.
Returns
object SQL results.

Here is the call graph for this function:

Here is the caller graph for this function:

static GetSubtree (   $ID)
static
Since
2.0.18 public
Parameters
int$ID
Returns
array

Here is the caller graph for this function:

HasChildren (   $CategoryID)

Check whether category has any children categories.

Since
2.0.0 public
Parameters
string$CategoryIDUnique ID for category being checked.
Returns
bool

Here is the call graph for this function:

static JoinCategories ( $Data,
  $Column = 'CategoryID',
  $Options = array() 
)
static
Since
2.0.18 public
Parameters
array$DataDataset.
string$ColumnName of database column.
array$Options'Join' key may contain array of columns to join on.

Here is the caller graph for this function:

static JoinModerators (   $Data,
  $Permission = 'Vanilla.Comments.Edit',
  $Column = 'Moderators' 
)
static
Since
2.0.0 public
Parameters
array$Data
string$Permission
string$Column

Here is the call graph for this function:

Here is the caller graph for this function:

static JoinUserData ( $Categories,
  $AddUserCategory = TRUE 
)
static
Since
2.0.18 public
Parameters
array$Categories
bool$AddUserCategory

Here is the call graph for this function:

RebuildTree ( )

Rebuilds the category tree. We are using the Nested Set tree model.

http://articles.sitepoint.com/article/hierarchical-data-database/2 http://en.wikipedia.org/wiki/Nested_set_model

Since
2.0.0 public

Here is the call graph for this function:

Here is the caller graph for this function:

Save (   $FormPostValues)

Saves the category.

Since
2.0.0 public
Parameters
array$FormPostValueThe values being posted back from the form.
Returns
int ID of the saved category.

Here is the call graph for this function:

SaveTree (   $TreeArray)

Saves the category tree based on a provided tree array. We are using the Nested Set tree model.

http://articles.sitepoint.com/article/hierarchical-data-database/2 http://en.wikipedia.org/wiki/Nested_set_model

Since
2.0.16 public
Parameters
array$TreeArrayA fully defined nested set model of the category tree.

Here is the call graph for this function:

Here is the caller graph for this function:

SaveUserTree (   $CategoryID,
  $Set 
)

Grab the Category IDs of the tree.

Since
2.0.18 public
Parameters
int$CategoryID
mixed$Set

Here is the call graph for this function:

Here is the caller graph for this function:

static SetCache (   $ID = FALSE,
  $Data = FALSE 
)
static

Grab the categories from the cache.

Since
2.0.18 public
Parameters
int$ID
array$Data

Here is the call graph for this function:

Here is the caller graph for this function:

SetField (   $ID,
  $Property,
  $Value = FALSE 
)

Field Documentation

$Categories = NULL
static
$Watching = FALSE
const CACHE_KEY = 'Categories'

The documentation for this class was generated from the following file: