PHP Class ConversationMessageModel, vanilla

Inheritance: extends ConversationsModel
Show file Open project: vanilla/vanilla Class Usage Examples

Public Methods

Method Description
__construct ( ) Class constructor. Defines the related database table name.
get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $PageNumber = false )
getCount ( $wheres = [] )
getCountByConversation ( integer $ConversationID, integer $ViewingUserID, array $Wheres = '' ) : integer Get number of messages in a conversation.
getCountWhere ( array $Wheres = '' ) : integer Get number of messages that meet criteria.
getID ( mixed $ID, string $DatasetType = false, array $options = [] ) : Gdn_DataSet Get the data from the model based on its primary key.
getNew ( integer $ConversationID, integer $LastMessageID ) : Gdn_DataSet Get only new messages from conversation.
getRecent ( integer $ConversationID, integer $ViewingUserID, integer $Offset = '0', integer $Limit = '', array $Wheres = '' ) : Gdn_DataSet Get messages by conversation.
instance ( ) Return the singleton instance of this class.
save ( array $FormPostValues, $Conversation = null, $Options = [] ) : integer Save message from form submission.
validate ( array $FormPostValues, boolean $Insert = false ) : boolean

Method Details

__construct() public method

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

get() public method

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

getCount() public method

Deprecation:
public getCount ( $wheres = [] )

getCountByConversation() public method

Get number of messages in a conversation.
Since: 2.0.0
public getCountByConversation ( integer $ConversationID, integer $ViewingUserID, array $Wheres = '' ) : integer
$ConversationID integer Unique ID of conversation being viewed.
$ViewingUserID integer Unique ID of current user.
$Wheres array SQL conditions.
return integer Number of messages.

getCountWhere() public method

Get number of messages that meet criteria.
Since: 2.0.0
public getCountWhere ( array $Wheres = '' ) : integer
$Wheres array SQL conditions.
return integer Number of messages.

getID() public method

Get the data from the model based on its primary key.
public getID ( mixed $ID, string $DatasetType = false, array $options = [] ) : Gdn_DataSet
$ID mixed The value of the primary key in the database.
$DatasetType string The format of the result dataset.
$options array Not used.
return Gdn_DataSet

getNew() public method

Get only new messages from conversation.
Since: 2.0.0
public getNew ( integer $ConversationID, integer $LastMessageID ) : Gdn_DataSet
$ConversationID integer Unique ID of conversation being viewed.
$LastMessageID integer Unique ID of last message to be viewed.
return Gdn_DataSet SQL results.

getRecent() public method

Events: BeforeGet.
Since: 2.0.0
public getRecent ( integer $ConversationID, integer $ViewingUserID, integer $Offset = '0', integer $Limit = '', array $Wheres = '' ) : Gdn_DataSet
$ConversationID integer Unique ID of conversation being viewed.
$ViewingUserID integer Unique ID of current user.
$Offset integer Number to skip.
$Limit integer Maximum to return.
$Wheres array SQL conditions.
return Gdn_DataSet SQL results.

instance() public static method

Return the singleton instance of this class.
public static instance ( )

save() public method

Save message from form submission.
Since: 2.0.0
public save ( array $FormPostValues, $Conversation = null, $Options = [] ) : integer
$FormPostValues array Values submitted via form.
return integer Unique ID of message created or updated.

validate() public method

public validate ( array $FormPostValues, boolean $Insert = false ) : boolean
$FormPostValues array
$Insert boolean
return boolean