method add documentation in bbn\Appui\Mailing

Adds a new mailing and returns its ID.

function(array $cfg) { $notes = $this->_note(); if ($this->check() && $notes && bbn\X::hasProps($cfg, ['title', 'content', 'sender'], true) && ($id_type = Note::getOptionId('mailings','types')) && ($id_note = $notes->insert($cfg['title'], $cfg['content'], $id_type)) // Cannot give a date if no recipients selected && (!empty($cfg['recipients']) || empty($cfg['sent'])) ) { if (empty($cfg['sent'])) { $cfg['sent'] = null; } if ($this->db->insert( 'bbn_emailings', [ 'id_note' => $id_note, 'version' => 1, 'sender' => $cfg['sender'], 'recipients' => $cfg['recipients'] ?: null, 'sent' => $cfg['sent'] ] ) ) { $cfg['id'] = $this->db->lastId(); $cfg['id_note'] = $id_note; $cfg['version'] = 1; if (!empty($cfg['attachments'])) { foreach ($cfg['attachments'] as $f){ if (is_array($f)) { $notes->addMediaToNote($f['id_media'], $id_note, 1); } elseif (is_file($f)) { // Add media $notes->addMedia($id_note, $f); } } } if (bbn\X::hasProps($cfg, ['recipients', 'sent', 'emails'], true)) { $cfg['res'] = $this->insertEmails($cfg['id'], $cfg['sent'], $cfg['emails'], $cfg['priority'] ?? 5); } return $cfg; } } return null; }

Adds a new mailing and returns its ID. 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.