|
@@ -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)
|
|
|
{
|