method updateBit documentation in bbn\User\Preferences
Updates a preference's bit
function(string $id, array $cfg, bool $merge_config = true)
{
if (\bbn\Str::isUid($id)) {
$c = $this->class_cfg['arch']['user_options_bits'];
if (\array_key_exists($c['id'], $cfg)) {
unset($cfg[$c['id']]);
}
if (!empty($cfg[$c['cfg']]) && \bbn\Str::isJson($cfg[$c['cfg']])) {
$cfg[$c['cfg']] = json_decode($cfg[$c['cfg']], true);
}
$to_cfg = $this->getBitCfg(null, $cfg[$c['cfg']] ?? $cfg);
if (isset($to_cfg['items'])) {
unset($to_cfg['items']);
}
$update = [];
$from_cfg = $this->getBitCfg($id);
if (!empty($to_cfg)) {
if ($merge_config && !empty($from_cfg)) {
$update['cfg'] = json_encode(array_merge($from_cfg, $to_cfg));
}
else {
$update['cfg'] = json_encode($to_cfg);
}
}
elseif (!$merge_config) {
$update['cfg'] = null;
}
if (isset($cfg[$c['id_parent']])) {
$update[$c['id_parent']] = $cfg[$c['id_parent']];
}
if (isset($cfg[$c['id_option']])) {
$update[$c['id_option']] = $cfg[$c['id_option']];
}
if (isset($cfg[$c['num']])) {
$update[$c['num']] = $cfg[$c['num']];
}
if (isset($cfg[$c['text']])) {
$update[$c['text']] = $cfg[$c['text']];
}
return count($update) ? $this->db->update(
$this->class_cfg['tables']['user_options_bits'],
$update,
[$c['id'] => $id]
) : 0;
}
return null;
}
Updates a preference's bit 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