Model for forums
Models don't share that much, so most implementations will be adding methods onto this class. This class simply provides helper methods for common actions.
| package | XenForo_Forum | 
|---|
__construct()
Use create() statically unless you know what you're doing.
| inherited_from | \XenForo_Model::__construct() | 
|---|
addFetchOptionJoin(array $fetchOptions, integer $join)
Join should be one of the constants.
| inherited_from | \XenForo_Model::addFetchOptionJoin() | 
|---|
array
integer
addPositionLimit(string $table, integer $limit, integer $offset, string $column) : string
It no limit value is specified, nothing will be returned.
This must be added within a WHERE clause. If a clause is required, it will begin with "AND", so ensure there is a condition before it.
| inherited_from | \XenForo_Model::addPositionLimit() | 
|---|
stringName of the table alias to prefix. May be blank for no table reference.
integerNumber of records to limit to; ignored if <= 0
integerOffset from the start of the records. 0+
stringName of the column that is storing the position
stringPosition limit clause if neededassertValidCutOffOperator(string $operator)
| inherited_from | \XenForo_Model::assertValidCutOffOperator() | 
|---|
string
canLockUnlockThreadInForum(array $forum, string $errorPhraseKey, array $nodePermissions, array $viewingUser) : boolean
array
string
arraynull
arraynull
booleancanPostThreadInForum(array $forum, string $errorPhraseKey, array $nodePermissions, array $viewingUser) : boolean
If no permissions are specified, permissions are retrieved from the currently visiting user. This does not check viewing permissions.
arrayInfo about the forum posting in
stringReturned phrase key for a specific error
arraynull
arraynull
booleancanStickUnstickThreadInForum(array $forum, string $errorPhraseKey, array $nodePermissions, array $viewingUser) : boolean
array
string
arraynull
arraynull
booleancanUploadAndManageAttachment(array $forum, string $errorPhraseKey, array $nodePermissions, array $viewingUser) : boolean
If no permissions are specified, permissions are retrieved from the currently visiting user. This does not check viewing permissions.
arrayInfo about the forum posting in
stringReturned phrase key for a specific error
arraynull
arraynull
booleancanViewForum(array $forum, string $errorPhraseKey, array $nodePermissions, array $viewingUser) : boolean
arrayInfo about the forum posting in
stringReturned phrase key for a specific error
arraynull
arraynull
booleancreate(string $class) : \XenForo_Model
The class must exist or be autoloadable or an exception will be thrown.
| inherited_from | \XenForo_Model::create() | 
|---|
stringClass to load
fetchAllKeyed(string $sql, string $key, mixed $bind, string $nullPrefix) : array
The 'key' parameter provides the column name with which to key the result. For example, calling fetchAllKeyed('SELECT item_id, title, date FROM table', 'item_id') would result in an array keyed by item_id: [$itemId] => array('item_id' => $itemId, 'title' => $title, 'date' => $date)
Note that the specified key must exist in the query result, or it will be ignored.
| inherited_from | \XenForo_Model::fetchAllKeyed() | 
|---|
stringSQL to execute
stringColumn with which to key the results array
mixedParameters for the SQL
stringIf the key is null, prefix the counter with this
arraygetAttachmentParams(array $forum, array $contentData, array $nodePermissions, array $viewingUser) : array | false
array
arrayInformation about the content, for URL building
arraynull
arraynull
arrayfalse
getConditionsForClause(array $sqlConditions) : string
This always returns a value that can be used in a clause such as WHERE.
| inherited_from | \XenForo_Model::getConditionsForClause() | 
|---|
array
stringgetContentTypeField(string $contentType, string $fieldName) : string | false
| inherited_from | \XenForo_Model::getContentTypeField() | 
|---|
string
string
stringfalse
getContentTypesWithField(string $fieldName) : array
| inherited_from | \XenForo_Model::getContentTypesWithField() | 
|---|
string
arrayFormat: [content type] => field valuegetExtraForumDataForNodes(array $nodeIds, array $fetchOptions) : array
array
arrayOptions that affect what is fetched
arrayFormat: [node id] => extra infogetForumById(integer $id, array $fetchOptions) : array
integerNode ID
arrayOptions that affect what is fetched
arraygetForumByNodeName(string $name, array $fetchOptions) : array
stringNode name
arrayOptions that affect what is fetched
arraygetForumByThreadId(integer $threadId) : array
integer
arraygetForumCounters(integer $forumId) : array
integer
arrayKeys: discussion_count, message_countgetForums(array $conditions, array $fetchOptions) : array
array
array
arraygetForumsByIds(array $forumIds, array $fetchOptions) : array
array
arrayOptions that affect what is fetched
arrayFormat: [node id] => infogetForumsByThreadIds(array $threadIds)
getModelFromCache(string $class) : \XenForo_Model
If it does not exist, it will be instantiated.
| inherited_from | \XenForo_Model::getModelFromCache() | 
|---|
stringName of the class to load
getOrderByClause(array $choices, array $fetchOptions, string $defaultOrderSql) : string
| inherited_from | \XenForo_Model::getOrderByClause() | 
|---|
array
array
string
stringOrder by clause or empty stringgetPermissionsForForum(array $forum, array $permissionsList) : array
When looking within the forum, looks for "nodePermissions" or "node_permission_cache" keys.
arrayForum info
arrayOptional permissions to override; format: [forum id] => permissions
arrayPermissions for forumgetUnreadThreadCountInForum(integer $forumId, integer $userId, integer $forumReadDate, string | array $ignored) : integer | false
This only applies to registered users. If no user ID is given, false is returned.
integer
integer
integerTime when the whole forum is read from
stringarrayList of ignored user IDs; if string, unserialized and keys used
integerfalse
getUserForumReadDate(integer $userId, integer $forumId) : integer | null
integer
integer
integernullNull if guest; timestamp otherwiselimitQueryResults(string $query, integer $limit, integer $offset) : string
If the limit value is 0 or less, no clause is applied.
| inherited_from | \XenForo_Model::limitQueryResults() | 
|---|
stringSQL query to run
integerNumber of records to limit to; ignored if <= 0
integerOffset from the start of the records. 0+
stringQuery with limit applied if necessarymarkForumRead(array $forum, integer $readDate, array $viewingUser) : boolean
Forum must have the forum_read_date key.
arrayForum info
integerTimestamp to mark as read until
arraynull
booleanTrue if marked as readmarkForumReadIfNeeded(array $forum, array $viewingUser) : boolean
array
arraynull
booleanmarkForumTreeRead(array $baseForum, integer $readDate, array $viewingUser) : array
This can be used without a base forum to mark all forums as read.
arraynullInfo about base forum to mark read; may be null
integerDate to set as read date
arraynull
arrayA list of node IDs that were marked as readprepareForum(array $forum) : array
arrayUnprepared forum
arrayPrepared forumprepareForumConditions(array $conditions, array $fetchOptions) : string
arrayList of conditions
arrayModifiable set of fetch options (may have joins pushed on to it)
stringSQL clause (at least 1=1)prepareForumJoinOptions(array $fetchOptions) : array
arrayArray containing a 'join' integer key build from this class's FETCH_x bitfields and other keys
arrayContaining 'selectFields' and 'joinTables' keys. Example: selectFields = ', user.*, foo.title'; joinTables = ' INNER JOIN foo ON (foo.id = other.id) 'prepareForums(array $forums) : array
arrayUnprepared forums
arrayPrepared forumsprepareLimitFetchOptions(array $fetchOptions) : array
Includes: limit, offset, page, and perPage.
| inherited_from | \XenForo_Model::prepareLimitFetchOptions() | 
|---|
arrayUnprepared options
arrayLimit options; keys: limit, offsetprepareStateLimitFromConditions(array $fetchOptions, string $table, string $stateField, string $userField) : string
Looks for keys "deleted" and "moderated".
| inherited_from | \XenForo_Model::prepareStateLimitFromConditions() | 
|---|
array
stringName of the table to prefix the state and user fields with
stringName of the field that holds the state
stringName of the field that holds the user ID
stringSQL condition to limit stateresetLocalCacheData($name)
This can be used if you know when some cached data has expired.
| inherited_from | \XenForo_Model::resetLocalCacheData() | 
|---|
setAllowCachedRead(boolean $allowCachedRead)
This may be controllable on an individual level basis, if the implementation allows it.
| inherited_from | \XenForo_Model::setAllowCachedRead() | 
|---|
boolean
setLocalCacheData(string $name, $value)
This should only be used if you know what you're doing or for testing purposes!
Note that you cannot get the existing data via the public interface. If you think you need the set data, use a new object. It defaults to empty. :)
| inherited_from | \XenForo_Model::setLocalCacheData() | 
|---|
string
standardizeNodePermissionsAndUserId(integer $nodeId, array | null $permissions, integer | null $userId)
If an invalid permission set or user ID is provided, the current visitor's will be used.
| inherited_from | \XenForo_Model::standardizeNodePermissionsAndUserId() | 
|---|
integerNode permissions are for
arraynullPermissions for node or null to use current visitor's permissions
integernullUser permissions belong to or null to use current visitor
standardizePermissionCombinationIdAndUserId(integer | null $permissionCombinationId, integer | null $userId)
If null, users current visitor's values.
| inherited_from | \XenForo_Model::standardizePermissionCombinationIdAndUserId() | 
|---|
integernullPermission combination ID or null to use current visitor
integernullUser permissions belong to or null to use current visitor
standardizePermissionsAndUserId(array | null $permissions, integer | null $userId)
If an invalid permission set or user ID is provided, the current visitor's will be used.
| inherited_from | \XenForo_Model::standardizePermissionsAndUserId() | 
|---|
arraynullGlobal pPermissions or null to use current visitor's permissions
integernullUser permissions belong to or null to use current visitor
standardizeViewingUserReference(array $viewingUser)
This array must contain all basic user info (preferably all user info) and include global permissions in a "permissions" key. If not an array or missing a user_id, the visitor's values will be used.
| inherited_from | \XenForo_Model::standardizeViewingUserReference() | 
|---|
arraynull
standardizeViewingUserReferenceForNode(integer $nodeId, array $viewingUser, array $nodePermissions)
| inherited_from | \XenForo_Model::standardizeViewingUserReferenceForNode() | 
|---|
integer
arraynullViewing user; if null, use visitor
arraynullPermissions for this node; if null, use visitor's
unserializePermissionsInList(array $items, string $serializedKey, string $targetKey) : array
| inherited_from | \XenForo_Model::unserializePermissionsInList() | 
|---|
arrayList of items
stringKey where serialized permissions are
stringKey where unserialized permissions will go
arrayList of items with permissions unserialized_getCache(boolean $forceCachedRead) : \Zend_Cache_Core | \Zend_Cache_Frontend | false
If cache reads are disabled, this will return false.
| inherited_from | \XenForo_Model::_getCache() | 
|---|
booleanIf true, the global "allow cached read" value is ignored
\Zend_Cache_Core\Zend_Cache_Frontendfalse
_getDb() : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_Model::_getDb() | 
|---|
\Zend_Db_Adapter_Abstract_getLocalCacheData(string $name) : mixed
| inherited_from | \XenForo_Model::_getLocalCacheData() | 
|---|
string
mixed$_allowCachedRead : boolean
If not, it should be retrieved from the source.
| inherited_from | \XenForo_Model::$$_allowCachedRead | 
|---|
$_cache : \Zend_Cache_Core | \Zend_Cache_Frontend
| inherited_from | \XenForo_Model::$$_cache | 
|---|
$_db : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_Model::$$_db | 
|---|
$_localCacheData : array
This data is generally treated as canonical, even if {$_allowCachedRead} is false.
| inherited_from | \XenForo_Model::$$_localCacheData | 
|---|
$_modelCache : array
| inherited_from | \XenForo_Model::$$_modelCache | 
|---|