method create documentation in bbn\Appui\Notification
function(string $opt_path, string $title, string $content, $perms = true, string $opt_text = '', string $cat_text = '', bool $user_excluded = false)
{
if ($list_opt = self::getOptionId('list')) {
$ocfg = $this->opt->getClassCfg();
$pcfg = $this->pref->getClassCfg();
$users = \is_array($perms) ? $perms : [];
$perms = \is_bool($perms) && !empty($perms) && defined('BBN_ID_PERMISSION');
if (!($id_opt = $this->opt->fromPath($opt_path, '/', $list_opt))) {
$bits = \explode('/', $opt_path);
if (count($bits) === 2) {
if ($perms) {
// Get permissions from the current BBN_ID_PERMISSION value
$permissions = $this->db->selectAll(
$pcfg['table'], [
$pcfg['arch']['user_options']['id_user'],
$pcfg['arch']['user_options']['id_group']
], [$pcfg['arch']['user_options']['id_option'] => BBN_ID_PERMISSION]
);
$is_public = (bool)$this->opt->getProp(BBN_ID_PERMISSION, 'public');
$perm_parent = $this->perms->optionToPermission($list_opt, true);
}
$parent = $list_opt;
foreach ($bits as $i => $code) {
$text = ($i === 0) && !empty($cat_text) ? $cat_text : (($i === 1) && !empty($opt_text) ? $opt_text : $code);
if (!($p = $this->opt->fromCode($code, $parent))) {
$p = $this->opt->add(
[
$ocfg['arch']['options']['text'] => $text,
$ocfg['arch']['options']['code'] => $code,
$ocfg['arch']['options']['id_parent'] => $parent
]
);
}
if ($perms) {
if (!($pp = $this->perms->optionToPermission($p))) {
$pp = $this->perms->optionToPermission($p, true);
$this->opt->setProp($pp, ['public' => $is_public]);
if (!$is_public) {
foreach ($permissions as $perm) {
$this->lastDbId = $this->db->lastId();
if ($this->db->insert(
$pcfg['table'], [
$pcfg['arch']['user_options']['id_option'] => $pp,
$pcfg['arch']['user_options']['id_user'] => $perm->{$pcfg['arch']['user_options']['id_user']},
$pcfg['arch']['user_options']['id_group'] => $perm->{$pcfg['arch']['user_options']['id_group']}
]
) ) {
$this->lastId = $this->db->lastId();
}
$this->db->setLastInsertId($this->lastDbId);
}
}
}
$perm_parent = $pp;
}
$parent = $p;
if ($i === 1) {
$id_opt = $parent;
}
}
}
}
if (bbn\Str::isUid($id_opt)) {
if ($perms) {
return $perms ? $this->insertByOption($title, $content, $id_opt, $user_excluded) : $this->insert($title, $content, $id_opt, $users, $user_excluded);
}
}
}
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-2023
BBN Solutions