This is a question for those who are or have been acquainted with phpfreechat. I have a site with a phpfreechat module. The version of phpfreechat is 2.1.0. By default, phpfreechat has a chatroom where admin and users can talk to each other. But I, as an admin, want to have private conversations with each user. I mean, I don't want to users can talk to each other, just to me.
So, the question would be: How can I do this? How can I configure phpfreechat v2.x to a private message/conversation mode? Is this posible?
Last, I want to say that I did made a properly research on Google, S.O. and phpfreechat website before asking here. Of course, without any success.
Thank you all!
Okay ... Not used this before, but I've had a quick look through the code, and found the function that 'sends' the message to all other users (found in /server/container/messages.php)
This function is postMsgToChannel() ...
So basically, you could try copy/modify it to create one that only sends to a single user, which may look something like this:
static public function postMsgToUser($cid, $ruid, $suid, $body, $type = 'msg') {
$mid = self::generateMid($cid);
$msg = array(
'id' => $mid,
'sender' => $suid,
'recipient' => 'channel|'.$cid,
'type' => $type,
'body' => $body,
'timestamp' => time(),
);
// json encode msg before storing
$msg = json_encode($msg);
//send message to single user
$umdir = Container_users::getDir().'/'.$ruid.'/messages';
file_put_contents($umdir.'/'.$mid, $msg);
return $msg;
}
Where $ruid
is the recipient's uid, and $suid
is the senders uid.
The only problem I can foresee, is trying to figure out the user's id that you are sending to.