method getChatByUsers documentation in bbn\Appui\Chat
function(array $users)
{
if ($this->check() && count($users)) {
$cfg = [
'tables' => ['bbn_chats'],
'fields' => ['bbn_chats.id'],
'join' => [],
'where' => ['blocked' => 0]
];
$users[] = $this->user->getId();
$users = array_unique($users);
foreach ($users as $i => $u) {
$cfg['join'][] = [
'table' => 'bbn_chats_users',
'alias' => 'u'.($i + 1),
'on' => [
'conditions' => [[
'field' => 'bbn_chats.id',
'exp' => 'u'.($i + 1).'.id_chat'
]]
]
];
$cfg['where']['u'.($i + 1).'.id_user'] = $u;
}
$id_chat = false;
$ids = $this->db->getColumnValues($cfg);
if (count($ids)) {
foreach ($ids as $id) {
if (count($this->getParticipants($id)) === count($users)) {
$id_chat = $id;
break;
}
}
}
if (!$id_chat) {
$id_chat = $this->create($users);
}
return $id_chat ?: null;
}
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.
© 2011-2023
BBN Solutions