Documentation

Chat
in package

Chat class.

Table of Contents

ALLOWED_ROOM_TYPES  = ['crm', 'group', 'global', 'private', 'user']
Information about allowed types of rooms.
COLUMN_NAME  = ['message' => ['crm' => 'crmid', 'group' => 'groupid', 'global' => 'globalid', 'private' => 'privateid', 'user' => 'roomid'], 'room' => ['crm' => 'crmid', 'group' => 'groupid', 'global' => 'global_room_id', 'private' => 'private_room_id', 'user' => 'roomid'], 'room_name' => ['crm' => 'label', 'group' => 'groupname', 'global' => 'name', 'private' => 'name', 'user' => 'roomid']]
Information about the columns of the database.
TABLE_NAME  = ['message' => ['crm' => 'u_#__chat_messages_crm', 'group' => 'u_#__chat_messages_group', 'global' => 'u_#__chat_messages_global', 'private' => 'u_#__chat_messages_private', 'user' => 'u_#__chat_messages_user'], 'room' => ['crm' => 'u_#__chat_rooms_crm', 'group' => 'u_#__chat_rooms_group', 'global' => 'u_#__chat_rooms_global', 'private' => 'u_#__chat_rooms_private', 'user' => 'u_#__chat_rooms_user'], 'room_name' => ['crm' => 'u_#__crmentity_label', 'group' => 'vtiger_groups', 'global' => 'u_#__chat_global', 'private' => 'u_#__chat_private', 'user' => 'u_#__chat_user'], 'users' => 'vtiger_users']
Information about the tables of the database.
$recordId  : int|null
ID record associated with the chat room.
$roomType  : string
Type of chat room.
$lastMessageId  : int|null
Last message ID.
$room  : array<string|int, mixed>|false
$userId  : int
User ID.
__construct()  : mixed
Chat constructor.
addMessage()  : int
Add new message to chat room.
addParticipantToPrivate()  : bool
Add participant to private room.
addToFavorites()  : mixed
Add room to favorites.
addToFavoritesQuery()  : mixed
Add room to favorites query.
archivePrivateRoom()  : mixed
Archive private room.
createPrivateRoom()  : mixed
Create private room.
createRoom()  : Chat
Create chat room.
createUserRoom()  : int
Create user room.
getActiveRoomTypes()  : array<string|int, mixed>
Get active room types.
getChatModules()  : array<string|int, mixed>
Get chat modules.
getChatUsers()  : array<string|int, mixed>
Get chat users.
getCurrentRoom()  : array<string|int, mixed>|false
Get current room ID, type.
getDefaultRoom()  : array<string|int, mixed>|false
Get default room.
getEntries()  : array<string|int, mixed>
Get entries function.
getHistoryByType()  : array<string|int, mixed>
Get history by type.
getInstance()  : Chat
Get instance \App\Chat.
getNumberOfNewMessages()  : array<string|int, mixed>
Rerun the number of new messages.
getParticipants()  : array<string|int, mixed>
Get getParticipants.
getQueryRoom()  : Query
Get a query for chat room.
getRecordId()  : int|null
Get record ID.
getRoomLastMessage()  : array<string|int, mixed>
Get room last message.
getRoomPrivateUnpinnedUsers()  : array<string|int, mixed>
List of unpinned users to private room.
getRoomsByUser()  : array<string|int, mixed>
Get all chat rooms by user.
getRoomsCrm()  : array<string|int, mixed>
CRM list of chat rooms.
getRoomsGlobal()  : array<string|int, mixed>
List global chat rooms.
getRoomsGlobalUnpinned()  : array<string|int, mixed>
List unpinned global chat rooms.
getRoomsGroup()  : array<string|int, mixed>
List of chat room groups.
getRoomsGroupUnpinned()  : array<string|int, mixed>
Get rooms group unpinned.
getRoomsPrivate()  : array<string|int, mixed>
List of private chat rooms.
getRoomsPrivateUnpinned()  : array<string|int, mixed>
List of unpinned private chat rooms.
getRoomsUnpinnedQuery()  : object
Create query for unpinned rooms.
getRoomsUser()  : array<string|int, mixed>
Get rooms user unpinned.
getRoomsUserUnpinned()  : array<string|int, mixed>
Get rooms user unpinned.
getRoomsUserUnpinnedQuery()  : object
Get rooms user unpinned query.
getRoomType()  : string|null
Get room type.
getRoomTypeLastMessage()  : array<string|int, mixed>
Get room type last message.
getUnreadByType()  : array<string|int, mixed>
Get unread messages.
getUserInfo()  : array<string|int, mixed>
Get user info.
isAssigned()  : bool
Is the user assigned to the chat room.
isNewMessages()  : bool
Is there any new message.
isNewMessagesForCrm()  : bool
Is there any new message for crm.
isNewMessagesForGlobal()  : bool
Is there any new message for global.
isNewMessagesForGroup()  : bool
Is there any new message for group.
isNewMessagesForPrivate()  : bool
Is there any new message for global.
isPrivateRoomAllowed()  : bool
Is private room allowed for specified user.
isRecordOwner()  : bool
Is record owner.
isRoomExists()  : bool
Check if chat room exists.
isRoomModerator()  : bool
Is room moderator.
isUserRoomCreated()  : mixed
Check if user room is created.
pinAllUsers()  : mixed
Pin all users.
pinTargetUserRoom()  : mixed
Pin target user room when is unpinned.
removeFromFavorites()  : bool
Remove room from favorites.
setCurrentRoom()  : mixed
Set current room ID, type.
setCurrentRoomDefault()  : array<string|int, mixed>|false
Set default room as current room.
setUserRoomRecordId()  : mixed
Set user room recordId.
decodeMessage()  : string
Decode message.
decodeNoHtmlMessage()  : string
Decode message without html except completions.
getLastMessageId()  : array<string|int, mixed>
Get last message id.
getQueryForUnread()  : Query
Get query for unread messages.
getQueryMessage()  : Query
Get a query for chat messages.
markAsRead()  : mixed
Mark as read.
updateRoom()  : mixed
Update last message ID.

Constants

ALLOWED_ROOM_TYPES

Information about allowed types of rooms.

public mixed ALLOWED_ROOM_TYPES = ['crm', 'group', 'global', 'private', 'user']

COLUMN_NAME

Information about the columns of the database.

public mixed COLUMN_NAME = ['message' => ['crm' => 'crmid', 'group' => 'groupid', 'global' => 'globalid', 'private' => 'privateid', 'user' => 'roomid'], 'room' => ['crm' => 'crmid', 'group' => 'groupid', 'global' => 'global_room_id', 'private' => 'private_room_id', 'user' => 'roomid'], 'room_name' => ['crm' => 'label', 'group' => 'groupname', 'global' => 'name', 'private' => 'name', 'user' => 'roomid']]

TABLE_NAME

Information about the tables of the database.

public mixed TABLE_NAME = ['message' => ['crm' => 'u_#__chat_messages_crm', 'group' => 'u_#__chat_messages_group', 'global' => 'u_#__chat_messages_global', 'private' => 'u_#__chat_messages_private', 'user' => 'u_#__chat_messages_user'], 'room' => ['crm' => 'u_#__chat_rooms_crm', 'group' => 'u_#__chat_rooms_group', 'global' => 'u_#__chat_rooms_global', 'private' => 'u_#__chat_rooms_private', 'user' => 'u_#__chat_rooms_user'], 'room_name' => ['crm' => 'u_#__crmentity_label', 'group' => 'vtiger_groups', 'global' => 'u_#__chat_global', 'private' => 'u_#__chat_private', 'user' => 'u_#__chat_user'], 'users' => 'vtiger_users']

Properties

$recordId

ID record associated with the chat room.

public int|null $recordId

$roomType

Type of chat room.

public string $roomType

$lastMessageId

Last message ID.

private int|null $lastMessageId = 0

$room

private array<string|int, mixed>|false $room = false

$userId

User ID.

private int $userId

Methods

__construct()

Chat constructor.

public __construct(string|null $roomType, int|null $recordId) : mixed
Parameters
$roomType : string|null
$recordId : int|null
Tags
throws
IllegalValue
Return values
mixed

addMessage()

Add new message to chat room.

public addMessage(string $message) : int
Parameters
$message : string
Tags
throws
Exception
Return values
int

addParticipantToPrivate()

Add participant to private room.

public addParticipantToPrivate(int $userId) : bool
Parameters
$userId : int
Return values
bool

$alreadyInvited

addToFavorites()

Add room to favorites.

public addToFavorites() : mixed
Tags
throws
Exception
Return values
mixed

addToFavoritesQuery()

Add room to favorites query.

public addToFavoritesQuery([int|null $userId = null ]) : mixed
Parameters
$userId : int|null = null
Tags
throws
Exception
Return values
mixed

archivePrivateRoom()

Archive private room.

public archivePrivateRoom(int $recordId) : mixed
Parameters
$recordId : int
Return values
mixed

createPrivateRoom()

Create private room.

public createPrivateRoom(string $name) : mixed
Parameters
$name : string
Return values
mixed

createRoom()

Create chat room.

public static createRoom(string $roomType, int $recordId) : Chat
Parameters
$roomType : string
$recordId : int
Tags
throws
IllegalValue
throws
Exception
Return values
Chat

createUserRoom()

Create user room.

public createUserRoom(int $relUserId) : int
Parameters
$relUserId : int
Return values
int

getActiveRoomTypes()

Get active room types.

public static getActiveRoomTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getChatModules()

Get chat modules.

public static getChatModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

getChatUsers()

Get chat users.

public static getChatUsers() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCurrentRoom()

Get current room ID, type.

public static getCurrentRoom() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

getDefaultRoom()

Get default room.

public static getDefaultRoom() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

getEntries()

Get entries function.

public getEntries(int|null $messageId[, string $condition = '>' ][, string|null $searchVal = null ]) : array<string|int, mixed>
Parameters
$messageId : int|null
$condition : string = '>'
$searchVal : string|null = null
Tags
throws
AppException
throws
IllegalValue
throws
Exception
Return values
array<string|int, mixed>

getHistoryByType()

Get history by type.

public getHistoryByType([string $roomType = 'global' ][, int|null $messageId = null ]) : array<string|int, mixed>
Parameters
$roomType : string = 'global'
$messageId : int|null = null
Return values
array<string|int, mixed>

getInstance()

Get instance \App\Chat.

public static getInstance([string|null $roomType = null ][, int|null $recordId = null ]) : Chat
Parameters
$roomType : string|null = null
$recordId : int|null = null
Tags
throws
IllegalValue
Return values
Chat

getNumberOfNewMessages()

Rerun the number of new messages.

public static getNumberOfNewMessages([array<string|int, mixed>|null $roomInfo = null ]) : array<string|int, mixed>
Parameters
$roomInfo : array<string|int, mixed>|null = null
Return values
array<string|int, mixed>

getParticipants()

Get getParticipants.

public getParticipants() : array<string|int, mixed>
Return values
array<string|int, mixed>

getQueryRoom()

Get a query for chat room.

public getQueryRoom() : Query
Return values
Query

getRecordId()

Get record ID.

public getRecordId() : int|null
Return values
int|null

getRoomLastMessage()

Get room last message.

public static getRoomLastMessage(int $roomId, string $roomType) : array<string|int, mixed>
Parameters
$roomId : int
$roomType : string
Return values
array<string|int, mixed>

getRoomPrivateUnpinnedUsers()

List of unpinned users to private room.

public static getRoomPrivateUnpinnedUsers(int $roomId) : array<string|int, mixed>
Parameters
$roomId : int
Return values
array<string|int, mixed>

getRoomsByUser()

Get all chat rooms by user.

public static getRoomsByUser([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsCrm()

CRM list of chat rooms.

public static getRoomsCrm([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsGlobal()

List global chat rooms.

public static getRoomsGlobal([int $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int = null
Return values
array<string|int, mixed>

getRoomsGlobalUnpinned()

List unpinned global chat rooms.

public static getRoomsGlobalUnpinned([int $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int = null
Return values
array<string|int, mixed>

getRoomsGroup()

List of chat room groups.

public static getRoomsGroup([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsGroupUnpinned()

Get rooms group unpinned.

public static getRoomsGroupUnpinned([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsPrivate()

List of private chat rooms.

public static getRoomsPrivate([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsPrivateUnpinned()

List of unpinned private chat rooms.

public static getRoomsPrivateUnpinned([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsUnpinnedQuery()

Create query for unpinned rooms.

public static getRoomsUnpinnedQuery(string $roomType, int $userId) : object
Parameters
$roomType : string
$userId : int
Return values
object

getRoomsUser()

Get rooms user unpinned.

public static getRoomsUser([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsUserUnpinned()

Get rooms user unpinned.

public static getRoomsUserUnpinned([int|null $userId = null ]) : array<string|int, mixed>
Parameters
$userId : int|null = null
Return values
array<string|int, mixed>

getRoomsUserUnpinnedQuery()

Get rooms user unpinned query.

public static getRoomsUserUnpinnedQuery([int|null $userId = null ]) : object
Parameters
$userId : int|null = null
Return values
object

getRoomType()

Get room type.

public getRoomType() : string|null
Return values
string|null

getRoomTypeLastMessage()

Get room type last message.

public static getRoomTypeLastMessage(string $roomType) : array<string|int, mixed>
Parameters
$roomType : string
Return values
array<string|int, mixed>

getUnreadByType()

Get unread messages.

public static getUnreadByType([string $roomType = 'global' ]) : array<string|int, mixed>
Parameters
$roomType : string = 'global'
Tags
throws
AppException
Return values
array<string|int, mixed>

getUserInfo()

Get user info.

public static getUserInfo(int $userId) : array<string|int, mixed>
Parameters
$userId : int
Tags
throws
AppException
Return values
array<string|int, mixed>

isAssigned()

Is the user assigned to the chat room.

public isAssigned() : bool
Return values
bool

isNewMessages()

Is there any new message.

public static isNewMessages() : bool
Return values
bool

isNewMessagesForCrm()

Is there any new message for crm.

public static isNewMessagesForCrm(int $userId) : bool
Parameters
$userId : int
Return values
bool

isNewMessagesForGlobal()

Is there any new message for global.

public static isNewMessagesForGlobal(int $userId) : bool
Parameters
$userId : int
Return values
bool

isNewMessagesForGroup()

Is there any new message for group.

public static isNewMessagesForGroup(int $userId) : bool
Parameters
$userId : int
Return values
bool

isNewMessagesForPrivate()

Is there any new message for global.

public static isNewMessagesForPrivate(int $userId) : bool
Parameters
$userId : int
Return values
bool

isPrivateRoomAllowed()

Is private room allowed for specified user.

public isPrivateRoomAllowed(int $recordId[, int $userId = null ]) : bool
Parameters
$recordId : int
$userId : int = null
Return values
bool

isRecordOwner()

Is record owner.

public isRecordOwner() : bool
Return values
bool

isRoomExists()

Check if chat room exists.

public isRoomExists() : bool
Return values
bool

isRoomModerator()

Is room moderator.

public isRoomModerator(int $recordId) : bool
Parameters
$recordId : int
Return values
bool

isUserRoomCreated()

Check if user room is created.

public static isUserRoomCreated(mixed $userId, mixed $relUserId) : mixed
Parameters
$userId : mixed
$relUserId : mixed
Tags
throws
Exception
Return values
mixed

pinAllUsers()

Pin all users.

public static pinAllUsers(int $userId) : mixed
Parameters
$userId : int
Return values
mixed

pinTargetUserRoom()

Pin target user room when is unpinned.

public pinTargetUserRoom() : mixed
Tags
throws
Exception
Return values
mixed

removeFromFavorites()

Remove room from favorites.

public removeFromFavorites([int|null $userId = null ]) : bool
Parameters
$userId : int|null = null
Tags
throws
Exception
Return values
bool

$success

setCurrentRoom()

Set current room ID, type.

public static setCurrentRoom(string $roomType, int|null $recordId) : mixed
Parameters
$roomType : string
$recordId : int|null
Tags
throws
IllegalValue
Return values
mixed

setCurrentRoomDefault()

Set default room as current room.

public static setCurrentRoomDefault() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

setUserRoomRecordId()

Set user room recordId.

public setUserRoomRecordId() : mixed
Tags
throws
Exception
Return values
mixed

decodeMessage()

Decode message.

private static decodeMessage(string $message) : string
Parameters
$message : string
Return values
string

decodeNoHtmlMessage()

Decode message without html except completions.

private static decodeNoHtmlMessage(string $message[, bool $linksAllowed = true ]) : string
Parameters
$message : string
$linksAllowed : bool = true
Return values
string

getLastMessageId()

Get last message id.

private static getLastMessageId([array<string|int, mixed> $messages = [] ]) : array<string|int, mixed>
Parameters
$messages : array<string|int, mixed> = []
Return values
array<string|int, mixed>

getQueryForUnread()

Get query for unread messages.

private static getQueryForUnread([string $roomType = 'global' ]) : Query
Parameters
$roomType : string = 'global'
Return values
Query

getQueryMessage()

Get a query for chat messages.

private getQueryMessage(int|null $messageId[, string $condition = '>' ][, string|null $searchVal = null ][, bool $isLimit = true ]) : Query
Parameters
$messageId : int|null
$condition : string = '>'
$searchVal : string|null = null
$isLimit : bool = true
Tags
throws
IllegalValue
Return values
Query

markAsRead()

Mark as read.

private static markAsRead(string $roomType[, array<string|int, mixed> $messages = [] ]) : mixed
Parameters
$roomType : string
$messages : array<string|int, mixed> = []
Tags
throws
Exception
Return values
mixed

updateRoom()

Update last message ID.

private updateRoom() : mixed
Tags
throws
IllegalValue
throws
Exception
Return values
mixed

        

Search results