method insert documentation in bbn\Appui\Notification
function(string $title, string $content, string $id_option = NULL, array $users = [], bool $user_excluded = false)
{
if (\is_string($id_option) && !bbn\Str::isUid($id_option)) {
$id_option = \array_reverse(\explode('/', $id_option));
$id_option[] = 'list';
$id_option = self::getOptionId(...$id_option);
}
if (!empty($title)
&& !empty($content)
&& (\is_null($id_option)
|| bbn\Str::isUid($id_option))
) {
$notification = [
$this->class_cfg['arch']['content']['id_option'] => $id_option,
$this->class_cfg['arch']['content']['title'] => $title,
$this->class_cfg['arch']['content']['content'] => $content,
$this->class_cfg['arch']['content']['creation'] => \date('Y-m-d H:i:s')
];
$this->lastDbId = $this->db->lastId();
if ($this->db->insert($this->class_cfg['tables']['content'], $notification)) {
$id = $this->db->lastId();
if (empty($users) && !$user_excluded) {
$users[] = $this->user->getId();
}
$i = 0;
$current_id_user = $this->user->getId();
foreach ($users as $u){
if ((!$user_excluded || ($current_id_user !== $u))
&& $this->_user_has_permission($notification, $u)
) {
$i += (int)$this->db->insert(
$this->class_table, [
$this->fields['id_content'] => $id,
$this->fields['id_user'] => $u
]
);
$this->lastId = $this->db->lastId();
}
}
$this->db->setLastInsertId($this->lastDbId);
return (bool)$i;
}
}
return false;
}
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-2024
BBN Solutions