stanley-king 6 jaren geleden
bovenliggende
commit
10859a3c2b

+ 4 - 1
data/model/room.model.php

@@ -30,7 +30,10 @@ class roomModel extends Model
         $ret = $this->table('room_participant')->where(['room_id' => $room_id,'member_id' => $user])->update(['leave_time' => time(),'state' => 1]);
         return $ret;
     }
-
+    public function kickout($room_id,$user) {
+        $ret = $this->table('room_participant')->where(['room_id' => $room_id,'member_id' => $user])->update(['leave_time' => time(),'state' => 2]);
+        return $ret;
+    }
     ///群聊接口//////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function create_room($type,$name,$creator,$owner,$owner_name,$max_user = 0) {
         $params = ['type' => $type,'room_name' => $name,'room_creator' => $creator,'room_owner' => $owner,'owner_name' => $owner_name,'max_user' => $max_user,'add_time' => time()];

+ 48 - 4
helper/room/base_room.php

@@ -32,6 +32,7 @@ abstract class base_room
         $this->mParticipants = $participants;
         $this->mod_room = Model('room');
     }
+
     public function room_id() {
         return $this->mRoomInfo->room_id();
     }
@@ -41,6 +42,13 @@ abstract class base_room
     public function room_info() {
         return $this->mRoomInfo->format();
     }
+    public function room_name() {
+        return $this->mRoomInfo->name();
+    }
+//    private function notify_change()
+//    {
+//        $name =
+//    }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function invite($inviter,$invitees,&$newusers)
     {
@@ -50,11 +58,12 @@ abstract class base_room
             if($users === false) {
                 $ret = ['room' => $this->mRoomid,'invitees' => []];
             }
-            else {
+            else
+            {
                 $ret = ['room' => $this->mRoomid,'invitees' => $users];
                 if(!empty($newusers)) {
                     $content = $this->format_invite($inviter,$newusers);
-                    $this->relay_broadcast('invite',['type' => proto_type::msg_stype_text,'content' => $content]);
+                    $this->relay_broadcast('plain',['msgid' => -1,'type' => proto_type::msg_stype_text,'content' => $content,'send_time' => time()]);
                 }
             }
             return $ret;
@@ -63,15 +72,37 @@ abstract class base_room
             return false;
         }
     }
+
+    public function kickout($manager,$users)
+    {
+        $fadmin = $this->mRoomInfo->isAdmin($manager);
+        if($fadmin == false) return false;
+
+        $kicks = [];
+        foreach ($users as $user)
+        {
+            $fadmin = $this->mRoomInfo->isAdmin($user);
+            if($fadmin) continue;
+
+            if($this->kick_out($user) != false) {
+                $kicks[] = $user;
+            }
+        }
+
+        return $kicks;
+    }
+
     private function format_invite($inviter,$invitees)
     {
         $invitees = $this->userinfos($invitees);
         $inviter  = $this->userinfos($inviter);
 
-        $str = $inviter['nickname'] . "邀请:";
+        $str = "<font color='#3c78d8'>{$inviter['nickname']}</font>邀请:";
+        $sinvitees = [];
         foreach ($invitees as $user) {
-            $str .= "{$user['nickname']} ";
+            $sinvitees[] = "<font color='#3c78d8'>{$user['nickname']}</font>";
         }
+        $str .= implode(',',$sinvitees);
         $str .= " 加入群聊";
 
         return $str;
@@ -130,6 +161,7 @@ abstract class base_room
 
         return $result;
     }
+
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function leave($userid)
     {
@@ -142,6 +174,18 @@ abstract class base_room
             return false;
         }
     }
+    public function kick_out($userid)
+    {
+        $ret = $this->find($userid);
+        if($ret != false) {
+            unset($this->mParticipants[$userid]);
+            $this->mod_room->kickout($this->room_id(),$userid);
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function messageOp($input)
     {

+ 3 - 5
helper/room/msg_builder.php

@@ -44,7 +44,7 @@ class msg_builder
         return $msg;
     }
 
-    public static function invite_push($roomid,$invitees,$inviter,$info)
+    public static function invited_push($roomid, $invitees, $inviter, $room_info)
     {
         $msg = [];
 
@@ -57,10 +57,10 @@ class msg_builder
         $msg['receiver_type'] = proto_type::sroom_push;
 
         $msg['body']['act'] = proto_type::act_room;
-        $msg['body']['op'] = 'invite';
+        $msg['body']['op'] = 'invited';
         $msg['body']['msgtype'] = "message";
         $msg['body']['room'] = $roomid;
-        $msg['body']['room_info'] = $info;
+        $msg['body']['room_info'] = $room_info;
         $msg['body']['inviter'] = $inviter;
 
         return $msg;
@@ -91,6 +91,4 @@ class msg_builder
 
         return $msg;
     }
-
-
 }

+ 6 - 5
helper/room/room_info.php

@@ -57,8 +57,6 @@ class room_info
     public function owner_name() {
         return $this->mParams['owner_name'];
     }
-
-
     public function max_user() {
         return intval($this->mParams['max_user']);
     }
@@ -71,9 +69,6 @@ class room_info
     public function level(){
         return intval($this->mParams['room_level']);
     }
-
-
-
     public function shared_bonus(){
         return $this->mParams['shared_bonus'];
     }
@@ -83,7 +78,13 @@ class room_info
     public function passwd(){
         return $this->mParams['passwd'];
     }
+    public function isAdmin($uid)
+    {
+        $uid = intval($uid);
+        if($uid <= 0) return false;
 
+        return ($uid == $this->creator() || $uid == $this->owner());
+    }
 
     public function format()
     {

+ 2 - 5
helper/room/util.php

@@ -309,8 +309,8 @@ class talks_helper
     }
 }
 
-class members{
-
+class members
+{
     public static function get_members($uids)
     {
         $members = [];
@@ -333,7 +333,6 @@ class members{
         return $members;
     }
 
-
     public static function uids_filter($operater,$needle)
     {
         $uids = [];
@@ -389,8 +388,6 @@ class room_helper
         }
     }
 
-
-
     public static function room_uids($roomid,$limit=false)
     {
         $uids = [];

+ 1 - 0
helper/util_helper.php

@@ -833,4 +833,5 @@ class string_helper
 
         return $languageSpecific[$language] ? $languageSpecific[$language] : null;
     }
+
 }

BIN
mac_webacc


+ 1 - 1
mobile/control/game.php

@@ -67,7 +67,7 @@ class gameControl extends mbMemberControl
         if($stCreator == 0) {
             $mod_room = Model('room');
             $params = $mod_room->getRoom($room_id);
-            $rinfo = new room\base_info($params);
+            $rinfo = new room\room_info($params);
             $stCreator = $rinfo->creator();
         }
 

+ 10 - 0
mobile/control/member_talk.php

@@ -268,6 +268,16 @@ class member_talkControl extends mbMemberControl
     {
         $creator = session_helper::memberid();
         $result = room\factory_client::instance()->create_chat($creator);
+
+        if(!empty($_GET['invitees']))
+        {
+            $room = $result['room_id'];
+            $invitees = explode(',', trim($_GET['invitees']));
+            if(!empty($invitees) && $room > 0) {
+                room\factory_client::instance()->invite($room,$creator,$invitees);
+            }
+        }
+
         return self::outsuccess($result);
     }
 

+ 1 - 1
test/TestRoomFactory.php

@@ -136,7 +136,7 @@ class TestRoomFactory extends PHPUnit_Framework_TestCase
     {
         $mod_room = Model('room');
         $params = $mod_room->getRoom($room_id);
-        $rinfo = new room\base_info($params);
+        $rinfo = new room\room_info($params);
         return $rinfo->creator();
     }
 }

+ 1 - 1
test/TestRoomSrv.php

@@ -88,7 +88,7 @@ class TestRoomSrv extends PHPUnit_Framework_TestCase
     {
         $mod_room = Model('room');
         $params = $mod_room->getRoom($room_id);
-        $rinfo = new room\base_info($params);
+        $rinfo = new room\room_info($params);
         return $rinfo->creator();
     }
 

+ 1 - 1
test/TestTalk.php

@@ -51,7 +51,7 @@ class TestTalk extends PHPUnit_Framework_TestCase
         if($stCreator == 0) {
             $mod_room = Model('room');
             $params = $mod_room->getRoom($room_id);
-            $rinfo = new room\base_info($params);
+            $rinfo = new room\room_info($params);
             $stCreator = $rinfo->creator();
         }