Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

message_get_conversation()

Description

Get all messages between the given user IDs


"msgfind" - (string) Text to find
"sort_desc" - (bool) Sort by message ID in descending order? False = Ascending
"limit" - (int) Maximum number of messages to return

Parameters

ColumnTypeDefaultDescription
$user int
$msgusers array array Array of other user IDs
$filteropts array array: array { array_map"is_int_loose" Array of extra options to filter and sort messages returned
$msgusers;
$users int User ID

Return

array Array of messages

Location

include/message_functions.php lines 894 to 937

Definition

 
function message_get_conversation(int $user$msgusers = array(),$filteropts = array()): array
    {
    
array_map("is_int_loose",$msgusers);
    if(
count($msgusers) == || !is_int_loose($user))
        {
        return array();
        }

    
$msgfind $filteropts['msgfind'] ?? '';
    
$sort_desc $filteropts['sort_desc'] ?? false;
    
$limit $filteropts['limit'] ?? 0;

    
# Build array of sql query parameters
    
$parameters ps_param_fill($msgusers,"i");
    
$parameters array_merge($parameters, array("i",$user), array("i",$user));
    
$parameters array_merge($parametersps_param_fill($msgusers,"i"));
    if (
$msgfind != "" )
        {
        
$parameters array_merge($parameters, array("s"$msgfind));
        }
    if (
$limit 0)
        {
        
$parameters array_merge($parameters, array("i", (int)$limit));
        }
    
$msgquery "SELECT message.created,
                        message.owner,
                        message.message,
                        message.url,
                        message.expires,
                        message.type,
                        user_message.user,
                        user_message.ref,
                        user_message.seen
                   FROM message
              LEFT JOIN user_message ON user_message.message=message.ref
                  WHERE ((owner IN(" 
ps_param_insert(count($msgusers)) . ") AND user_message.user = ?)
                     OR (owner = ? AND user_message.user IN(" 
ps_param_insert(count($msgusers)) . ")))"
           
.  ($msgfind != "" ? (" AND message.message LIKE ?") : " " )
           . 
" AND type & '" MESSAGE_ENUM_NOTIFICATION_TYPE_USER_MESSAGE "'"
           
" ORDER BY user_message.ref " . ($sort_desc "DESC" "ASC")
           . (
$limit " LIMIT ?" "");

    return 
ps_query($msgquery$parameters);
    }

This article was last updated 17th November 2024 15:05 Europe/London time based on the source file dated 1st July 2024 16:10 Europe/London time.