PHP Class CommentModel, vanilla

Inheritance: extends Model
ファイルを表示 Open project: vanilla/vanilla Class Usage Examples

Public Properties

Property Type Description
$pageCache boolean

Protected Properties

Property Type Description
$_OrderBy List of fields to order results by.
$_Where Wheres.

Public Methods

Method Description
__construct ( ) Class constructor. Defines the related database table name.
cachePageWhere ( $Result, $PageWhere, $DiscussionID, $Page, null $Limit = null )
calculate ( $Comment ) Modifies comment data before it is returned.
commentQuery ( boolean $FireEvent = true, $Join = true ) Select the data for a single comment.
delete ( $where = [], $options = [] ) Delete a comment.
deleteID ( integer $CommentID, array $Options = [] ) Delete a comment.
get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $PageNumber = false )
getByDiscussion ( integer $DiscussionID, integer $Limit, integer $Offset ) : Gdn_DataSet Get comments for a discussion.
getByUser ( integer $UserID, integer $Limit, integer $Offset ) : object Get comments for a user.
getByUser2 ( integer $UserID, integer $Limit, integer $Offset, integer $LastCommentID = false ) : Gdn_DataSet Get comments for a user. This is an optimized version of CommentModel->GetByUser().
getCount ( $Wheres = '' )
getCountByDiscussion ( integer $DiscussionID ) : object Count total comments in a discussion specified by ID.
getCountWhere ( array $Where = false ) : object Count total comments in a discussion specified by $Where conditions.
getID ( integer $CommentID, string $ResultType = DATASET_TYPE_OBJECT, array $Options = [] ) : mixed Get single comment by ID. Allows you to pick data format of return value.
getIDData ( integer $CommentID, $Options = [] ) : object Get single comment by ID as SQL result data.
getNew ( integer $DiscussionID, integer $LastCommentID ) : object Get comments in a discussion since the specified one.
getOffset ( mixed $Comment ) : object Gets the offset of the specified comment in its related discussion.
getUnreadOffset ( $DiscussionID, $UserID = null )
getUserScore ( integer $CommentID, integer $UserID ) : integer Gets the UserComment Score value for the specified user.
orderBy ( $Value = null ) : array Set the order of the comments or return current order.
pageWhere ( $DiscussionID, $Page, $Limit )
recordAdvancedNotications ( ActivityModel $ActivityModel, array $Activity, array $Discussion ) Record advanced notifications for users.
removePageCache ( $DiscussionID, $From = 1 )
save ( array $FormPostValues, array $Settings = false ) : integer Insert or update core data about the comment.
save2 ( array $CommentID, integer $Insert, boolean $CheckExisting = true, boolean $IncUser = false ) Insert or update meta data about the comment.
setCalculatedFields ( object &$Data ) Modifies comment data before it is returned.
setUserScore ( integer $CommentID, integer $UserID, integer $Score ) : integer Sets the UserComment Score value.
setWatch ( object $Discussion, integer $Limit, integer $Offset, integer $TotalComments ) Record the user's watch data.
updateCommentCount ( $Discussion, array $Options = [] ) Updates the CountComments value on the discussion based on the CommentID being saved.
updateUser ( integer $UserID, $Inc = false ) Update user's total comment count.
updateUserCommentCounts ( integer $DiscussionID ) Update UserDiscussion so users don't have incorrect counts.
where ( $Value = null )

Protected Methods

Method Description
_WhereFromOrderBy ( array $Part, object $Comment, string $Op = '' ) : array Builds Where statements for GetOffset method.

Method Details

_WhereFromOrderBy() protected method

Builds Where statements for GetOffset method.
See also: CommentModel::GetOffset()
Since: 2.0.0
protected _WhereFromOrderBy ( array $Part, object $Comment, string $Op = '' ) : array
$Part array Value from $this->_OrderBy.
$Comment object
$Op string Comparison operator.
return array Expression and value.

__construct() public method

Class constructor. Defines the related database table name.
Since: 2.0.0
public __construct ( )

cachePageWhere() public method

public cachePageWhere ( $Result, $PageWhere, $DiscussionID, $Page, null $Limit = null )
$Result
$PageWhere
$DiscussionID
$Page
$Limit null

calculate() public method

Modifies comment data before it is returned.
Since: 2.1a32
public calculate ( $Comment )

commentQuery() public method

Select the data for a single comment.
Since: 2.0.0
public commentQuery ( boolean $FireEvent = true, $Join = true )
$FireEvent boolean Kludge to fix VanillaCommentReplies plugin.

delete() public method

public delete ( $where = [], $options = [] )

deleteID() public method

This is a hard delete that completely removes it from the database. Events: DeleteComment, BeforeDeleteComment.
Since: 2.0.0
public deleteID ( integer $CommentID, array $Options = [] )
$CommentID integer Unique ID of the comment to be deleted.
$Options array Additional options for the delete.

get() public method

public get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $PageNumber = false )

getByDiscussion() public method

Get comments for a discussion.
public getByDiscussion ( integer $DiscussionID, integer $Limit, integer $Offset ) : Gdn_DataSet
$DiscussionID integer Which discussion to get comment from.
$Limit integer Max number to get.
$Offset integer Number to skip.
return Gdn_DataSet Returns a list of comments.

getByUser() public method

Get comments for a user.
Since: 2.0.17
public getByUser ( integer $UserID, integer $Limit, integer $Offset ) : object
$UserID integer Which user to get comments for.
$Limit integer Max number to get.
$Offset integer Number to skip.
return object SQL results.

getByUser2() public method

Get comments for a user. This is an optimized version of CommentModel->GetByUser().
Since: 2.1
public getByUser2 ( integer $UserID, integer $Limit, integer $Offset, integer $LastCommentID = false ) : Gdn_DataSet
$UserID integer Which user to get comments for.
$Limit integer Max number to get.
$Offset integer Number to skip.
$LastCommentID integer A hint for quicker paging.
return Gdn_DataSet SQL results.

getCount() public method

public getCount ( $Wheres = '' )

getCountByDiscussion() public method

Events: BeforeGetCount
public getCountByDiscussion ( integer $DiscussionID ) : object
$DiscussionID integer Unique ID of discussion we're counting comments from.
return object SQL result.

getCountWhere() public method

Count total comments in a discussion specified by $Where conditions.
Since: 2.0.0
public getCountWhere ( array $Where = false ) : object
$Where array Conditions
return object SQL result.

getID() public method

Get single comment by ID. Allows you to pick data format of return value.
Since: 2.0.0
public getID ( integer $CommentID, string $ResultType = DATASET_TYPE_OBJECT, array $Options = [] ) : mixed
$CommentID integer Unique ID of the comment.
$ResultType string Format to return comment in.
$Options array options to pass to the database.
return mixed SQL result in format specified by $ResultType.

getIDData() public method

Get single comment by ID as SQL result data.
Since: 2.0.0
public getIDData ( integer $CommentID, $Options = [] ) : object
$CommentID integer Unique ID of the comment.
return object SQL result.

getNew() public method

Events: BeforeGetNew
Since: 2.0.0
public getNew ( integer $DiscussionID, integer $LastCommentID ) : object
$DiscussionID integer Unique ID of the discusion.
$LastCommentID integer Unique ID of the comment.
return object SQL result.

getOffset() public method

Events: BeforeGetOffset
Since: 2.0.0
public getOffset ( mixed $Comment ) : object
$Comment mixed Unique ID or or a comment object for which the offset is being defined.
return object SQL result.

getUnreadOffset() public method

public getUnreadOffset ( $DiscussionID, $UserID = null )

getUserScore() public method

Gets the UserComment Score value for the specified user.
Since: 2.0.0
public getUserScore ( integer $CommentID, integer $UserID ) : integer
$CommentID integer Unique ID of comment we're getting the score for.
$UserID integer Unique ID of user who scored the comment.
return integer Current score for the comment.

orderBy() public method

Getter/setter for $this->_OrderBy.
Since: 2.0.0
public orderBy ( $Value = null ) : array
return array $this->_OrderBy (optionally).

pageWhere() public method

public pageWhere ( $DiscussionID, $Page, $Limit )

recordAdvancedNotications() public method

Record advanced notifications for users.
public recordAdvancedNotications ( ActivityModel $ActivityModel, array $Activity, array $Discussion )
$ActivityModel ActivityModel
$Activity array
$Discussion array

removePageCache() public method

public removePageCache ( $DiscussionID, $From = 1 )

save() public method

Events: BeforeSaveComment, AfterValidateComment, AfterSaveComment.
Since: 2.0.0
public save ( array $FormPostValues, array $Settings = false ) : integer
$FormPostValues array Data from the form model.
$Settings array Currently unused.
return integer $CommentID

save2() public method

Updates unread comment totals, bookmarks, and activity. Sends notifications.
Since: 2.0.0
public save2 ( array $CommentID, integer $Insert, boolean $CheckExisting = true, boolean $IncUser = false )
$CommentID array Unique ID for this comment.
$Insert integer Used as a boolean for whether this is a new comment.
$CheckExisting boolean Not used.
$IncUser boolean Whether or not to just increment the user's comment count rather than recalculate it.

setCalculatedFields() public method

Modifies comment data before it is returned.
Since: 2.1a32
public setCalculatedFields ( object &$Data )
$Data object SQL result.

setUserScore() public method

Sets the UserComment Score value.
Since: 2.0.0
public setUserScore ( integer $CommentID, integer $UserID, integer $Score ) : integer
$CommentID integer Unique ID of comment we're setting the score for.
$UserID integer Unique ID of user scoring the comment.
$Score integer Score being assigned to the comment.
return integer New total score for the comment.

setWatch() public method

Record the user's watch data.
Since: 2.0.0
public setWatch ( object $Discussion, integer $Limit, integer $Offset, integer $TotalComments )
$Discussion object Discussion being watched.
$Limit integer Max number to get.
$Offset integer Number to skip.
$TotalComments integer Total in entire discussion (hard limit).

updateCommentCount() public method

Events: BeforeUpdateCommentCount.
Since: 2.0.0
Since: 2.3 Added the $Options parameter.
public updateCommentCount ( $Discussion, array $Options = [] )
$Options array

updateUser() public method

Update user's total comment count.
Since: 2.0.0
public updateUser ( integer $UserID, $Inc = false )
$UserID integer Unique ID of the user to be updated.

updateUserCommentCounts() public method

Update UserDiscussion so users don't have incorrect counts.
Since: 2.0.18
public updateUserCommentCounts ( integer $DiscussionID )
$DiscussionID integer Unique ID of the discussion we are updating.

where() public method

public where ( $Value = null )

Property Details

$_OrderBy protected_oe property

List of fields to order results by.
protected $_OrderBy

$_Where protected_oe property

Wheres.
protected $_Where

$pageCache public_oe property

public bool $pageCache
return boolean