Conversation members are returned with conversations list

This commit is contained in:
Pierre 2017-06-13 11:11:17 +02:00
parent 040750d11c
commit b4de521174

View File

@ -72,7 +72,10 @@ class conversations {
"last_active" => $processConversation["last_active"], "last_active" => $processConversation["last_active"],
"name" => ($processConversation["name"] == "" ? false : $processConversation["name"]), "name" => ($processConversation["name"] == "" ? false : $processConversation["name"]),
"following" => $processConversation["following"], "following" => $processConversation["following"],
"saw_last_message" => $processConversation["saw_last_message"] "saw_last_message" => $processConversation["saw_last_message"],
//Get and add conversation members
"conversation_members" => $this->getConversationMembers($processConversation["ID"]),
); );
} }
@ -80,6 +83,36 @@ class conversations {
return $conversationsList; return $conversationsList;
} }
/**
* Get a conversation members
*
* @param Integer $conversationID The ID of the conversation
* @return Array A list of the conversation members (empty arary may means that an error occured)
*/
public function getConversationMembers($conversationID) : array {
//Perform a request on the database
$tableName = $this->conversationUsersTable;
$conditions = "WHERE ID_".$this->conversationListTable." = ?";
$conditionsValues = array($conversationID*1);
$getFields = array("ID_utilisateurs as userID");
//Perform the request
$results = CS::get()->db->select($tableName, $conditions, $conditionsValues, $getFields);
if($results === false)
return array(); //An error occured
//Process results
$membersList = array();
foreach($results as $processUser)
$membersList[] = $processUser["userID"];
//Return result
return $membersList;
}
/** /**
* Create a new conversation * Create a new conversation
* *