douao7937 2014-04-09 21:10
浏览 48

如何将phpfreechat配置为私人消息模式?

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!

  • 写回答

1条回答 默认 最新

  • dongzheng4556 2014-04-09 21:34
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致