method orderBit documentation in bbn\User\Preferences

Orders a bit.

function(string $id, int $pos) { if ( \bbn\Str::isUid($id) && ($cf = $this->getClassCfg()) && ($cfg = $cf['arch']['user_options_bits']) && ($bit = $this->getBit($id)) && ($old = (int)$bit[$cfg['num']]) && !empty($pos) && ($old !== $pos) && ($bits = $this->getBits($bit[$cfg['id_user_option']], $bit[$cfg['id_parent']])) ) { $past_new = false; $past_old = false; $p = 1; $changed = 0; foreach ($bits as $ele) { $upd = []; if ($past_old && !$past_new) { $upd[$cfg['num']] = $p - 1; } elseif (!$past_old && $past_new) { $upd[$cfg['num']] = $p + 1; } if ($id === $ele['id']) { $upd[$cfg['num']] = $pos; $past_old = 1; } elseif ($p === $pos) { $upd[$cfg['num']] = $p + ($pos > $old ? -1 : 1); $past_new = 1; } if (!empty($upd)) { $changed += $this->db->update($cf['tables']['user_options_bits'], $upd, [$cfg['id'] => $ele['id']]); } if ($past_new && $past_old) { break; } $p++; } return (bool)$changed; } return null; }

Orders a 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.