Model for profile post related functions.

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_ProfilePost

 Methods

Constructor.

__construct() 
Inherited

Use create() statically unless you know what you're doing.

inherited_from \XenForo_Model::__construct()

Adds a join to the set of fetch options.

addFetchOptionJoin(array $fetchOptions, integer $join) 
Inherited

Join should be one of the constants.

inherited_from \XenForo_Model::addFetchOptionJoin()

Parameters

$fetchOptions

array

$join

integer

Adds the inline mod option to a profile post.

addInlineModOptionToProfilePost(array $profilePost, array $user, array $viewingUser) : array

Parameters

$profilePost

array

Profile post. By reference; canInlineMod key added

$user

array

$viewingUser

arraynull

Returns

arrayList of inline mod options the user can do

Adds the inline mod option to a batch of profile posts.

addInlineModOptionToProfilePosts(array $profilePosts, array $user, array $viewingUser) : array

Parameters

$profilePosts

array

Batch of profile posts. By reference; all modified to add canInlineMod key

$user

array

$viewingUser

arraynull

Returns

arrayList of inline mod options the user can do on at least one post

Adds the equivalent of a limit clause using position-based limits.

addPositionLimit(string $table, integer $limit, integer $offset, string $column) : string
Inherited

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()

Parameters

$table

string

Name of the table alias to prefix. May be blank for no table reference.

$limit

integer

Number of records to limit to; ignored if <= 0

$offset

integer

Offset from the start of the records. 0+

$column

string

Name of the column that is storing the position

Returns

stringPosition limit clause if needed

Merges comments into existing profile post data.

addProfilePostCommentsToProfilePosts(array $profilePosts, array $fetchOptions) : array

Parameters

$profilePosts

array

$fetchOptions

array

Returns

arrayPosts with comments merged

Ensures that a valid cut-off operator is passed.

assertValidCutOffOperator(string $operator) 
Inherited

inherited_from \XenForo_Model::assertValidCutOffOperator()

Parameters

$operator

string

Determines if the given profile post can be approved/unapproved.

canApproveUnapproveProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post can be commented on.

canCommentOnProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post can be deleted.

canDeleteProfilePost(array $profilePost, array $user, string $deleteType, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$profilePost

array

$user

array

$deleteType

string

Type of deletion (soft or hard)

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post comment can be deleted.

canDeleteProfilePostComment(array $comment, array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$comment

array

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post can be edited.

canEditProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the profile post can be liked with the given permissions.

canLikeProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check profile post viewing permissions.

Parameters

$profilePost

array

Profile post info

$user

array

User info for where profile post is posted

$errorPhraseKey

string

Returned phrase key for a specific error

$viewingUser

arraynull

Returns

boolean

Checks that the viewing user may report the specified profile post

canReportProfilePost(array $profilePost, array $user, boolean $errorPhraseKey, array $viewingUser) : boolean

Parameters

$profilePost

array

$user

array

$errorPhraseKey

boolean

string

$viewingUser

arraynull

Returns

boolean

Determines if the given profile post can be undeleted.

canUndeleteProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the viewing user can view the IP of the stated profile post

canViewIps(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post can be viewed.

canViewProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check user profile viewing permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post can be viewed.

canViewProfilePostAndContainer(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This checks parent permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Determines if the given profile post can be warned.

canWarnProfilePost(array $profilePost, array $user, string $errorPhraseKey, array $viewingUser) : boolean

This does not check parent (viewing) permissions.

Parameters

$profilePost

array

$user

array

$errorPhraseKey

string

By ref. More specific error, if available.

$viewingUser

arraynull

Viewing user reference

Returns

boolean

Counts the profile posts that were left for the specified user (with the given conditions).

countProfilePostsForUserId(integer $userId, array $conditions) : integer

Parameters

$userId

integer

$conditions

array

Returns

integer

Factory method to get the named model.

create(string $class) : \XenForo_Model
Inherited

The class must exist or be autoloadable or an exception will be thrown.

inherited_from \XenForo_Model::create()

Parameters

$class

string

Class to load

Returns

Fetches results from the database with each row keyed according to preference.

fetchAllKeyed(string $sql, string $key, mixed $bind, string $nullPrefix) : array
Inherited

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()

Parameters

$sql

string

SQL to execute

$key

string

Column with which to key the results array

$bind

mixed

Parameters for the SQL

$nullPrefix

string

If the key is null, prefix the counter with this

Returns

array

Gets a list of SQL conditions in the format for a clause.

getConditionsForClause(array $sqlConditions) : string
Inherited

This always returns a value that can be used in a clause such as WHERE.

inherited_from \XenForo_Model::getConditionsForClause()

Parameters

$sqlConditions

array

Returns

string

Gets the specified field from a content type, if specified for that type.

getContentTypeField(string $contentType, string $fieldName) : string | false
Inherited

inherited_from \XenForo_Model::getContentTypeField()

Parameters

$contentType

string

$fieldName

string

Returns

stringfalse

Gets the value of the specified field for each content type that has that field.

getContentTypesWithField(string $fieldName) : array
Inherited

inherited_from \XenForo_Model::getContentTypesWithField()

Parameters

$fieldName

string

Returns

arrayFormat: [content type] => field value

Gets the specified model object from the cache.

getModelFromCache(string $class) : \XenForo_Model
Inherited

If it does not exist, it will be instantiated.

inherited_from \XenForo_Model::getModelFromCache()

Parameters

$class

string

Name of the class to load

Returns

Gets the order by clause for an SQL query.

getOrderByClause(array $choices, array $fetchOptions, string $defaultOrderSql) : string
Inherited

inherited_from \XenForo_Model::getOrderByClause()

Parameters

$choices

array

$fetchOptions

array

$defaultOrderSql

string

Returns

stringOrder by clause or empty string

Gets permission-based conditions that apply to profile post fetching functions.

getPermissionBasedProfilePostConditions(array $user, array $viewingUser) : array

Parameters

$user

array

User the profile posts will belong to

$viewingUser

arraynull

Viewing user ref; defaults to visitor

Returns

arrayKeys: deleted (boolean), moderated (boolean, integer if can only view specific user ID)

Gets the specified profile post.

getProfilePostById(integer $id, array $fetchOptions) : array | false

Parameters

$id

integer

$fetchOptions

array

Returns

arrayfalse

Gets the specified profile post comment.

getProfilePostCommentById(integer $profilePostCommentId, array $fetchOptions) : array | false

Parameters

$profilePostCommentId

integer

$fetchOptions

array

Returns

arrayfalse

Gets the user IDs that have commented on a profile post.

getProfilePostCommentUserIds(integer $profilePostId) : array

Parameters

$profilePostId

integer

Returns

array

Gets the profile post comments with the specified IDs.

getProfilePostCommentsByIds(array $ids, array $fetchOptions) : array

Parameters

$ids

array

$fetchOptions

array

Returns

array[id] => info

Gets all comments that belong to the specified post.

getProfilePostCommentsByProfilePost(integer $profilePostId, integer $beforeDate, array $fetchOptions) : array

If a limit is specified, more recent comments are returned.

Parameters

$profilePostId

integer

$beforeDate

integer

If specified, gets posts before specified date only

$fetchOptions

array

Returns

array[id] => info

Gets the profile post comments make by a particular user.

getProfilePostCommentsByUserId($userId, array $fetchOptions) : array

Parameters

$userId

$fetchOptions

array

Returns

array[id] => info

Gets profile post IDs in the specified range.

getProfilePostIdsInRange(integer $start, integer $limit) : array

The IDs returned will be those immediately after the "start" value (not including the start), up to the specified limit.

Parameters

$start

integer

IDs greater than this will be returned

$limit

integer

Number of posts to return

Returns

arrayList of IDs

Gets the message state for a newly inserted profile post by the viewing user.

getProfilePostInsertMessageState(array $user, array $viewingUser) : string

Parameters

$user

array

User whose profile is being posted on

$viewingUser

arraynull

Returns

stringMessage state (visible, moderated, deleted)

Fetch view parameters for profile posts, primarily for meta controls like warn, view IPs etc.

getProfilePostViewParams(array $profilePosts, array $user, array $viewingUser) : array

Parameters

$profilePosts

array

$user

array

(owner of the profile on which the profile posts are shown)

$viewingUser

array

Returns

array

Gets the specified profile posts.

getProfilePostsByIds(array $messageIds, array $fetchOptions) : array

Parameters

$messageIds

array

$fetchOptions

array

Returns

array[profile post id] => info

Fetches all profile posts posted by the specified user, on their own and others' profile pages.

getProfilePostsByUserId(integer $userId, array $fetchOptions) : array

Parameters

$userId

integer

$fetchOptions

array

Returns

array

Gets profile posts for the specified user that meet the given conditions.

getProfilePostsForUserId(integer $userId, array $conditions, array $fetchOptions) : array

Parameters

$userId

integer

$conditions

array

$fetchOptions

array

Returns

array[profile post id] => info

Extracts the data relating to a profile owner user from a profile post, that has been fetched with XenForo_Model_ProfilePost::FETCH_USER_RECEIVER

getProfileUserFromProfilePost(array $profilePost, array $viewingUser) : array

Parameters

$profilePost

array

$viewingUser

Returns

array

Applies a limit clause to the provided query if a limit value is specified.

limitQueryResults(string $query, integer $limit, integer $offset) : string
Inherited

If the limit value is 0 or less, no clause is applied.

inherited_from \XenForo_Model::limitQueryResults()

Parameters

$query

string

SQL query to run

$limit

integer

Number of records to limit to; ignored if <= 0

$offset

integer

Offset from the start of the records. 0+

Returns

stringQuery with limit applied if necessary

Prepares the limit-related fetching options that can be applied to various queries.

prepareLimitFetchOptions(array $fetchOptions) : array
Inherited

Includes: limit, offset, page, and perPage.

inherited_from \XenForo_Model::prepareLimitFetchOptions()

Parameters

$fetchOptions

array

Unprepared options

Returns

arrayLimit options; keys: limit, offset

Prepares a profile post.

prepareProfilePost(array $profilePost, array $user, array $viewingUser) : array

Parameters

$profilePost

array

$user

array

User whose profile the post is on

$viewingUser

arraynull

Viewing user reference

Returns

array

Prepares a profile post comment for display.

prepareProfilePostComment(array $comment, array $profilePost, array $user, array $viewingUser) : array

Parameters

$comment

array

$profilePost

array

$user

array

$viewingUser

arraynull

Returns

array

Prepares the fetching options for profile post comments.

prepareProfilePostCommentFetchOptions(array $fetchOptions) : array

Parameters

$fetchOptions

array

Returns

array

Prepares a collection of profile post fetching related conditions into an SQL clause

prepareProfilePostConditions(array $conditions, array $fetchOptions) : string

Parameters

$conditions

array

List of conditions

$fetchOptions

array

Modifiable set of fetch options (may have joins pushed on to it)

Returns

stringSQL clause (at least 1=1)

Checks the 'join' key of the incoming array for the presence of the FETCH_x bitfields in this class and returns SQL snippets to join the specified tables if required

prepareProfilePostFetchOptions(array $fetchOptions) : array

Parameters

$fetchOptions

array

containing a 'join' integer key build from this class's FETCH_x bitfields

Returns

arrayContaining 'selectFields' and 'joinTables' keys. Example: selectFields = ', user.*, foo.title'; joinTables = ' INNER JOIN foo ON (foo.id = other.id) '

Prepares a batch of profile posts.

prepareProfilePosts(array $profilePosts, array $user, array $viewingUser) : array

Parameters

$profilePosts

array

$user

array

User whose profile the post is on

$viewingUser

arraynull

Viewing user reference

Returns

array

Prepares state related fetch limits, based on the list of conditions.

prepareStateLimitFromConditions(array $fetchOptions, string $table, string $stateField, string $userField) : string
Inherited

Looks for keys "deleted" and "moderated".

inherited_from \XenForo_Model::prepareStateLimitFromConditions()

Parameters

$fetchOptions

array

$table

string

Name of the table to prefix the state and user fields with

$stateField

string

Name of the field that holds the state

$userField

string

Name of the field that holds the user ID

Returns

stringSQL condition to limit state

Reset an entry or the entire local cache.

resetLocalCacheData($name) 
Inherited

This can be used if you know when some cached data has expired.

inherited_from \XenForo_Model::resetLocalCacheData()

Parameters

$name

Sets whether we're allowed to read values from the cache on a model-level.

setAllowCachedRead($allowCachedRead) 
Inherited

This may be controllable on an individual level basis, if the implementation allows it.

inherited_from \XenForo_Model::setAllowCachedRead()

Parameters

$allowCachedRead

boolean

Injects a local cache value.

setLocalCacheData(string $name, $value) 
Inherited

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()

Parameters

$name

string

$value

Standardizes a set of node permissions and a user ID to always have appropriate data.

standardizeNodePermissionsAndUserId(integer $nodeId, array | null $permissions, integer | null $userId) 
Inherited

If an invalid permission set or user ID is provided, the current visitor's will be used.

inherited_from \XenForo_Model::standardizeNodePermissionsAndUserId()

Parameters

$nodeId

integer

Node permissions are for

$permissions

arraynull

Permissions for node or null to use current visitor's permissions

$userId

integernull

User permissions belong to or null to use current visitor

Standardizes a permission combination and user ID to always have appropriate data.

standardizePermissionCombinationIdAndUserId(integer | null $permissionCombinationId, integer | null $userId) 
Inherited

If null, users current visitor's values.

inherited_from \XenForo_Model::standardizePermissionCombinationIdAndUserId()

Parameters

$permissionCombinationId

integernull

Permission combination ID or null to use current visitor

$userId

integernull

User permissions belong to or null to use current visitor

Standardizes a set of permissions and a user ID to always have appropriate data.

standardizePermissionsAndUserId(array | null $permissions, integer | null $userId) 
Inherited

If an invalid permission set or user ID is provided, the current visitor's will be used.

inherited_from \XenForo_Model::standardizePermissionsAndUserId()

Parameters

$permissions

arraynull

Global pPermissions or null to use current visitor's permissions

$userId

integernull

User permissions belong to or null to use current visitor

Standardizes a viewing user reference array.

standardizeViewingUserReference(array $viewingUser) 
Inherited

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()

Parameters

$viewingUser

arraynull

Standardizes the viewing user reference for the specific node.

standardizeViewingUserReferenceForNode(integer $nodeId, array $viewingUser, array $nodePermissions) 
Inherited

inherited_from \XenForo_Model::standardizeViewingUserReferenceForNode()

Parameters

$nodeId

integer

$viewingUser

arraynull

Viewing user; if null, use visitor

$nodePermissions

arraynull

Permissions for this node; if null, use visitor's

Helper to unserialize permissions in a list of items.

unserializePermissionsInList(array $items, string $serializedKey, string $targetKey) : array
Inherited

inherited_from \XenForo_Model::unserializePermissionsInList()

Parameters

$items

array

List of items

$serializedKey

string

Key where serialized permissions are

$targetKey

string

Key where unserialized permissions will go

Returns

arrayList of items with permissions unserialized

Helper method to get the cache object.

_getCache(boolean $forceCachedRead) : \Zend_Cache_Core | \Zend_Cache_Frontend | false
Inherited

If cache reads are disabled, this will return false.

inherited_from \XenForo_Model::_getCache()

Parameters

$forceCachedRead

boolean

If true, the global "allow cached read" value is ignored

Returns

\Zend_Cache_Core\Zend_Cache_Frontendfalse

Gets the data registry model.

_getDataRegistryModel() : \XenForo_Model_DataRegistry
Inherited

inherited_from \XenForo_Model::_getDataRegistryModel()

Returns

Helper method to get the database object.

_getDb() : \Zend_Db_Adapter_Abstract
Inherited

inherited_from \XenForo_Model::_getDb()

Returns

\Zend_Db_Adapter_Abstract

Gets the named entry from the local cache.

_getLocalCacheData(string $name) : mixed
Inherited

inherited_from \XenForo_Model::_getLocalCacheData()

Parameters

$name

string

Returns

mixed

_getUserModel()

_getUserModel() : \XenForo_Model_User

_getUserProfileModel()

_getUserProfileModel() : \XenForo_Model_UserProfile

 Properties

 

Controls whether a cached read is allowed.

$_allowCachedRead : boolean
Inherited

If not, it should be retrieved from the source.

inherited_from \XenForo_Model::$$_allowCachedRead
 

Cache object

$_cache : \Zend_Cache_Core | \Zend_Cache_Frontend
Inherited

inherited_from \XenForo_Model::$$_cache
 

Database object

$_db : \Zend_Db_Adapter_Abstract
Inherited

inherited_from \XenForo_Model::$$_db
 

Stores local, instance-specific cached data for each model.

$_localCacheData : array
Inherited

This data is generally treated as canonical, even if {$_allowCachedRead} is false.

inherited_from \XenForo_Model::$$_localCacheData
 

Standard approach to caching other model objects for the lifetime of the model.

$_modelCache : array
Inherited

inherited_from \XenForo_Model::$$_modelCache

 Constants

 

Constant for fetching the info about the comment user.

FETCH_COMMENT_USER : integer

 

FETCH_DELETION_LOG

FETCH_DELETION_LOG 

 

Constants to allow joins to extra tables in certain queries

FETCH_USER_POSTER : integer: integer: integer: integer

 

FETCH_USER_RECEIVER

FETCH_USER_RECEIVER 

 

FETCH_USER_RECEIVER_PRIVACY

FETCH_USER_RECEIVER_PRIVACY