method createGroup documentation in bbn\Appui\Chat

function(string $title, array $users, array $admins = []) { if (($time = X::microtime()) && !empty($users) && ($id_user = $this->user->getId()) && ($username = $this->user->getName()) && $this->db->insert( 'bbn_chats', [ 'title' => $title, 'creator' => $id_user, 'creation' => date('Y-m-d H:i:s', $time) ] ) && ($id = $this->db->lastId()) && $this->db->insert( 'bbn_chats_users', [ 'id_chat' => $id, 'id_user' => $id_user, 'entrance' => $time, 'admin' => 1 ] ) ) { $users = array_filter( $users, function ($u) use ($id_user) { return $u !== $id_user; } ); $admins = array_filter( $admins, function ($u) use ($id_user) { return $u !== $id_user; } ); $users_added = 0; $admins_added = 0; foreach ($users as $user) { if (bbn\Str::isUid($user)) { $users_added += $this->db->insert( 'bbn_chats_users', [ 'id_chat' => $id, 'id_user' => $user, 'entrance' => $time, 'admin' => 0 ] ); } } $this->_add_bot_message( $id, [ $id_user => X::_('You created this group'), "$username " . X::_('created this group') ] ); foreach ($users as $user) { if (bbn\Str::isUid($user)) { $name = $this->user->getName($user); $this->_add_bot_message( $id, [ $id_user => X::_('You added') . " $name " . X::_('to the group'), $user => $username . ' ' . X::_('added you to the group'), "$username " . X::_('added') . " $name " . X::_('to the group') ] ); if (\in_array($user, $admins, true)) { $admins_added += (int)$this->addAdmin($id, $user); } } } $this->_set_state_hash($id); return (count($users) === $users_added) && (count($admins) === $admins_added); } return null; }

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.