method create documentation in bbn\Appui\Chat

Creates a new chat with the current user and another participant.

function(array $users, int $public = 0) { if ($this->check()) { $join = ''; $where = ''; $values = [$this->user->getId(), $public]; foreach ($users as $i => $u){ $join .= "JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id".PHP_EOL; $where .= "AND u$i.id_user = ?".PHP_EOL; $values[] = $u; } $sql = <<db->getOne($sql, $values)) && (count($users) === $this->db->count('bbn_chat_users', ['id_chat' => $id_chat])) ) { return $id_chat; } if ($this->db->insert( 'bbn_chats', [ 'creator' => $this->user->getId(), 'creation' => date('Y-m-d H:i:s'), 'public' => $public ? 1 : 0 ] ) ) { $id_chat = $this->db->lastId(); $this->db->insert( 'bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $this->user->getId(), 'entrance' => X::microtime(), 'admin' => 1 ] ); foreach ($users as $user) { $this->db->insertIgnore( 'bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $user, 'entrance' => X::microtime(), 'admin' => 0 ] ); } $this->_set_state_hash($id_chat); return $id_chat; } } return null; }

Creates a new chat with the current user and another participant. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.