/** * Updates a mailing * * @param array $item The mailing record to update. */ public static function updateMailing(array $item) { $local = $item; self::deleteMailings($item['id']); // fetch the CM IDs for each group if this field is not set yet if (!isset($item['group_cm_ids'])) { $item['group_cm_ids'] = self::getCampaignMonitorIDsForGroups($item['groups']); } // fetch the content URLs if (!isset($item['content_html_url'])) { $item['content_html_url'] = BackendMailmotorModel::getMailingPreviewURL($item['id'], 'html', true); } if (!isset($item['content_plain_url'])) { $item['content_plain_url'] = BackendMailmotorModel::getMailingPreviewURL($item['id'], 'plain', true); } // overwrite the name, because the previous one is taken -.- $item['name'] .= ' (#' . rand(0, 999) . ')'; // re-insert the mailing in CM self::insertMailing($item); // unset vars we don't need, save vars we need later $groups = $local['groups']; unset($local['cm_id'], $local['groups'], $local['recipients'], $local['delivery_date']); // serialize full content mailing $local['data'] = serialize($local['data']); // re-insert the mailing in our database $id = BackendMailmotorModel::insertMailing($local); // reinsert the groups for this mailing BackendMailmotorModel::updateGroupsForMailing($id, $groups); }
/** * Load the form for step 4 */ private function loadFormForStep4() { // check if we have to redirect back to step 3 (HTML content is not set) if (empty($this->record['content_html'])) { $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $this->id . '&step=3&error=complete-step-3'); } // get preview URL $previewURL = BackendMailmotorModel::getMailingPreviewURL($this->record['id'], 'html', true); // check if the mailmotor is linked if (BackendModel::getURLForBlock($this->getModule(), 'detail') == BackendModel::getURL(404)) { $previewURL = false; } // parse the preview URL $this->tpl->assign('previewURL', $previewURL); // create form $this->frm = new BackendForm('step4'); // subject $this->frm->addText('email'); $this->frm->addDate('send_on_date', $this->record['send_on']); $this->frm->addTime('send_on_time', \SpoonDate::getDate('H:i', $this->record['send_on'])); // show the form $this->tpl->assign('step4', true); }