method getByUser documentation in bbn\Appui\Imessages
Gets all user's internal messages
function(string $id_user)
{
$cfg =& $this->class_cfg;
// Current datetime
$now = date('Y-m-d H:i:s');
// Get the user's group
$id_group = $this->db->selectOne('bbn_users', 'id_group', ['id' => $id_user]);
$fields = array_map(
function ($a) use ($db, $cfg) {
return $db->cfn($a, $cfg['table']);
},
array_keys($this->db->getColumns($cfg['table']))
);
// Get all user's internal messages
$messages = $this->db->rselectAll(
[
'tables' => [$cfg['tables']['users']],
'fields' => $fields,
'join' => [
[
'table' => $cfg['table'],
'on' => [
[
'field' => $this->db->cfn($cfg['arch']['imessages']['id_user'], $cfg['table']),
'exp' => $this->db->cfn($cfg['arch']['users']['id_user'], $cfg['tables']['users'])
], [
'field' => $this->db->cfn($cfg['arch']['imessages']['id'], $cfg['table']),
'exp' => $this->db->cfn($cfg['arch']['users']['id_imessage'], $cfg['tables']['users'])
]
]
]
],
'where' => [
'conditions' => [
[
'logic' => 'OR',
'conditions' => [
[
'field' => $this->db->cfn($cfg['arch']['imessages']['start'], $cfg['table']),
'operator' => 'isnull'
], [
'field' => $this->db->cfn($cfg['arch']['imessages']['start'], $cfg['table']),
'operator' => '<=',
'exp' => 'NOW()'
]
]
], [
'logic' => 'OR',
'conditions' => [
[
'field' => $this->db->cfn($cfg['arch']['imessages']['end'], $cfg['table']),
'operator' => 'isnull'
], [
'field' => $this->db->cfn($cfg['arch']['imessages']['end'], $cfg['table']),
'operator' => '>',
'exp' => 'NOW()'
]
]
], [
'logic' => 'OR',
'conditions' => [
[
'field' => $this->db->cfn($cfg['arch']['imessages']['id_user'], $cfg['table']),
'value' => $id_user
], [
'field' => $this->db->cfn($cfg['arch']['imessages']['id_group'], $cfg['table']),
'value' => $id_group
], [
'logic' => 'OR',
'conditions' => [
[
'field' => $this->db->cfn($cfg['arch']['imessages']['id_user'], $cfg['table']),
'operator' => 'isnull'
], [
'field' => $this->db->cfn($cfg['arch']['imessages']['id_group'], $cfg['table']),
'operator' => 'isnull'
]
]
]
]
], [
'logic' => 'OR',
'conditions' => [
[
'field' => $this->db->cfn($cfg['arch']['users']['hidden'], $cfg['tables']['users']),
'operator' => 'isnull'
], [
'field' => $this->db->cfn($cfg['arch']['users']['hidden'], $cfg['tables']['users']),
'operator' => '=',
'value' => 0
]
]
]
]
]
]
);
// Get and return the imessage's info from notes archive
return $this->fromNotes($messages);
}
Gets all user's internal messages 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