Users are marked as "read" when their browser download last messages

This commit is contained in:
Pierre
2017-06-26 10:38:58 +02:00
parent 46985a77f9
commit a82b65f18d
2 changed files with 38 additions and 2 deletions

View File

@ -509,6 +509,36 @@ class conversations {
return true;
}
/**
* Mark the user of a conversation as "read" for a conversation
*
* @param Integer $userID The ID of the user to update
* @param Integer $conversationID The ID of a conversation to update
* @return Boolean True for a success
*/
public function markUserAsRead($userID, $conversationID) : bool {
//Prepare database request
$tableName = $this->conversationsUsersTable;
$conditions = "ID_".$this->conversationsListTable." = ? AND ID_utilisateurs = ?";
$condVals = array(
$conversationID,
$userID
);
//Define new values
$newValues = array(
"saw_last_message" => 1
);
//Try to perform a request on the database
if(!CS::get()->db->updateDB($tableName, $conditions, $newValues, $condVals))
return false; //An error occured
//Success
return true;
}
/**
* Send a new message
*