method getByType documentation in bbn\Appui\Note
function($type = NULL, $id_user = false, int $limit = 10, int $start = 0)
{
$db = &$this->db;
$cf = &$this->class_cfg;
$res = [];
if (!Str::isUid($type)) {
$type = self::getOptionId(is_null($type) ? 'personal' : $type, 'types');
}
if (Str::isUid($type) && is_int($limit) && is_int($start)) {
$where = [[
'field' => $db->cfn($cf['arch']['notes']['id_type'], $cf['table']),
'value' => $type,
], [
'field' => $db->cfn($cf['arch']['notes']['active'], $cf['table']),
'value' => 1,
]];
if (Str::isUid($id_user)) {
$where[] = [
'field' => $db->cfn($cf['arch']['notes']['creator'], $cf['table']),
'value' => $id_user,
];
}
$cfg = $this->getLastVersionCfg();
$cfg['where'] = [
'conditions' => $where,
];
$cfg['limit'] = $limit;
$cfg['start'] = $start;
$notes = $db->rselectAll($cfg);
foreach ($notes as $note) {
if ($medias = $db->getColumnValues(
$cf['tables']['notes_medias'],
$cf['arch']['notes_medias']['id_media'],
[
$cf['arch']['notes_medias']['id_note'] => $note[$cf['arch']['versions']['id_note']]
]
)) {
$note['medias'] = [];
foreach ($medias as $m) {
if ($med = $db->rselect($cf['tables']['medias'], [], [$cf['arch']['medias']['id'] => $m])) {
if (Str::isJson($med[$cf['arch']['medias']['content']])) {
$med[$cf['arch']['medias']['content']] = json_decode($med[$cf['arch']['medias']['content']]);
}
$note['medias'][] = $med;
}
}
}
$res[] = $note;
}
X::sortBy($res, $cf['arch']['versions']['creation'], 'DESC');
return $res;
}
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-2024
BBN Solutions