method insertByOption documentation in bbn\Appui\Notification
function(string $title, string $content, string $id_option, bool $user_excluded = false)
{
if (!bbn\Str::isUid($id_option)) {
$id_option = \array_reverse(\explode('/', $id_option));
if (\count($id_option) === 2) {
$id_option[] = 'list';
}
$id_option = self::getOptionId(...$id_option);
}
if (bbn\Str::isUid($id_option)
&& ($ucfg = $this->user->getClassCfg())
&& ($ocfg = $this->opt->getClassCfg())
&& ($groups = $this->db->getColumnValues($ucfg['tables']['groups'], $ucfg['arch']['groups']['id'], [$ucfg['arch']['groups']['type'] => 'real']))
&& ($id_perm = $this->db->selectOne($ocfg['table'], $ocfg['arch']['options']['id'], [$ocfg['arch']['options']['code'] => 'opt'.$id_option]))
&& ($perm = $this->opt->option($id_perm))
) {
$users = [];
$is_public = !empty($perm['public']);
$current_id_user = $this->user->getId();
foreach ($groups as $group) {
$has_perm = $this->pref->groupHas($id_perm, $group);
$group_users = $this->db->selectAll(
$ucfg['table'], [], [
$ucfg['arch']['users']['id_group'] => $group,
$ucfg['arch']['users']['active'] => 1
]
);
foreach ($group_users as $user) {
$id_user = $user->{$ucfg['arch']['users']['id']};
if (!\in_array($id_user, $users, true)
&& (!$user_excluded || ($current_id_user !== $id_user))
&& ($is_public
|| $has_perm
|| $this->pref->userHas($id_perm, $id_user)
|| (!empty($user->{$ucfg['arch']['users']['admin']})
|| !empty($user->{$ucfg['arch']['users']['dev']})))
) {
$users[] = $id_user;
}
}
}
if (!empty($users)) {
return $this->insert($title, $content, $id_option, $users);
}
}
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