method addBit documentation in bbn\User\Preferences
Adds a bit to a preference
function(string $id_user_option, array $cfg)
{
if (
($id_user_option = $this->_getIdOption($id_user_option))
&& $this->isAuthorized($id_user_option)
&& ($c = $this->class_cfg['arch']['user_options_bits'])
) {
$to_cfg = $this->getBitCfg(null, $cfg);
if (isset($to_cfg['items'])) {
unset($to_cfg['items']);
}
if (!empty($to_cfg)) {
if (!empty($cfg[$c['cfg']])) {
if (\bbn\Str::isJson($cfg[$c['cfg']])) {
$cfg[$c['cfg']] = json_decode($cfg[$c['cfg']], true);
}
if (\is_array($cfg[$c['cfg']])) {
$cfg[$c['cfg']] = array_merge($cfg[$c['cfg']], $to_cfg);
}
else {
$cfg[$c['cfg']] = $to_cfg;
}
}
else {
$cfg[$c['cfg']] = $to_cfg;
}
$cfg[$c['cfg']] = json_encode($cfg[$c['cfg']]);
}
if (
$this->db->insert(
$this->class_cfg['tables']['user_options_bits'],
[
$c['id_user_option'] => $id_user_option,
$c['id_parent'] => $cfg[$c['id_parent']] ?? null,
$c['id_option'] => $cfg[$c['id_option']] ?? null,
$c['num'] => $cfg[$c['num']] ?? null,
$c['text'] => $cfg[$c['text']] ?? '',
$c['cfg'] => $cfg[$c['cfg']] ?? null,
]
)
) {
return $this->db->lastId();
}
}
return null;
}
Adds a bit to a preference 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-2025
BBN Solutions