method insertVersion documentation in bbn\Appui\Note
Adds a new version to the given note if it's different from the last, and returns the latest version.
function(string $id_note, string $title = '', string $content = '', string $excerpt = '')
{
if ($this->check()
&& ($usr = bbn\User::getInstance())
&& ($note = $this->get($id_note))
&& ($title || $content)
) {
$cf = &$this->class_cfg;
$latest = $note['version'] ?? 0;
if (!$latest
|| ($note['content'] != $content)
|| ($note['title'] != $title)
|| ($note['excerpt'] != $excerpt)
) {
$next = $latest + 1;
}
if (
isset($next) && $this->db->insert(
$cf['tables']['versions'],
[
$cf['arch']['versions']['id_note'] => $id_note,
$cf['arch']['versions']['version'] => $next ?? 1,
$cf['arch']['versions']['latest'] => 1,
$cf['arch']['versions']['title'] => $title,
$cf['arch']['versions']['content'] => $content,
$cf['arch']['versions']['excerpt'] => $excerpt ?: '',
$cf['arch']['versions']['id_user'] => $usr->getId(),
$cf['arch']['versions']['creation'] => date('Y-m-d H:i:s'),
]
)
) {
$this->db->update(
$cf['tables']['versions'],
[$cf['arch']['versions']['latest'] => 0],
[
$cf['arch']['versions']['id_note'] => $id_note,
['version', '!=', $next]
]
);
return $next;
}
return $latest;
}
return null;
}
Adds a new version to the given note if it's different from the last, and returns the latest version. 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