function(array $cfg, bool $addRole = true)
{
&& ($idType = $opt->fromCode('tasks', 'types', 'note', 'appui'))
&& isset($cfg['title'], $cfg['type'])
&& ($idNote = $this->noteCls->insert($cfg['title'], $cfg['content'] ?? '', $idType))
) {
if ( $this->db->insert('bbn_tasks', [
'id_note' => $idNote,
'type' => $cfg['type'],
'priority' => !empty($cfg['priority']) ? $cfg['priority'] : 3,
'id_parent' => !empty($cfg['id_parent']) ? $cfg['id_parent'] : null,
'id_alias' => !empty($cfg['id_alias']) ? $cfg['id_alias'] : null,
'deadline' => !empty($cfg['deadline']) ? $cfg['deadline'] : null,
'id_user' => $this->id_user ?: null,
'state' => !empty($cfg['state']) ? $cfg['state'] : $this->idState('opened'),
'creation_date' => $this->date ?: date('Y-m-d H:i:s'),
'private' => !empty($cfg['private']) ? 1 : 0
]) ){
$id = $this->db->lastId();
$this->addLog($id, 'insert');
if ($addRole) {
$this->addRole($id, 'managers');
}
/*
$subject = "Nouveau bug posté par {$this->user}";
$text = "{$this->user} a posté un nouveau bug
".
"$title
".
"".nl2br($text)."
".
"Rendez-vous dans votre interface APST pour lui répondre
";
$this->email($id, $subject, $text);
*/
return $id;
}
}
return false;
}