Follow state of a conversation can be updated

This commit is contained in:
Pierre
2017-06-18 10:07:52 +02:00
parent b1e340e0c1
commit 952779f527
7 changed files with 84 additions and 15 deletions

View File

@ -207,6 +207,45 @@ class conversations {
return $result != 0;
}
/**
* Change the follow state of a user on conversation
*
* @param Integer $userID The ID to update
* @param Integer $conversationID The ID of the conversation
* @param Boolean $follow Specify if the conversation is followed or not
* @return Boolean True for a success
*/
public function changeFollowState($userID, $conversationID, $follow){
//Prepare the request on the database
$tableName = $this->conversationsUsersTable;
$conditions = "ID_".$this->conversationsListTable." = ? AND ID_utilisateurs = ?";
$condVals = array(
$conversationID,
$userID
);
//Defines modifications
$modifs = array(
"following" => $follow ? 1 : 0,
);
//Update the table
if(!CS::get()->db->updateDB($tableName, $conditions, $modifs, $condVals))
return false; //An error occured
//Success
return true;
}
/**
* Check if a user is a conversation moderator or not
*
* @param Integer $userID The ID of the user to check
* @param Integer $conversationID The ID of the conversation to check
* @return Boolean True if the user is a conversation moderator or not
*/
}
//Register component