/** * Load the form */ private function loadForm() { // create form $this->frm = new BackendForm('add'); // fetch the campaigns $campaigns = BackendMailmotorModel::getCampaignsAsPairs(); // fetch the groups $groupIds = BackendMailmotorModel::getGroupIDs(); $groups = BackendMailmotorModel::getGroupsWithRecipientsForCheckboxes(); // no groups were made yet if (empty($groups) && empty($groupIds)) { $this->redirect(BackendModel::createURLForAction('AddGroup') . '&error=add-mailing-no-groups'); } elseif (empty($groups)) { // groups were made, but none have subscribers $this->redirect(BackendModel::createURLForAction('Addresses') . '&error=no-subscribers'); } // fetch the languages $languages = BackendMailmotorModel::getLanguagesForCheckboxes(); // settings $this->frm->addText('name'); if (count($campaigns) > 1) { $this->frm->addDropdown('campaign', $campaigns); } // sender $this->frm->addText('from_name', $this->get('fork.settings')->get($this->getModule(), 'from_name')); $this->frm->addText('from_email', $this->get('fork.settings')->get($this->getModule(), 'from_email')); // reply-to address $this->frm->addText('reply_to_email', $this->get('fork.settings')->get($this->getModule(), 'reply_to_email')); // groups - if there is only 1 group present, we select it by default $this->frm->addMultiCheckbox('groups', $groups, count($groups) == 1 && isset($groups[0]) ? $groups[0]['value'] : false); // languages $this->frm->addRadiobutton('languages', $languages, BL::getWorkingLanguage()); }
/** * Get the data */ private function getData() { // get the record $this->record = (array) BackendMailmotorModel::getMailing($this->id); // get the campaigns $this->campaigns = (array) BackendMailmotorModel::getCampaignsAsPairs(); // no item found, throw an exceptions, because somebody is f*****g with our URL if (empty($this->record)) { $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing'); } }
/** * Load the form for step 1 */ private function loadFormForStep1() { // create form $this->frm = new BackendForm('step1'); // fetch the campaigns $campaigns = BackendMailmotorModel::getCampaignsAsPairs(); // fetch the groups $groups = BackendMailmotorModel::getGroupsWithRecipientsForCheckboxes(); // fetch the languages $languages = BackendMailmotorModel::getLanguagesForCheckboxes(); // settings $this->frm->addText('name', $this->record['name']); if (count($campaigns) > 1) { $this->frm->addDropdown('campaign', $campaigns, $this->record['campaign_id']); } // sender $this->frm->addText('from_name', $this->record['from_name']); $this->frm->addText('from_email', $this->record['from_email']); // reply-to address $this->frm->addText('reply_to_email', $this->record['reply_to_email']); // groups $this->frm->addMultiCheckbox('groups', $groups, $this->record['groups']); // languages $this->frm->addRadiobutton('languages', $languages, $this->record['language']); // show the form $this->tpl->assign('step1', true); }